diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/CHANGELOG.md b/sdk/resourcemanager/apimanagement/armapimanagement/CHANGELOG.md index 9baf175a1046..14a15b4580a0 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/CHANGELOG.md +++ b/sdk/resourcemanager/apimanagement/armapimanagement/CHANGELOG.md @@ -1,5 +1,431 @@ # Release History +## 3.0.0 (2025-04-22) +### Breaking Changes + +- Type of `ErrorResponse.Error` has been changed from `*ErrorResponseBody` to `*ErrorDetail` +- Operation `*APIClient.Delete` has been changed to LRO, use `*APIClient.BeginDelete` instead. +- Operation `*UserClient.Delete` has been changed to LRO, use `*UserClient.BeginDelete` instead. +- Operation `*PolicyClient.ListByService` has supported pagination, use `*PolicyClient.NewListByServicePager` instead. +- Operation `*PolicyFragmentClient.ListByService` has supported pagination, use `*PolicyFragmentClient.NewListByServicePager` instead. +- Operation `*PortalConfigClient.ListByService` has supported pagination, use `*PortalConfigClient.NewListByServicePager` instead. +- Operation `*ProductPolicyClient.ListByProduct` has supported pagination, use `*ProductPolicyClient.NewListByProductPager` instead. + +### Features Added + +- New value `APITypeGrpc`, `APITypeOData` added to enum type `APIType` +- New value `ContentFormatGrpc`, `ContentFormatGrpcLink`, `ContentFormatOData`, `ContentFormatODataLink` added to enum type `ContentFormat` +- New value `HostnameTypeConfigurationAPI` added to enum type `HostnameType` +- New value `PlatformVersionStv21` added to enum type `PlatformVersion` +- New value `SKUTypeBasicV2`, `SKUTypeStandardV2` added to enum type `SKUType` +- New value `SoapAPITypeGRPC`, `SoapAPITypeOData` added to enum type `SoapAPIType` +- New enum type `APIGatewaySKUType` with values `APIGatewaySKUTypeStandard`, `APIGatewaySKUTypeWorkspaceGatewayPremium`, `APIGatewaySKUTypeWorkspaceGatewayStandard` +- New enum type `BackendType` with values `BackendTypePool`, `BackendTypeSingle` +- New enum type `DeveloperPortalStatus` with values `DeveloperPortalStatusDisabled`, `DeveloperPortalStatusEnabled` +- New enum type `GatewayListDebugCredentialsContractPurpose` with values `GatewayListDebugCredentialsContractPurposeTracing` +- New enum type `GatewaySKUCapacityScaleType` with values `GatewaySKUCapacityScaleTypeAutomatic`, `GatewaySKUCapacityScaleTypeManual`, `GatewaySKUCapacityScaleTypeNone` +- New enum type `KeyVaultRefreshState` with values `KeyVaultRefreshStateFalse`, `KeyVaultRefreshStateTrue` +- New enum type `LegacyAPIState` with values `LegacyAPIStateDisabled`, `LegacyAPIStateEnabled` +- New enum type `LegacyPortalStatus` with values `LegacyPortalStatusDisabled`, `LegacyPortalStatusEnabled` +- New enum type `MigrateToStv2Mode` with values `MigrateToStv2ModeNewIP`, `MigrateToStv2ModePreserveIP` +- New enum type `PolicyComplianceState` with values `PolicyComplianceStateCompliant`, `PolicyComplianceStateNonCompliant`, `PolicyComplianceStatePending` +- New enum type `PolicyRestrictionRequireBase` with values `PolicyRestrictionRequireBaseFalse`, `PolicyRestrictionRequireBaseTrue` +- New function `NewAPIGatewayClient(string, azcore.TokenCredential, *arm.ClientOptions) (*APIGatewayClient, error)` +- New function `*APIGatewayClient.BeginCreateOrUpdate(context.Context, string, string, GatewayResource, *APIGatewayClientBeginCreateOrUpdateOptions) (*runtime.Poller[APIGatewayClientCreateOrUpdateResponse], error)` +- New function `*APIGatewayClient.BeginDelete(context.Context, string, string, *APIGatewayClientBeginDeleteOptions) (*runtime.Poller[APIGatewayClientDeleteResponse], error)` +- New function `*APIGatewayClient.Get(context.Context, string, string, *APIGatewayClientGetOptions) (APIGatewayClientGetResponse, error)` +- New function `*APIGatewayClient.NewListByResourceGroupPager(string, *APIGatewayClientListByResourceGroupOptions) *runtime.Pager[APIGatewayClientListByResourceGroupResponse]` +- New function `*APIGatewayClient.NewListPager(*APIGatewayClientListOptions) *runtime.Pager[APIGatewayClientListResponse]` +- New function `*APIGatewayClient.BeginUpdate(context.Context, string, string, GatewayUpdateParameters, *APIGatewayClientBeginUpdateOptions) (*runtime.Poller[APIGatewayClientUpdateResponse], error)` +- New function `NewAPIGatewayConfigConnectionClient(string, azcore.TokenCredential, *arm.ClientOptions) (*APIGatewayConfigConnectionClient, error)` +- New function `*APIGatewayConfigConnectionClient.BeginCreateOrUpdate(context.Context, string, string, string, GatewayConfigConnectionResource, *APIGatewayConfigConnectionClientBeginCreateOrUpdateOptions) (*runtime.Poller[APIGatewayConfigConnectionClientCreateOrUpdateResponse], error)` +- New function `*APIGatewayConfigConnectionClient.BeginDelete(context.Context, string, string, string, string, *APIGatewayConfigConnectionClientBeginDeleteOptions) (*runtime.Poller[APIGatewayConfigConnectionClientDeleteResponse], error)` +- New function `*APIGatewayConfigConnectionClient.Get(context.Context, string, string, string, *APIGatewayConfigConnectionClientGetOptions) (APIGatewayConfigConnectionClientGetResponse, error)` +- New function `*APIGatewayConfigConnectionClient.NewListByGatewayPager(string, string, *APIGatewayConfigConnectionClientListByGatewayOptions) *runtime.Pager[APIGatewayConfigConnectionClientListByGatewayResponse]` +- New function `NewAllPoliciesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*AllPoliciesClient, error)` +- New function `*AllPoliciesClient.NewListByServicePager(string, string, *AllPoliciesClientListByServiceOptions) *runtime.Pager[AllPoliciesClientListByServiceResponse]` +- New function `*ClientFactory.NewAPIGatewayClient() *APIGatewayClient` +- New function `*ClientFactory.NewAPIGatewayConfigConnectionClient() *APIGatewayConfigConnectionClient` +- New function `*ClientFactory.NewAllPoliciesClient() *AllPoliciesClient` +- New function `*ClientFactory.NewGatewaySKUsClient() *GatewaySKUsClient` +- New function `*ClientFactory.NewOperationStatusClient() *OperationStatusClient` +- New function `*ClientFactory.NewOperationsResultsClient() *OperationsResultsClient` +- New function `*ClientFactory.NewPolicyRestrictionClient() *PolicyRestrictionClient` +- New function `*ClientFactory.NewPolicyRestrictionValidationsClient() *PolicyRestrictionValidationsClient` +- New function `*ClientFactory.NewProductAPILinkClient() *ProductAPILinkClient` +- New function `*ClientFactory.NewProductGroupLinkClient() *ProductGroupLinkClient` +- New function `*ClientFactory.NewTagAPILinkClient() *TagAPILinkClient` +- New function `*ClientFactory.NewTagOperationLinkClient() *TagOperationLinkClient` +- New function `*ClientFactory.NewTagProductLinkClient() *TagProductLinkClient` +- New function `*ClientFactory.NewWorkspaceAPIClient() *WorkspaceAPIClient` +- New function `*ClientFactory.NewWorkspaceAPIDiagnosticClient() *WorkspaceAPIDiagnosticClient` +- New function `*ClientFactory.NewWorkspaceAPIExportClient() *WorkspaceAPIExportClient` +- New function `*ClientFactory.NewWorkspaceAPIOperationClient() *WorkspaceAPIOperationClient` +- New function `*ClientFactory.NewWorkspaceAPIOperationPolicyClient() *WorkspaceAPIOperationPolicyClient` +- New function `*ClientFactory.NewWorkspaceAPIPolicyClient() *WorkspaceAPIPolicyClient` +- New function `*ClientFactory.NewWorkspaceAPIReleaseClient() *WorkspaceAPIReleaseClient` +- New function `*ClientFactory.NewWorkspaceAPIRevisionClient() *WorkspaceAPIRevisionClient` +- New function `*ClientFactory.NewWorkspaceAPISchemaClient() *WorkspaceAPISchemaClient` +- New function `*ClientFactory.NewWorkspaceAPIVersionSetClient() *WorkspaceAPIVersionSetClient` +- New function `*ClientFactory.NewWorkspaceBackendClient() *WorkspaceBackendClient` +- New function `*ClientFactory.NewWorkspaceCertificateClient() *WorkspaceCertificateClient` +- New function `*ClientFactory.NewWorkspaceClient() *WorkspaceClient` +- New function `*ClientFactory.NewWorkspaceDiagnosticClient() *WorkspaceDiagnosticClient` +- New function `*ClientFactory.NewWorkspaceGlobalSchemaClient() *WorkspaceGlobalSchemaClient` +- New function `*ClientFactory.NewWorkspaceGroupClient() *WorkspaceGroupClient` +- New function `*ClientFactory.NewWorkspaceGroupUserClient() *WorkspaceGroupUserClient` +- New function `*ClientFactory.NewWorkspaceLinkClient() *WorkspaceLinkClient` +- New function `*ClientFactory.NewWorkspaceLinksClient() *WorkspaceLinksClient` +- New function `*ClientFactory.NewWorkspaceLoggerClient() *WorkspaceLoggerClient` +- New function `*ClientFactory.NewWorkspaceNamedValueClient() *WorkspaceNamedValueClient` +- New function `*ClientFactory.NewWorkspaceNotificationClient() *WorkspaceNotificationClient` +- New function `*ClientFactory.NewWorkspaceNotificationRecipientEmailClient() *WorkspaceNotificationRecipientEmailClient` +- New function `*ClientFactory.NewWorkspaceNotificationRecipientUserClient() *WorkspaceNotificationRecipientUserClient` +- New function `*ClientFactory.NewWorkspacePolicyClient() *WorkspacePolicyClient` +- New function `*ClientFactory.NewWorkspacePolicyFragmentClient() *WorkspacePolicyFragmentClient` +- New function `*ClientFactory.NewWorkspaceProductAPILinkClient() *WorkspaceProductAPILinkClient` +- New function `*ClientFactory.NewWorkspaceProductClient() *WorkspaceProductClient` +- New function `*ClientFactory.NewWorkspaceProductGroupLinkClient() *WorkspaceProductGroupLinkClient` +- New function `*ClientFactory.NewWorkspaceProductPolicyClient() *WorkspaceProductPolicyClient` +- New function `*ClientFactory.NewWorkspaceSubscriptionClient() *WorkspaceSubscriptionClient` +- New function `*ClientFactory.NewWorkspaceTagAPILinkClient() *WorkspaceTagAPILinkClient` +- New function `*ClientFactory.NewWorkspaceTagClient() *WorkspaceTagClient` +- New function `*ClientFactory.NewWorkspaceTagOperationLinkClient() *WorkspaceTagOperationLinkClient` +- New function `*ClientFactory.NewWorkspaceTagProductLinkClient() *WorkspaceTagProductLinkClient` +- New function `*GatewayClient.InvalidateDebugCredentials(context.Context, string, string, string, *GatewayClientInvalidateDebugCredentialsOptions) (GatewayClientInvalidateDebugCredentialsResponse, error)` +- New function `*GatewayClient.ListDebugCredentials(context.Context, string, string, string, GatewayListDebugCredentialsContract, *GatewayClientListDebugCredentialsOptions) (GatewayClientListDebugCredentialsResponse, error)` +- New function `*GatewayClient.ListTrace(context.Context, string, string, string, GatewayListTraceContract, *GatewayClientListTraceOptions) (GatewayClientListTraceResponse, error)` +- New function `NewGatewaySKUsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*GatewaySKUsClient, error)` +- New function `*GatewaySKUsClient.NewListAvailableSKUsPager(string, string, *GatewaySKUsClientListAvailableSKUsOptions) *runtime.Pager[GatewaySKUsClientListAvailableSKUsResponse]` +- New function `NewOperationStatusClient(string, azcore.TokenCredential, *arm.ClientOptions) (*OperationStatusClient, error)` +- New function `*OperationStatusClient.Get(context.Context, string, string, *OperationStatusClientGetOptions) (OperationStatusClientGetResponse, error)` +- New function `NewOperationsResultsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*OperationsResultsClient, error)` +- New function `*OperationsResultsClient.Get(context.Context, string, string, *OperationsResultsClientGetOptions) (OperationsResultsClientGetResponse, error)` +- New function `NewPolicyRestrictionClient(string, azcore.TokenCredential, *arm.ClientOptions) (*PolicyRestrictionClient, error)` +- New function `*PolicyRestrictionClient.CreateOrUpdate(context.Context, string, string, string, PolicyRestrictionContract, *PolicyRestrictionClientCreateOrUpdateOptions) (PolicyRestrictionClientCreateOrUpdateResponse, error)` +- New function `*PolicyRestrictionClient.Delete(context.Context, string, string, string, *PolicyRestrictionClientDeleteOptions) (PolicyRestrictionClientDeleteResponse, error)` +- New function `*PolicyRestrictionClient.Get(context.Context, string, string, string, *PolicyRestrictionClientGetOptions) (PolicyRestrictionClientGetResponse, error)` +- New function `*PolicyRestrictionClient.GetEntityTag(context.Context, string, string, string, *PolicyRestrictionClientGetEntityTagOptions) (PolicyRestrictionClientGetEntityTagResponse, error)` +- New function `*PolicyRestrictionClient.NewListByServicePager(string, string, *PolicyRestrictionClientListByServiceOptions) *runtime.Pager[PolicyRestrictionClientListByServiceResponse]` +- New function `*PolicyRestrictionClient.Update(context.Context, string, string, string, string, PolicyRestrictionUpdateContract, *PolicyRestrictionClientUpdateOptions) (PolicyRestrictionClientUpdateResponse, error)` +- New function `NewPolicyRestrictionValidationsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*PolicyRestrictionValidationsClient, error)` +- New function `*PolicyRestrictionValidationsClient.BeginByService(context.Context, string, string, *PolicyRestrictionValidationsClientBeginByServiceOptions) (*runtime.Poller[PolicyRestrictionValidationsClientByServiceResponse], error)` +- New function `NewProductAPILinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ProductAPILinkClient, error)` +- New function `*ProductAPILinkClient.CreateOrUpdate(context.Context, string, string, string, string, ProductAPILinkContract, *ProductAPILinkClientCreateOrUpdateOptions) (ProductAPILinkClientCreateOrUpdateResponse, error)` +- New function `*ProductAPILinkClient.Delete(context.Context, string, string, string, string, *ProductAPILinkClientDeleteOptions) (ProductAPILinkClientDeleteResponse, error)` +- New function `*ProductAPILinkClient.Get(context.Context, string, string, string, string, *ProductAPILinkClientGetOptions) (ProductAPILinkClientGetResponse, error)` +- New function `*ProductAPILinkClient.NewListByProductPager(string, string, string, *ProductAPILinkClientListByProductOptions) *runtime.Pager[ProductAPILinkClientListByProductResponse]` +- New function `NewProductGroupLinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ProductGroupLinkClient, error)` +- New function `*ProductGroupLinkClient.CreateOrUpdate(context.Context, string, string, string, string, ProductGroupLinkContract, *ProductGroupLinkClientCreateOrUpdateOptions) (ProductGroupLinkClientCreateOrUpdateResponse, error)` +- New function `*ProductGroupLinkClient.Delete(context.Context, string, string, string, string, *ProductGroupLinkClientDeleteOptions) (ProductGroupLinkClientDeleteResponse, error)` +- New function `*ProductGroupLinkClient.Get(context.Context, string, string, string, string, *ProductGroupLinkClientGetOptions) (ProductGroupLinkClientGetResponse, error)` +- New function `*ProductGroupLinkClient.NewListByProductPager(string, string, string, *ProductGroupLinkClientListByProductOptions) *runtime.Pager[ProductGroupLinkClientListByProductResponse]` +- New function `NewTagAPILinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*TagAPILinkClient, error)` +- New function `*TagAPILinkClient.CreateOrUpdate(context.Context, string, string, string, string, TagAPILinkContract, *TagAPILinkClientCreateOrUpdateOptions) (TagAPILinkClientCreateOrUpdateResponse, error)` +- New function `*TagAPILinkClient.Delete(context.Context, string, string, string, string, *TagAPILinkClientDeleteOptions) (TagAPILinkClientDeleteResponse, error)` +- New function `*TagAPILinkClient.Get(context.Context, string, string, string, string, *TagAPILinkClientGetOptions) (TagAPILinkClientGetResponse, error)` +- New function `*TagAPILinkClient.NewListByProductPager(string, string, string, *TagAPILinkClientListByProductOptions) *runtime.Pager[TagAPILinkClientListByProductResponse]` +- New function `NewTagOperationLinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*TagOperationLinkClient, error)` +- New function `*TagOperationLinkClient.CreateOrUpdate(context.Context, string, string, string, string, TagOperationLinkContract, *TagOperationLinkClientCreateOrUpdateOptions) (TagOperationLinkClientCreateOrUpdateResponse, error)` +- New function `*TagOperationLinkClient.Delete(context.Context, string, string, string, string, *TagOperationLinkClientDeleteOptions) (TagOperationLinkClientDeleteResponse, error)` +- New function `*TagOperationLinkClient.Get(context.Context, string, string, string, string, *TagOperationLinkClientGetOptions) (TagOperationLinkClientGetResponse, error)` +- New function `*TagOperationLinkClient.NewListByProductPager(string, string, string, *TagOperationLinkClientListByProductOptions) *runtime.Pager[TagOperationLinkClientListByProductResponse]` +- New function `NewTagProductLinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*TagProductLinkClient, error)` +- New function `*TagProductLinkClient.CreateOrUpdate(context.Context, string, string, string, string, TagProductLinkContract, *TagProductLinkClientCreateOrUpdateOptions) (TagProductLinkClientCreateOrUpdateResponse, error)` +- New function `*TagProductLinkClient.Delete(context.Context, string, string, string, string, *TagProductLinkClientDeleteOptions) (TagProductLinkClientDeleteResponse, error)` +- New function `*TagProductLinkClient.Get(context.Context, string, string, string, string, *TagProductLinkClientGetOptions) (TagProductLinkClientGetResponse, error)` +- New function `*TagProductLinkClient.NewListByProductPager(string, string, string, *TagProductLinkClientListByProductOptions) *runtime.Pager[TagProductLinkClientListByProductResponse]` +- New function `NewWorkspaceAPIClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPIClient, error)` +- New function `*WorkspaceAPIClient.BeginCreateOrUpdate(context.Context, string, string, string, string, APICreateOrUpdateParameter, *WorkspaceAPIClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspaceAPIClientCreateOrUpdateResponse], error)` +- New function `*WorkspaceAPIClient.Delete(context.Context, string, string, string, string, string, *WorkspaceAPIClientDeleteOptions) (WorkspaceAPIClientDeleteResponse, error)` +- New function `*WorkspaceAPIClient.Get(context.Context, string, string, string, string, *WorkspaceAPIClientGetOptions) (WorkspaceAPIClientGetResponse, error)` +- New function `*WorkspaceAPIClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceAPIClientGetEntityTagOptions) (WorkspaceAPIClientGetEntityTagResponse, error)` +- New function `*WorkspaceAPIClient.NewListByServicePager(string, string, string, *WorkspaceAPIClientListByServiceOptions) *runtime.Pager[WorkspaceAPIClientListByServiceResponse]` +- New function `*WorkspaceAPIClient.Update(context.Context, string, string, string, string, string, APIUpdateContract, *WorkspaceAPIClientUpdateOptions) (WorkspaceAPIClientUpdateResponse, error)` +- New function `NewWorkspaceAPIDiagnosticClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPIDiagnosticClient, error)` +- New function `*WorkspaceAPIDiagnosticClient.CreateOrUpdate(context.Context, string, string, string, string, string, DiagnosticContract, *WorkspaceAPIDiagnosticClientCreateOrUpdateOptions) (WorkspaceAPIDiagnosticClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceAPIDiagnosticClient.Delete(context.Context, string, string, string, string, string, string, *WorkspaceAPIDiagnosticClientDeleteOptions) (WorkspaceAPIDiagnosticClientDeleteResponse, error)` +- New function `*WorkspaceAPIDiagnosticClient.Get(context.Context, string, string, string, string, string, *WorkspaceAPIDiagnosticClientGetOptions) (WorkspaceAPIDiagnosticClientGetResponse, error)` +- New function `*WorkspaceAPIDiagnosticClient.GetEntityTag(context.Context, string, string, string, string, string, *WorkspaceAPIDiagnosticClientGetEntityTagOptions) (WorkspaceAPIDiagnosticClientGetEntityTagResponse, error)` +- New function `*WorkspaceAPIDiagnosticClient.NewListByWorkspacePager(string, string, string, string, *WorkspaceAPIDiagnosticClientListByWorkspaceOptions) *runtime.Pager[WorkspaceAPIDiagnosticClientListByWorkspaceResponse]` +- New function `*WorkspaceAPIDiagnosticClient.Update(context.Context, string, string, string, string, string, string, DiagnosticUpdateContract, *WorkspaceAPIDiagnosticClientUpdateOptions) (WorkspaceAPIDiagnosticClientUpdateResponse, error)` +- New function `NewWorkspaceAPIExportClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPIExportClient, error)` +- New function `*WorkspaceAPIExportClient.Get(context.Context, string, string, string, string, ExportFormat, ExportAPI, *WorkspaceAPIExportClientGetOptions) (WorkspaceAPIExportClientGetResponse, error)` +- New function `NewWorkspaceAPIOperationClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPIOperationClient, error)` +- New function `*WorkspaceAPIOperationClient.CreateOrUpdate(context.Context, string, string, string, string, string, OperationContract, *WorkspaceAPIOperationClientCreateOrUpdateOptions) (WorkspaceAPIOperationClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceAPIOperationClient.Delete(context.Context, string, string, string, string, string, string, *WorkspaceAPIOperationClientDeleteOptions) (WorkspaceAPIOperationClientDeleteResponse, error)` +- New function `*WorkspaceAPIOperationClient.Get(context.Context, string, string, string, string, string, *WorkspaceAPIOperationClientGetOptions) (WorkspaceAPIOperationClientGetResponse, error)` +- New function `*WorkspaceAPIOperationClient.GetEntityTag(context.Context, string, string, string, string, string, *WorkspaceAPIOperationClientGetEntityTagOptions) (WorkspaceAPIOperationClientGetEntityTagResponse, error)` +- New function `*WorkspaceAPIOperationClient.NewListByAPIPager(string, string, string, string, *WorkspaceAPIOperationClientListByAPIOptions) *runtime.Pager[WorkspaceAPIOperationClientListByAPIResponse]` +- New function `*WorkspaceAPIOperationClient.Update(context.Context, string, string, string, string, string, string, OperationUpdateContract, *WorkspaceAPIOperationClientUpdateOptions) (WorkspaceAPIOperationClientUpdateResponse, error)` +- New function `NewWorkspaceAPIOperationPolicyClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPIOperationPolicyClient, error)` +- New function `*WorkspaceAPIOperationPolicyClient.CreateOrUpdate(context.Context, string, string, string, string, string, PolicyIDName, PolicyContract, *WorkspaceAPIOperationPolicyClientCreateOrUpdateOptions) (WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceAPIOperationPolicyClient.Delete(context.Context, string, string, string, string, string, PolicyIDName, string, *WorkspaceAPIOperationPolicyClientDeleteOptions) (WorkspaceAPIOperationPolicyClientDeleteResponse, error)` +- New function `*WorkspaceAPIOperationPolicyClient.Get(context.Context, string, string, string, string, string, PolicyIDName, *WorkspaceAPIOperationPolicyClientGetOptions) (WorkspaceAPIOperationPolicyClientGetResponse, error)` +- New function `*WorkspaceAPIOperationPolicyClient.GetEntityTag(context.Context, string, string, string, string, string, PolicyIDName, *WorkspaceAPIOperationPolicyClientGetEntityTagOptions) (WorkspaceAPIOperationPolicyClientGetEntityTagResponse, error)` +- New function `*WorkspaceAPIOperationPolicyClient.NewListByOperationPager(string, string, string, string, string, *WorkspaceAPIOperationPolicyClientListByOperationOptions) *runtime.Pager[WorkspaceAPIOperationPolicyClientListByOperationResponse]` +- New function `NewWorkspaceAPIPolicyClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPIPolicyClient, error)` +- New function `*WorkspaceAPIPolicyClient.CreateOrUpdate(context.Context, string, string, string, string, PolicyIDName, PolicyContract, *WorkspaceAPIPolicyClientCreateOrUpdateOptions) (WorkspaceAPIPolicyClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceAPIPolicyClient.Delete(context.Context, string, string, string, string, PolicyIDName, string, *WorkspaceAPIPolicyClientDeleteOptions) (WorkspaceAPIPolicyClientDeleteResponse, error)` +- New function `*WorkspaceAPIPolicyClient.Get(context.Context, string, string, string, string, PolicyIDName, *WorkspaceAPIPolicyClientGetOptions) (WorkspaceAPIPolicyClientGetResponse, error)` +- New function `*WorkspaceAPIPolicyClient.GetEntityTag(context.Context, string, string, string, string, PolicyIDName, *WorkspaceAPIPolicyClientGetEntityTagOptions) (WorkspaceAPIPolicyClientGetEntityTagResponse, error)` +- New function `*WorkspaceAPIPolicyClient.NewListByAPIPager(string, string, string, string, *WorkspaceAPIPolicyClientListByAPIOptions) *runtime.Pager[WorkspaceAPIPolicyClientListByAPIResponse]` +- New function `NewWorkspaceAPIReleaseClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPIReleaseClient, error)` +- New function `*WorkspaceAPIReleaseClient.CreateOrUpdate(context.Context, string, string, string, string, string, APIReleaseContract, *WorkspaceAPIReleaseClientCreateOrUpdateOptions) (WorkspaceAPIReleaseClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceAPIReleaseClient.Delete(context.Context, string, string, string, string, string, string, *WorkspaceAPIReleaseClientDeleteOptions) (WorkspaceAPIReleaseClientDeleteResponse, error)` +- New function `*WorkspaceAPIReleaseClient.Get(context.Context, string, string, string, string, string, *WorkspaceAPIReleaseClientGetOptions) (WorkspaceAPIReleaseClientGetResponse, error)` +- New function `*WorkspaceAPIReleaseClient.GetEntityTag(context.Context, string, string, string, string, string, *WorkspaceAPIReleaseClientGetEntityTagOptions) (WorkspaceAPIReleaseClientGetEntityTagResponse, error)` +- New function `*WorkspaceAPIReleaseClient.NewListByServicePager(string, string, string, string, *WorkspaceAPIReleaseClientListByServiceOptions) *runtime.Pager[WorkspaceAPIReleaseClientListByServiceResponse]` +- New function `*WorkspaceAPIReleaseClient.Update(context.Context, string, string, string, string, string, string, APIReleaseContract, *WorkspaceAPIReleaseClientUpdateOptions) (WorkspaceAPIReleaseClientUpdateResponse, error)` +- New function `NewWorkspaceAPIRevisionClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPIRevisionClient, error)` +- New function `*WorkspaceAPIRevisionClient.NewListByServicePager(string, string, string, string, *WorkspaceAPIRevisionClientListByServiceOptions) *runtime.Pager[WorkspaceAPIRevisionClientListByServiceResponse]` +- New function `NewWorkspaceAPISchemaClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPISchemaClient, error)` +- New function `*WorkspaceAPISchemaClient.BeginCreateOrUpdate(context.Context, string, string, string, string, string, SchemaContract, *WorkspaceAPISchemaClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspaceAPISchemaClientCreateOrUpdateResponse], error)` +- New function `*WorkspaceAPISchemaClient.Delete(context.Context, string, string, string, string, string, string, *WorkspaceAPISchemaClientDeleteOptions) (WorkspaceAPISchemaClientDeleteResponse, error)` +- New function `*WorkspaceAPISchemaClient.Get(context.Context, string, string, string, string, string, *WorkspaceAPISchemaClientGetOptions) (WorkspaceAPISchemaClientGetResponse, error)` +- New function `*WorkspaceAPISchemaClient.GetEntityTag(context.Context, string, string, string, string, string, *WorkspaceAPISchemaClientGetEntityTagOptions) (WorkspaceAPISchemaClientGetEntityTagResponse, error)` +- New function `*WorkspaceAPISchemaClient.NewListByAPIPager(string, string, string, string, *WorkspaceAPISchemaClientListByAPIOptions) *runtime.Pager[WorkspaceAPISchemaClientListByAPIResponse]` +- New function `NewWorkspaceAPIVersionSetClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceAPIVersionSetClient, error)` +- New function `*WorkspaceAPIVersionSetClient.CreateOrUpdate(context.Context, string, string, string, string, APIVersionSetContract, *WorkspaceAPIVersionSetClientCreateOrUpdateOptions) (WorkspaceAPIVersionSetClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceAPIVersionSetClient.Delete(context.Context, string, string, string, string, string, *WorkspaceAPIVersionSetClientDeleteOptions) (WorkspaceAPIVersionSetClientDeleteResponse, error)` +- New function `*WorkspaceAPIVersionSetClient.Get(context.Context, string, string, string, string, *WorkspaceAPIVersionSetClientGetOptions) (WorkspaceAPIVersionSetClientGetResponse, error)` +- New function `*WorkspaceAPIVersionSetClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceAPIVersionSetClientGetEntityTagOptions) (WorkspaceAPIVersionSetClientGetEntityTagResponse, error)` +- New function `*WorkspaceAPIVersionSetClient.NewListByServicePager(string, string, string, *WorkspaceAPIVersionSetClientListByServiceOptions) *runtime.Pager[WorkspaceAPIVersionSetClientListByServiceResponse]` +- New function `*WorkspaceAPIVersionSetClient.Update(context.Context, string, string, string, string, string, APIVersionSetUpdateParameters, *WorkspaceAPIVersionSetClientUpdateOptions) (WorkspaceAPIVersionSetClientUpdateResponse, error)` +- New function `NewWorkspaceBackendClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceBackendClient, error)` +- New function `*WorkspaceBackendClient.CreateOrUpdate(context.Context, string, string, string, string, BackendContract, *WorkspaceBackendClientCreateOrUpdateOptions) (WorkspaceBackendClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceBackendClient.Delete(context.Context, string, string, string, string, string, *WorkspaceBackendClientDeleteOptions) (WorkspaceBackendClientDeleteResponse, error)` +- New function `*WorkspaceBackendClient.Get(context.Context, string, string, string, string, *WorkspaceBackendClientGetOptions) (WorkspaceBackendClientGetResponse, error)` +- New function `*WorkspaceBackendClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceBackendClientGetEntityTagOptions) (WorkspaceBackendClientGetEntityTagResponse, error)` +- New function `*WorkspaceBackendClient.NewListByWorkspacePager(string, string, string, *WorkspaceBackendClientListByWorkspaceOptions) *runtime.Pager[WorkspaceBackendClientListByWorkspaceResponse]` +- New function `*WorkspaceBackendClient.Update(context.Context, string, string, string, string, string, BackendUpdateParameters, *WorkspaceBackendClientUpdateOptions) (WorkspaceBackendClientUpdateResponse, error)` +- New function `NewWorkspaceCertificateClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceCertificateClient, error)` +- New function `*WorkspaceCertificateClient.CreateOrUpdate(context.Context, string, string, string, string, CertificateCreateOrUpdateParameters, *WorkspaceCertificateClientCreateOrUpdateOptions) (WorkspaceCertificateClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceCertificateClient.Delete(context.Context, string, string, string, string, string, *WorkspaceCertificateClientDeleteOptions) (WorkspaceCertificateClientDeleteResponse, error)` +- New function `*WorkspaceCertificateClient.Get(context.Context, string, string, string, string, *WorkspaceCertificateClientGetOptions) (WorkspaceCertificateClientGetResponse, error)` +- New function `*WorkspaceCertificateClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceCertificateClientGetEntityTagOptions) (WorkspaceCertificateClientGetEntityTagResponse, error)` +- New function `*WorkspaceCertificateClient.NewListByWorkspacePager(string, string, string, *WorkspaceCertificateClientListByWorkspaceOptions) *runtime.Pager[WorkspaceCertificateClientListByWorkspaceResponse]` +- New function `*WorkspaceCertificateClient.RefreshSecret(context.Context, string, string, string, string, *WorkspaceCertificateClientRefreshSecretOptions) (WorkspaceCertificateClientRefreshSecretResponse, error)` +- New function `NewWorkspaceClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceClient, error)` +- New function `*WorkspaceClient.CreateOrUpdate(context.Context, string, string, string, WorkspaceContract, *WorkspaceClientCreateOrUpdateOptions) (WorkspaceClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceClient.Delete(context.Context, string, string, string, string, *WorkspaceClientDeleteOptions) (WorkspaceClientDeleteResponse, error)` +- New function `*WorkspaceClient.Get(context.Context, string, string, string, *WorkspaceClientGetOptions) (WorkspaceClientGetResponse, error)` +- New function `*WorkspaceClient.GetEntityTag(context.Context, string, string, string, *WorkspaceClientGetEntityTagOptions) (WorkspaceClientGetEntityTagResponse, error)` +- New function `*WorkspaceClient.NewListByServicePager(string, string, *WorkspaceClientListByServiceOptions) *runtime.Pager[WorkspaceClientListByServiceResponse]` +- New function `*WorkspaceClient.Update(context.Context, string, string, string, string, WorkspaceContract, *WorkspaceClientUpdateOptions) (WorkspaceClientUpdateResponse, error)` +- New function `NewWorkspaceDiagnosticClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceDiagnosticClient, error)` +- New function `*WorkspaceDiagnosticClient.CreateOrUpdate(context.Context, string, string, string, string, DiagnosticContract, *WorkspaceDiagnosticClientCreateOrUpdateOptions) (WorkspaceDiagnosticClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceDiagnosticClient.Delete(context.Context, string, string, string, string, string, *WorkspaceDiagnosticClientDeleteOptions) (WorkspaceDiagnosticClientDeleteResponse, error)` +- New function `*WorkspaceDiagnosticClient.Get(context.Context, string, string, string, string, *WorkspaceDiagnosticClientGetOptions) (WorkspaceDiagnosticClientGetResponse, error)` +- New function `*WorkspaceDiagnosticClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceDiagnosticClientGetEntityTagOptions) (WorkspaceDiagnosticClientGetEntityTagResponse, error)` +- New function `*WorkspaceDiagnosticClient.NewListByWorkspacePager(string, string, string, *WorkspaceDiagnosticClientListByWorkspaceOptions) *runtime.Pager[WorkspaceDiagnosticClientListByWorkspaceResponse]` +- New function `*WorkspaceDiagnosticClient.Update(context.Context, string, string, string, string, string, DiagnosticUpdateContract, *WorkspaceDiagnosticClientUpdateOptions) (WorkspaceDiagnosticClientUpdateResponse, error)` +- New function `NewWorkspaceGlobalSchemaClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceGlobalSchemaClient, error)` +- New function `*WorkspaceGlobalSchemaClient.BeginCreateOrUpdate(context.Context, string, string, string, string, GlobalSchemaContract, *WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspaceGlobalSchemaClientCreateOrUpdateResponse], error)` +- New function `*WorkspaceGlobalSchemaClient.Delete(context.Context, string, string, string, string, string, *WorkspaceGlobalSchemaClientDeleteOptions) (WorkspaceGlobalSchemaClientDeleteResponse, error)` +- New function `*WorkspaceGlobalSchemaClient.Get(context.Context, string, string, string, string, *WorkspaceGlobalSchemaClientGetOptions) (WorkspaceGlobalSchemaClientGetResponse, error)` +- New function `*WorkspaceGlobalSchemaClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceGlobalSchemaClientGetEntityTagOptions) (WorkspaceGlobalSchemaClientGetEntityTagResponse, error)` +- New function `*WorkspaceGlobalSchemaClient.NewListByServicePager(string, string, string, *WorkspaceGlobalSchemaClientListByServiceOptions) *runtime.Pager[WorkspaceGlobalSchemaClientListByServiceResponse]` +- New function `NewWorkspaceGroupClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceGroupClient, error)` +- New function `*WorkspaceGroupClient.CreateOrUpdate(context.Context, string, string, string, string, GroupCreateParameters, *WorkspaceGroupClientCreateOrUpdateOptions) (WorkspaceGroupClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceGroupClient.Delete(context.Context, string, string, string, string, string, *WorkspaceGroupClientDeleteOptions) (WorkspaceGroupClientDeleteResponse, error)` +- New function `*WorkspaceGroupClient.Get(context.Context, string, string, string, string, *WorkspaceGroupClientGetOptions) (WorkspaceGroupClientGetResponse, error)` +- New function `*WorkspaceGroupClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceGroupClientGetEntityTagOptions) (WorkspaceGroupClientGetEntityTagResponse, error)` +- New function `*WorkspaceGroupClient.NewListByServicePager(string, string, string, *WorkspaceGroupClientListByServiceOptions) *runtime.Pager[WorkspaceGroupClientListByServiceResponse]` +- New function `*WorkspaceGroupClient.Update(context.Context, string, string, string, string, string, GroupUpdateParameters, *WorkspaceGroupClientUpdateOptions) (WorkspaceGroupClientUpdateResponse, error)` +- New function `NewWorkspaceGroupUserClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceGroupUserClient, error)` +- New function `*WorkspaceGroupUserClient.CheckEntityExists(context.Context, string, string, string, string, string, *WorkspaceGroupUserClientCheckEntityExistsOptions) (WorkspaceGroupUserClientCheckEntityExistsResponse, error)` +- New function `*WorkspaceGroupUserClient.Create(context.Context, string, string, string, string, string, *WorkspaceGroupUserClientCreateOptions) (WorkspaceGroupUserClientCreateResponse, error)` +- New function `*WorkspaceGroupUserClient.Delete(context.Context, string, string, string, string, string, *WorkspaceGroupUserClientDeleteOptions) (WorkspaceGroupUserClientDeleteResponse, error)` +- New function `*WorkspaceGroupUserClient.NewListPager(string, string, string, string, *WorkspaceGroupUserClientListOptions) *runtime.Pager[WorkspaceGroupUserClientListResponse]` +- New function `NewWorkspaceLinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceLinkClient, error)` +- New function `*WorkspaceLinkClient.Get(context.Context, string, string, string, *WorkspaceLinkClientGetOptions) (WorkspaceLinkClientGetResponse, error)` +- New function `NewWorkspaceLinksClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceLinksClient, error)` +- New function `*WorkspaceLinksClient.NewListByServicePager(string, string, *WorkspaceLinksClientListByServiceOptions) *runtime.Pager[WorkspaceLinksClientListByServiceResponse]` +- New function `NewWorkspaceLoggerClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceLoggerClient, error)` +- New function `*WorkspaceLoggerClient.CreateOrUpdate(context.Context, string, string, string, string, LoggerContract, *WorkspaceLoggerClientCreateOrUpdateOptions) (WorkspaceLoggerClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceLoggerClient.Delete(context.Context, string, string, string, string, string, *WorkspaceLoggerClientDeleteOptions) (WorkspaceLoggerClientDeleteResponse, error)` +- New function `*WorkspaceLoggerClient.Get(context.Context, string, string, string, string, *WorkspaceLoggerClientGetOptions) (WorkspaceLoggerClientGetResponse, error)` +- New function `*WorkspaceLoggerClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceLoggerClientGetEntityTagOptions) (WorkspaceLoggerClientGetEntityTagResponse, error)` +- New function `*WorkspaceLoggerClient.NewListByWorkspacePager(string, string, string, *WorkspaceLoggerClientListByWorkspaceOptions) *runtime.Pager[WorkspaceLoggerClientListByWorkspaceResponse]` +- New function `*WorkspaceLoggerClient.Update(context.Context, string, string, string, string, string, LoggerUpdateContract, *WorkspaceLoggerClientUpdateOptions) (WorkspaceLoggerClientUpdateResponse, error)` +- New function `NewWorkspaceNamedValueClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceNamedValueClient, error)` +- New function `*WorkspaceNamedValueClient.BeginCreateOrUpdate(context.Context, string, string, string, string, NamedValueCreateContract, *WorkspaceNamedValueClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspaceNamedValueClientCreateOrUpdateResponse], error)` +- New function `*WorkspaceNamedValueClient.Delete(context.Context, string, string, string, string, string, *WorkspaceNamedValueClientDeleteOptions) (WorkspaceNamedValueClientDeleteResponse, error)` +- New function `*WorkspaceNamedValueClient.Get(context.Context, string, string, string, string, *WorkspaceNamedValueClientGetOptions) (WorkspaceNamedValueClientGetResponse, error)` +- New function `*WorkspaceNamedValueClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceNamedValueClientGetEntityTagOptions) (WorkspaceNamedValueClientGetEntityTagResponse, error)` +- New function `*WorkspaceNamedValueClient.NewListByServicePager(string, string, string, *WorkspaceNamedValueClientListByServiceOptions) *runtime.Pager[WorkspaceNamedValueClientListByServiceResponse]` +- New function `*WorkspaceNamedValueClient.ListValue(context.Context, string, string, string, string, *WorkspaceNamedValueClientListValueOptions) (WorkspaceNamedValueClientListValueResponse, error)` +- New function `*WorkspaceNamedValueClient.BeginRefreshSecret(context.Context, string, string, string, string, *WorkspaceNamedValueClientBeginRefreshSecretOptions) (*runtime.Poller[WorkspaceNamedValueClientRefreshSecretResponse], error)` +- New function `*WorkspaceNamedValueClient.BeginUpdate(context.Context, string, string, string, string, string, NamedValueUpdateParameters, *WorkspaceNamedValueClientBeginUpdateOptions) (*runtime.Poller[WorkspaceNamedValueClientUpdateResponse], error)` +- New function `NewWorkspaceNotificationClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceNotificationClient, error)` +- New function `*WorkspaceNotificationClient.CreateOrUpdate(context.Context, string, string, string, NotificationName, *WorkspaceNotificationClientCreateOrUpdateOptions) (WorkspaceNotificationClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceNotificationClient.Get(context.Context, string, string, string, NotificationName, *WorkspaceNotificationClientGetOptions) (WorkspaceNotificationClientGetResponse, error)` +- New function `*WorkspaceNotificationClient.NewListByServicePager(string, string, string, *WorkspaceNotificationClientListByServiceOptions) *runtime.Pager[WorkspaceNotificationClientListByServiceResponse]` +- New function `NewWorkspaceNotificationRecipientEmailClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceNotificationRecipientEmailClient, error)` +- New function `*WorkspaceNotificationRecipientEmailClient.CheckEntityExists(context.Context, string, string, string, NotificationName, string, *WorkspaceNotificationRecipientEmailClientCheckEntityExistsOptions) (WorkspaceNotificationRecipientEmailClientCheckEntityExistsResponse, error)` +- New function `*WorkspaceNotificationRecipientEmailClient.CreateOrUpdate(context.Context, string, string, string, NotificationName, string, *WorkspaceNotificationRecipientEmailClientCreateOrUpdateOptions) (WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceNotificationRecipientEmailClient.Delete(context.Context, string, string, string, NotificationName, string, *WorkspaceNotificationRecipientEmailClientDeleteOptions) (WorkspaceNotificationRecipientEmailClientDeleteResponse, error)` +- New function `*WorkspaceNotificationRecipientEmailClient.ListByNotification(context.Context, string, string, string, NotificationName, *WorkspaceNotificationRecipientEmailClientListByNotificationOptions) (WorkspaceNotificationRecipientEmailClientListByNotificationResponse, error)` +- New function `NewWorkspaceNotificationRecipientUserClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceNotificationRecipientUserClient, error)` +- New function `*WorkspaceNotificationRecipientUserClient.CheckEntityExists(context.Context, string, string, string, NotificationName, string, *WorkspaceNotificationRecipientUserClientCheckEntityExistsOptions) (WorkspaceNotificationRecipientUserClientCheckEntityExistsResponse, error)` +- New function `*WorkspaceNotificationRecipientUserClient.CreateOrUpdate(context.Context, string, string, string, NotificationName, string, *WorkspaceNotificationRecipientUserClientCreateOrUpdateOptions) (WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceNotificationRecipientUserClient.Delete(context.Context, string, string, string, NotificationName, string, *WorkspaceNotificationRecipientUserClientDeleteOptions) (WorkspaceNotificationRecipientUserClientDeleteResponse, error)` +- New function `*WorkspaceNotificationRecipientUserClient.ListByNotification(context.Context, string, string, string, NotificationName, *WorkspaceNotificationRecipientUserClientListByNotificationOptions) (WorkspaceNotificationRecipientUserClientListByNotificationResponse, error)` +- New function `NewWorkspacePolicyClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspacePolicyClient, error)` +- New function `*WorkspacePolicyClient.CreateOrUpdate(context.Context, string, string, string, PolicyIDName, PolicyContract, *WorkspacePolicyClientCreateOrUpdateOptions) (WorkspacePolicyClientCreateOrUpdateResponse, error)` +- New function `*WorkspacePolicyClient.Delete(context.Context, string, string, string, PolicyIDName, string, *WorkspacePolicyClientDeleteOptions) (WorkspacePolicyClientDeleteResponse, error)` +- New function `*WorkspacePolicyClient.Get(context.Context, string, string, string, PolicyIDName, *WorkspacePolicyClientGetOptions) (WorkspacePolicyClientGetResponse, error)` +- New function `*WorkspacePolicyClient.GetEntityTag(context.Context, string, string, string, PolicyIDName, *WorkspacePolicyClientGetEntityTagOptions) (WorkspacePolicyClientGetEntityTagResponse, error)` +- New function `*WorkspacePolicyClient.NewListByAPIPager(string, string, string, *WorkspacePolicyClientListByAPIOptions) *runtime.Pager[WorkspacePolicyClientListByAPIResponse]` +- New function `NewWorkspacePolicyFragmentClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspacePolicyFragmentClient, error)` +- New function `*WorkspacePolicyFragmentClient.BeginCreateOrUpdate(context.Context, string, string, string, string, PolicyFragmentContract, *WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspacePolicyFragmentClientCreateOrUpdateResponse], error)` +- New function `*WorkspacePolicyFragmentClient.Delete(context.Context, string, string, string, string, string, *WorkspacePolicyFragmentClientDeleteOptions) (WorkspacePolicyFragmentClientDeleteResponse, error)` +- New function `*WorkspacePolicyFragmentClient.Get(context.Context, string, string, string, string, *WorkspacePolicyFragmentClientGetOptions) (WorkspacePolicyFragmentClientGetResponse, error)` +- New function `*WorkspacePolicyFragmentClient.GetEntityTag(context.Context, string, string, string, string, *WorkspacePolicyFragmentClientGetEntityTagOptions) (WorkspacePolicyFragmentClientGetEntityTagResponse, error)` +- New function `*WorkspacePolicyFragmentClient.NewListByServicePager(string, string, string, *WorkspacePolicyFragmentClientListByServiceOptions) *runtime.Pager[WorkspacePolicyFragmentClientListByServiceResponse]` +- New function `*WorkspacePolicyFragmentClient.ListReferences(context.Context, string, string, string, string, *WorkspacePolicyFragmentClientListReferencesOptions) (WorkspacePolicyFragmentClientListReferencesResponse, error)` +- New function `NewWorkspaceProductAPILinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceProductAPILinkClient, error)` +- New function `*WorkspaceProductAPILinkClient.CreateOrUpdate(context.Context, string, string, string, string, string, ProductAPILinkContract, *WorkspaceProductAPILinkClientCreateOrUpdateOptions) (WorkspaceProductAPILinkClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceProductAPILinkClient.Delete(context.Context, string, string, string, string, string, *WorkspaceProductAPILinkClientDeleteOptions) (WorkspaceProductAPILinkClientDeleteResponse, error)` +- New function `*WorkspaceProductAPILinkClient.Get(context.Context, string, string, string, string, string, *WorkspaceProductAPILinkClientGetOptions) (WorkspaceProductAPILinkClientGetResponse, error)` +- New function `*WorkspaceProductAPILinkClient.NewListByProductPager(string, string, string, string, *WorkspaceProductAPILinkClientListByProductOptions) *runtime.Pager[WorkspaceProductAPILinkClientListByProductResponse]` +- New function `NewWorkspaceProductClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceProductClient, error)` +- New function `*WorkspaceProductClient.CreateOrUpdate(context.Context, string, string, string, string, ProductContract, *WorkspaceProductClientCreateOrUpdateOptions) (WorkspaceProductClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceProductClient.Delete(context.Context, string, string, string, string, string, *WorkspaceProductClientDeleteOptions) (WorkspaceProductClientDeleteResponse, error)` +- New function `*WorkspaceProductClient.Get(context.Context, string, string, string, string, *WorkspaceProductClientGetOptions) (WorkspaceProductClientGetResponse, error)` +- New function `*WorkspaceProductClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceProductClientGetEntityTagOptions) (WorkspaceProductClientGetEntityTagResponse, error)` +- New function `*WorkspaceProductClient.NewListByServicePager(string, string, string, *WorkspaceProductClientListByServiceOptions) *runtime.Pager[WorkspaceProductClientListByServiceResponse]` +- New function `*WorkspaceProductClient.Update(context.Context, string, string, string, string, string, ProductUpdateParameters, *WorkspaceProductClientUpdateOptions) (WorkspaceProductClientUpdateResponse, error)` +- New function `NewWorkspaceProductGroupLinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceProductGroupLinkClient, error)` +- New function `*WorkspaceProductGroupLinkClient.CreateOrUpdate(context.Context, string, string, string, string, string, ProductGroupLinkContract, *WorkspaceProductGroupLinkClientCreateOrUpdateOptions) (WorkspaceProductGroupLinkClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceProductGroupLinkClient.Delete(context.Context, string, string, string, string, string, *WorkspaceProductGroupLinkClientDeleteOptions) (WorkspaceProductGroupLinkClientDeleteResponse, error)` +- New function `*WorkspaceProductGroupLinkClient.Get(context.Context, string, string, string, string, string, *WorkspaceProductGroupLinkClientGetOptions) (WorkspaceProductGroupLinkClientGetResponse, error)` +- New function `*WorkspaceProductGroupLinkClient.NewListByProductPager(string, string, string, string, *WorkspaceProductGroupLinkClientListByProductOptions) *runtime.Pager[WorkspaceProductGroupLinkClientListByProductResponse]` +- New function `NewWorkspaceProductPolicyClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceProductPolicyClient, error)` +- New function `*WorkspaceProductPolicyClient.CreateOrUpdate(context.Context, string, string, string, string, PolicyIDName, PolicyContract, *WorkspaceProductPolicyClientCreateOrUpdateOptions) (WorkspaceProductPolicyClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceProductPolicyClient.Delete(context.Context, string, string, string, string, PolicyIDName, string, *WorkspaceProductPolicyClientDeleteOptions) (WorkspaceProductPolicyClientDeleteResponse, error)` +- New function `*WorkspaceProductPolicyClient.Get(context.Context, string, string, string, string, PolicyIDName, *WorkspaceProductPolicyClientGetOptions) (WorkspaceProductPolicyClientGetResponse, error)` +- New function `*WorkspaceProductPolicyClient.GetEntityTag(context.Context, string, string, string, string, PolicyIDName, *WorkspaceProductPolicyClientGetEntityTagOptions) (WorkspaceProductPolicyClientGetEntityTagResponse, error)` +- New function `*WorkspaceProductPolicyClient.ListByProduct(context.Context, string, string, string, string, *WorkspaceProductPolicyClientListByProductOptions) (WorkspaceProductPolicyClientListByProductResponse, error)` +- New function `NewWorkspaceSubscriptionClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceSubscriptionClient, error)` +- New function `*WorkspaceSubscriptionClient.CreateOrUpdate(context.Context, string, string, string, string, SubscriptionCreateParameters, *WorkspaceSubscriptionClientCreateOrUpdateOptions) (WorkspaceSubscriptionClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceSubscriptionClient.Delete(context.Context, string, string, string, string, string, *WorkspaceSubscriptionClientDeleteOptions) (WorkspaceSubscriptionClientDeleteResponse, error)` +- New function `*WorkspaceSubscriptionClient.Get(context.Context, string, string, string, string, *WorkspaceSubscriptionClientGetOptions) (WorkspaceSubscriptionClientGetResponse, error)` +- New function `*WorkspaceSubscriptionClient.GetEntityTag(context.Context, string, string, string, string, *WorkspaceSubscriptionClientGetEntityTagOptions) (WorkspaceSubscriptionClientGetEntityTagResponse, error)` +- New function `*WorkspaceSubscriptionClient.NewListPager(string, string, string, *WorkspaceSubscriptionClientListOptions) *runtime.Pager[WorkspaceSubscriptionClientListResponse]` +- New function `*WorkspaceSubscriptionClient.ListSecrets(context.Context, string, string, string, string, *WorkspaceSubscriptionClientListSecretsOptions) (WorkspaceSubscriptionClientListSecretsResponse, error)` +- New function `*WorkspaceSubscriptionClient.RegeneratePrimaryKey(context.Context, string, string, string, string, *WorkspaceSubscriptionClientRegeneratePrimaryKeyOptions) (WorkspaceSubscriptionClientRegeneratePrimaryKeyResponse, error)` +- New function `*WorkspaceSubscriptionClient.RegenerateSecondaryKey(context.Context, string, string, string, string, *WorkspaceSubscriptionClientRegenerateSecondaryKeyOptions) (WorkspaceSubscriptionClientRegenerateSecondaryKeyResponse, error)` +- New function `*WorkspaceSubscriptionClient.Update(context.Context, string, string, string, string, string, SubscriptionUpdateParameters, *WorkspaceSubscriptionClientUpdateOptions) (WorkspaceSubscriptionClientUpdateResponse, error)` +- New function `NewWorkspaceTagAPILinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceTagAPILinkClient, error)` +- New function `*WorkspaceTagAPILinkClient.CreateOrUpdate(context.Context, string, string, string, string, string, TagAPILinkContract, *WorkspaceTagAPILinkClientCreateOrUpdateOptions) (WorkspaceTagAPILinkClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceTagAPILinkClient.Delete(context.Context, string, string, string, string, string, *WorkspaceTagAPILinkClientDeleteOptions) (WorkspaceTagAPILinkClientDeleteResponse, error)` +- New function `*WorkspaceTagAPILinkClient.Get(context.Context, string, string, string, string, string, *WorkspaceTagAPILinkClientGetOptions) (WorkspaceTagAPILinkClientGetResponse, error)` +- New function `*WorkspaceTagAPILinkClient.NewListByProductPager(string, string, string, string, *WorkspaceTagAPILinkClientListByProductOptions) *runtime.Pager[WorkspaceTagAPILinkClientListByProductResponse]` +- New function `NewWorkspaceTagClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceTagClient, error)` +- New function `*WorkspaceTagClient.CreateOrUpdate(context.Context, string, string, string, string, TagCreateUpdateParameters, *WorkspaceTagClientCreateOrUpdateOptions) (WorkspaceTagClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceTagClient.Delete(context.Context, string, string, string, string, string, *WorkspaceTagClientDeleteOptions) (WorkspaceTagClientDeleteResponse, error)` +- New function `*WorkspaceTagClient.Get(context.Context, string, string, string, string, *WorkspaceTagClientGetOptions) (WorkspaceTagClientGetResponse, error)` +- New function `*WorkspaceTagClient.GetEntityState(context.Context, string, string, string, string, *WorkspaceTagClientGetEntityStateOptions) (WorkspaceTagClientGetEntityStateResponse, error)` +- New function `*WorkspaceTagClient.NewListByServicePager(string, string, string, *WorkspaceTagClientListByServiceOptions) *runtime.Pager[WorkspaceTagClientListByServiceResponse]` +- New function `*WorkspaceTagClient.Update(context.Context, string, string, string, string, string, TagCreateUpdateParameters, *WorkspaceTagClientUpdateOptions) (WorkspaceTagClientUpdateResponse, error)` +- New function `NewWorkspaceTagOperationLinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceTagOperationLinkClient, error)` +- New function `*WorkspaceTagOperationLinkClient.CreateOrUpdate(context.Context, string, string, string, string, string, TagOperationLinkContract, *WorkspaceTagOperationLinkClientCreateOrUpdateOptions) (WorkspaceTagOperationLinkClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceTagOperationLinkClient.Delete(context.Context, string, string, string, string, string, *WorkspaceTagOperationLinkClientDeleteOptions) (WorkspaceTagOperationLinkClientDeleteResponse, error)` +- New function `*WorkspaceTagOperationLinkClient.Get(context.Context, string, string, string, string, string, *WorkspaceTagOperationLinkClientGetOptions) (WorkspaceTagOperationLinkClientGetResponse, error)` +- New function `*WorkspaceTagOperationLinkClient.NewListByProductPager(string, string, string, string, *WorkspaceTagOperationLinkClientListByProductOptions) *runtime.Pager[WorkspaceTagOperationLinkClientListByProductResponse]` +- New function `NewWorkspaceTagProductLinkClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspaceTagProductLinkClient, error)` +- New function `*WorkspaceTagProductLinkClient.CreateOrUpdate(context.Context, string, string, string, string, string, TagProductLinkContract, *WorkspaceTagProductLinkClientCreateOrUpdateOptions) (WorkspaceTagProductLinkClientCreateOrUpdateResponse, error)` +- New function `*WorkspaceTagProductLinkClient.Delete(context.Context, string, string, string, string, string, *WorkspaceTagProductLinkClientDeleteOptions) (WorkspaceTagProductLinkClientDeleteResponse, error)` +- New function `*WorkspaceTagProductLinkClient.Get(context.Context, string, string, string, string, string, *WorkspaceTagProductLinkClientGetOptions) (WorkspaceTagProductLinkClientGetResponse, error)` +- New function `*WorkspaceTagProductLinkClient.NewListByProductPager(string, string, string, string, *WorkspaceTagProductLinkClientListByProductOptions) *runtime.Pager[WorkspaceTagProductLinkClientListByProductResponse]` +- New struct `AllPoliciesCollection` +- New struct `AllPoliciesContract` +- New struct `AllPoliciesContractProperties` +- New struct `BackendBaseParametersPool` +- New struct `BackendCircuitBreaker` +- New struct `BackendConfiguration` +- New struct `BackendPool` +- New struct `BackendPoolItem` +- New struct `BackendSubnetConfiguration` +- New struct `CircuitBreakerFailureCondition` +- New struct `CircuitBreakerRule` +- New struct `ConfigurationAPI` +- New struct `DiagnosticContractUpdateProperties` +- New struct `DiagnosticUpdateContract` +- New struct `ErrorAdditionalInfo` +- New struct `ErrorDetail` +- New struct `FailureStatusCodeRange` +- New struct `FrontendConfiguration` +- New struct `GatewayBaseProperties` +- New struct `GatewayConfigConnectionBaseProperties` +- New struct `GatewayConfigConnectionListResult` +- New struct `GatewayConfigConnectionResource` +- New struct `GatewayConfigurationAPI` +- New struct `GatewayDebugCredentialsContract` +- New struct `GatewayListDebugCredentialsContract` +- New struct `GatewayListResult` +- New struct `GatewayListTraceContract` +- New struct `GatewayProperties` +- New struct `GatewayResource` +- New struct `GatewayResourceSKUResult` +- New struct `GatewayResourceSKUResults` +- New struct `GatewaySKU` +- New struct `GatewaySKUCapacity` +- New struct `GatewaySKUProperties` +- New struct `GatewaySKUPropertiesForPatch` +- New struct `GatewayUpdateParameters` +- New struct `GatewayUpdateProperties` +- New struct `MigrateToStv2Contract` +- New struct `OperationStatusResult` +- New struct `PolicyRestrictionCollection` +- New struct `PolicyRestrictionContract` +- New struct `PolicyRestrictionContractProperties` +- New struct `PolicyRestrictionUpdateContract` +- New struct `PolicyWithComplianceCollection` +- New struct `PolicyWithComplianceContract` +- New struct `PolicyWithComplianceContractProperties` +- New struct `ProductAPILinkCollection` +- New struct `ProductAPILinkContract` +- New struct `ProductAPILinkContractProperties` +- New struct `ProductGroupLinkCollection` +- New struct `ProductGroupLinkContract` +- New struct `ProductGroupLinkContractProperties` +- New struct `TagAPILinkCollection` +- New struct `TagAPILinkContract` +- New struct `TagAPILinkContractProperties` +- New struct `TagOperationLinkCollection` +- New struct `TagOperationLinkContract` +- New struct `TagOperationLinkContractProperties` +- New struct `TagProductLinkCollection` +- New struct `TagProductLinkContract` +- New struct `TagProductLinkContractProperties` +- New struct `WorkspaceCollection` +- New struct `WorkspaceContract` +- New struct `WorkspaceContractProperties` +- New struct `WorkspaceLinksBaseProperties` +- New struct `WorkspaceLinksGateway` +- New struct `WorkspaceLinksListResult` +- New struct `WorkspaceLinksProperties` +- New struct `WorkspaceLinksResource` +- New field `ProvisioningState` in struct `APIContractProperties` +- New field `ProvisioningState` in struct `APICreateOrUpdateProperties` +- New field `AppIDs` in struct `AuthorizationAccessPolicyContractProperties` +- New field `CircuitBreaker`, `Pool`, `Type` in struct `BackendBaseParameters` +- New field `CircuitBreaker`, `Pool`, `Type` in struct `BackendContractProperties` +- New field `CircuitBreaker`, `Pool`, `Type` in struct `BackendUpdateParameterProperties` +- New field `ProvisioningState` in struct `GlobalSchemaContractProperties` +- New field `ProvisioningState` in struct `NamedValueContractProperties` +- New field `ProvisioningState` in struct `PolicyFragmentContractProperties` +- New field `ProvisioningState` in struct `PortalRevisionContractProperties` +- New field `ProvisioningState` in struct `SchemaContractProperties` +- New field `ConfigurationAPI`, `DeveloperPortalStatus`, `LegacyPortalStatus` in struct `ServiceBaseProperties` +- New field `Parameters` in struct `ServiceClientBeginMigrateToStv2Options` +- New field `ConfigurationAPI`, `DeveloperPortalStatus`, `LegacyPortalStatus` in struct `ServiceProperties` +- New field `ConfigurationAPI`, `DeveloperPortalStatus`, `LegacyPortalStatus` in struct `ServiceUpdateProperties` + + ## 2.1.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/README.md b/sdk/resourcemanager/apimanagement/armapimanagement/README.md index 20fc94584560..f1bcb25f1f15 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/README.md +++ b/sdk/resourcemanager/apimanagement/armapimanagement/README.md @@ -18,7 +18,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure API Management module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2 +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3 ``` ## Authorization @@ -55,7 +55,7 @@ clientFactory, err := armapimanagement.NewClientFactory(, cred, A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewServiceClient() +client := clientFactory.NewAPIClient() ``` ## Fakes diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/allpolicies_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/allpolicies_client.go new file mode 100644 index 000000000000..106e53b81555 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/allpolicies_client.go @@ -0,0 +1,106 @@ +// 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 armapimanagement + +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" +) + +// AllPoliciesClient contains the methods for the AllPolicies group. +// Don't use this type directly, use NewAllPoliciesClient() instead. +type AllPoliciesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAllPoliciesClient creates a new instance of AllPoliciesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAllPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AllPoliciesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AllPoliciesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListByServicePager - Status of all policies of API Management services. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - options - AllPoliciesClientListByServiceOptions contains the optional parameters for the AllPoliciesClient.NewListByServicePager +// method. +func (client *AllPoliciesClient) NewListByServicePager(resourceGroupName string, serviceName string, options *AllPoliciesClientListByServiceOptions) *runtime.Pager[AllPoliciesClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[AllPoliciesClientListByServiceResponse]{ + More: func(page AllPoliciesClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AllPoliciesClientListByServiceResponse) (AllPoliciesClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AllPoliciesClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, nil) + if err != nil { + return AllPoliciesClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *AllPoliciesClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *AllPoliciesClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/allPolicies" + 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.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *AllPoliciesClient) listByServiceHandleResponse(resp *http.Response) (AllPoliciesClientListByServiceResponse, error) { + result := AllPoliciesClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AllPoliciesCollection); err != nil { + return AllPoliciesClientListByServiceResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/api_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/api_client.go index 8984de009d6d..2be9dc8cc017 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/api_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/api_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIClient struct { } // NewAPIClient creates a new instance of APIClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIClient, error) { @@ -47,7 +44,7 @@ func NewAPIClient(subscriptionID string, credential azcore.TokenCredential, opti // BeginCreateOrUpdate - Creates new or updates existing specified API of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -75,7 +72,7 @@ func (client *APIClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupN // CreateOrUpdate - Creates new or updates existing specified API of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *APIClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, parameters APICreateOrUpdateParameter, options *APIClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "APIClient.BeginCreateOrUpdate" @@ -90,7 +87,7 @@ func (client *APIClient) createOrUpdate(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -121,52 +118,74 @@ func (client *APIClient) createOrUpdateCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } return req, nil } -// Delete - Deletes the specified API of the API Management service instance. +// BeginDelete - Deletes the specified API of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has // ;rev=n as a suffix where n is the revision number. // - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or // it should be * for unconditional update. -// - options - APIClientDeleteOptions contains the optional parameters for the APIClient.Delete method. -func (client *APIClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *APIClientDeleteOptions) (APIClientDeleteResponse, error) { +// - options - APIClientBeginDeleteOptions contains the optional parameters for the APIClient.BeginDelete method. +func (client *APIClient) BeginDelete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *APIClientBeginDeleteOptions) (*runtime.Poller[APIClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, serviceName, apiID, ifMatch, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[APIClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[APIClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes the specified API of the API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *APIClient) deleteOperation(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *APIClientBeginDeleteOptions) (*http.Response, error) { var err error - const operationName = "APIClient.Delete" + const operationName = "APIClient.BeginDelete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, ifMatch, options) if err != nil { - return APIClientDeleteResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return APIClientDeleteResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return APIClientDeleteResponse{}, err + return nil, err } - return APIClientDeleteResponse{}, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *APIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *APIClientDeleteOptions) (*policy.Request, error) { +func (client *APIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *APIClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -189,20 +208,20 @@ func (client *APIClient) deleteCreateRequest(ctx context.Context, resourceGroupN return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.DeleteRevisions != nil { reqQP.Set("deleteRevisions", strconv.FormatBool(*options.DeleteRevisions)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -231,7 +250,7 @@ func (client *APIClient) Get(ctx context.Context, resourceGroupName string, serv } // getCreateRequest creates the Get request. -func (client *APIClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIClientGetOptions) (*policy.Request, error) { +func (client *APIClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, _ *APIClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -254,7 +273,7 @@ func (client *APIClient) getCreateRequest(ctx context.Context, resourceGroupName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -274,7 +293,7 @@ func (client *APIClient) getHandleResponse(resp *http.Response) (APIClientGetRes // GetEntityTag - Gets the entity state (Etag) version of the API specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -303,7 +322,7 @@ func (client *APIClient) GetEntityTag(ctx context.Context, resourceGroupName str } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, _ *APIClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -326,7 +345,7 @@ func (client *APIClient) getEntityTagCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -343,7 +362,7 @@ func (client *APIClient) getEntityTagHandleResponse(resp *http.Response) (APICli // NewListByServicePager - Lists all APIs of the API Management service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - APIClientListByServiceOptions contains the optional parameters for the APIClient.NewListByServicePager method. @@ -393,19 +412,19 @@ func (client *APIClient) listByServiceCreateRequest(ctx context.Context, resourc if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - if options != nil && options.Tags != nil { - reqQP.Set("tags", *options.Tags) + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.ExpandAPIVersionSet != nil { reqQP.Set("expandApiVersionSet", strconv.FormatBool(*options.ExpandAPIVersionSet)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Tags != nil { + reqQP.Set("tags", *options.Tags) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -422,7 +441,7 @@ func (client *APIClient) listByServiceHandleResponse(resp *http.Response) (APICl // NewListByTagsPager - Lists a collection of apis associated with tags. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - APIClientListByTagsOptions contains the optional parameters for the APIClient.NewListByTagsPager method. @@ -472,16 +491,16 @@ func (client *APIClient) listByTagsCreateRequest(ctx context.Context, resourceGr if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.IncludeNotTaggedApis != nil { reqQP.Set("includeNotTaggedApis", strconv.FormatBool(*options.IncludeNotTaggedApis)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -499,7 +518,7 @@ func (client *APIClient) listByTagsHandleResponse(resp *http.Response) (APIClien // Update - Updates the specified API of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -531,7 +550,7 @@ func (client *APIClient) Update(ctx context.Context, resourceGroupName string, s } // updateCreateRequest creates the Update request. -func (client *APIClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, parameters APIUpdateContract, options *APIClientUpdateOptions) (*policy.Request, error) { +func (client *APIClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, parameters APIUpdateContract, _ *APIClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -554,10 +573,10 @@ func (client *APIClient) updateCreateRequest(ctx context.Context, resourceGroupN return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/api_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/api_client_example_test.go deleted file mode 100644 index b424ced45e4f..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/api_client_example_test.go +++ /dev/null @@ -1,1300 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApis.json -func ExampleAPIClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.APIClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: nil, - Tags: nil, - ExpandAPIVersionSet: 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.APICollection = armapimanagement.APICollection{ - // Count: to.Ptr[int64](4), - // Value: []*armapimanagement.APIContract{ - // { - // Name: to.Ptr("a1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("1"), - // APIVersionSetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/c48f96c9-1385-4e2d-b410-5ab591ce0fc4"), - // IsCurrent: to.Ptr(true), - // Path: to.Ptr("api1"), - // DisplayName: to.Ptr("api1"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api"), - // }, - // }, - // { - // Name: to.Ptr("5a73933b8f27f7cc82a2d533"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5a73933b8f27f7cc82a2d533"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("1"), - // APIVersion: to.Ptr("v1"), - // APIVersionSetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/c48f96c9-1385-4e2d-b410-5ab591ce0fc4"), - // IsCurrent: to.Ptr(true), - // Path: to.Ptr("api1"), - // DisplayName: to.Ptr("api1"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api"), - // }, - // }, - // { - // Name: to.Ptr("echo-api"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // Path: to.Ptr("echo"), - // DisplayName: to.Ptr("Echo API"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api"), - // }, - // }, - // { - // Name: to.Ptr("5a7390baa5816a110435aee0"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5a7390baa5816a110435aee0"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // Path: to.Ptr("vvv"), - // DisplayName: to.Ptr("Swagger Petstore Extensive"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://petstore.swagger.wordnik.com/api"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApi.json -func ExampleAPIClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIClient().GetEntityTag(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiContract.json -func ExampleAPIClient_Get_apiManagementGetApiContract() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIClient().Get(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", 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.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("57d1f7558aa04f15146d9d8a"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a"), - // Properties: &armapimanagement.APIContractProperties{ - // APIType: to.Ptr(armapimanagement.APITypeSoap), - // APIRevision: to.Ptr("1"), - // AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - // OAuth2: &armapimanagement.OAuth2AuthenticationSettingsContract{ - // AuthorizationServerID: to.Ptr("authorizationServerId2283"), - // Scope: to.Ptr("oauth2scope2580"), - // }, - // OAuth2AuthenticationSettings: []*armapimanagement.OAuth2AuthenticationSettingsContract{ - // { - // AuthorizationServerID: to.Ptr("authorizationServerId2283"), - // Scope: to.Ptr("oauth2scope2580"), - // }, - // { - // AuthorizationServerID: to.Ptr("authorizationServerId2284"), - // Scope: to.Ptr("oauth2scope2581"), - // }}, - // }, - // IsCurrent: to.Ptr(true), - // IsOnline: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("schulte"), - // DisplayName: to.Ptr("Service"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("https://api.plexonline.com/DataSource/Service.asmx"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiRevision.json -func ExampleAPIClient_Get_apiManagementGetApiRevisionContract() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIClient().Get(ctx, "rg1", "apimService1", "echo-api;rev=3", 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.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("echo-api;rev=3"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api;rev=3"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("3"), - // APIRevisionDescription: to.Ptr("fixed bug in contract"), - // AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - // OAuth2: &armapimanagement.OAuth2AuthenticationSettingsContract{ - // AuthorizationServerID: to.Ptr("authorizationServerId2283"), - // Scope: to.Ptr("oauth2scope2580"), - // }, - // OAuth2AuthenticationSettings: []*armapimanagement.OAuth2AuthenticationSettingsContract{ - // { - // AuthorizationServerID: to.Ptr("authorizationServerId2283"), - // Scope: to.Ptr("oauth2scope2580"), - // }, - // { - // AuthorizationServerID: to.Ptr("authorizationServerId2284"), - // Scope: to.Ptr("oauth2scope2581"), - // }}, - // }, - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("schulte"), - // DisplayName: to.Ptr("Service"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("https://api.plexonline.com/DataSource/Service.asmx"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApi.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApi() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "tempgroup", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Description: to.Ptr("apidescription5200"), - AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - OAuth2: &armapimanagement.OAuth2AuthenticationSettingsContract{ - AuthorizationServerID: to.Ptr("authorizationServerId2283"), - Scope: to.Ptr("oauth2scope2580"), - }, - }, - SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - Header: to.Ptr("header4520"), - Query: to.Ptr("query3037"), - }, - Path: to.Ptr("newapiPath"), - DisplayName: to.Ptr("apiname1463"), - Protocols: []*armapimanagement.Protocol{ - to.Ptr(armapimanagement.ProtocolHTTPS), - to.Ptr(armapimanagement.ProtocolHTTP)}, - ServiceURL: to.Ptr("http://newechoapi.cloudapp.net/api"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("apiid9419"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/apiid9419"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("apidescription5200"), - // APIRevision: to.Ptr("1"), - // AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - // OAuth2: &armapimanagement.OAuth2AuthenticationSettingsContract{ - // AuthorizationServerID: to.Ptr("authorizationServerId2283"), - // Scope: to.Ptr("oauth2scope2580"), - // }, - // OAuth2AuthenticationSettings: []*armapimanagement.OAuth2AuthenticationSettingsContract{ - // { - // AuthorizationServerID: to.Ptr("authorizationServerId2283"), - // Scope: to.Ptr("oauth2scope2580"), - // }}, - // }, - // IsCurrent: to.Ptr(true), - // IsOnline: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("header4520"), - // Query: to.Ptr("query3037"), - // }, - // Path: to.Ptr("newapiPath"), - // DisplayName: to.Ptr("apiname1463"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTP), - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://newechoapi.cloudapp.net/api"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiClone.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiClone() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "echo-api2", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Description: to.Ptr("Copy of Existing Echo Api including Operations."), - IsCurrent: to.Ptr(true), - SubscriptionRequired: to.Ptr(true), - Path: to.Ptr("echo2"), - DisplayName: to.Ptr("Echo API2"), - Protocols: []*armapimanagement.Protocol{ - to.Ptr(armapimanagement.ProtocolHTTP), - to.Ptr(armapimanagement.ProtocolHTTPS)}, - ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api"), - SourceAPIID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58a4aeac497000007d040001"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("echoapi2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoapi2"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("Copy of Existing Echo Api including Operations."), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // SubscriptionRequired: to.Ptr(true), - // Path: to.Ptr("echo2"), - // DisplayName: to.Ptr("Echo API2"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTP), - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiNewVersionUsingExistingApi.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiNewVersionUsingExistingApi() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "echoapiv3", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Description: to.Ptr("Create Echo API into a new Version using Existing Version Set and Copy all Operations."), - APIVersion: to.Ptr("v4"), - APIVersionSetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458"), - IsCurrent: to.Ptr(true), - SubscriptionRequired: to.Ptr(true), - Path: to.Ptr("echo2"), - DisplayName: to.Ptr("Echo API2"), - Protocols: []*armapimanagement.Protocol{ - to.Ptr(armapimanagement.ProtocolHTTP), - to.Ptr(armapimanagement.ProtocolHTTPS)}, - ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api"), - SourceAPIID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoPath"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("echoapiv3"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echoapiv3"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("Create Echo API into a new Version using Existing Version Set and Copy all Operations."), - // APIRevision: to.Ptr("1"), - // APIVersion: to.Ptr("v4"), - // APIVersionSetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // SubscriptionRequired: to.Ptr(true), - // Path: to.Ptr("echo2"), - // APIVersionSet: &armapimanagement.APIVersionSetContractDetails{ - // Name: to.Ptr("Echo API2"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/aa9c59e6-c0cd-4258-9356-9ca7d2f0b458"), - // VersioningScheme: to.Ptr(armapimanagement.APIVersionSetContractDetailsVersioningSchemeSegment), - // }, - // DisplayName: to.Ptr("Echo API2"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTP), - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiRevisionFromExistingApi.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiRevisionFromExistingApi() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "echo-api;rev=3", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - APIRevisionDescription: to.Ptr("Creating a Revision of an existing API"), - Path: to.Ptr("echo"), - ServiceURL: to.Ptr("http://echoapi.cloudapp.net/apiv3"), - SourceAPIID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("echo-api;rev=3"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api;rev=3"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("3"), - // APIRevisionDescription: to.Ptr("Creating a Revision of an existing API"), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // SubscriptionRequired: to.Ptr(true), - // Path: to.Ptr("echo"), - // DisplayName: to.Ptr("Echo API"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://echoapi.cloudapp.net/apiv3"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingImportOverrideServiceUrl.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiUsingImportOverrideServiceUrl() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "apidocs", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Path: to.Ptr("petstoreapi123"), - ServiceURL: to.Ptr("http://petstore.swagger.wordnik.com/api"), - Format: to.Ptr(armapimanagement.ContentFormat("swagger-link")), - Value: to.Ptr("http://apimpimportviaurl.azurewebsites.net/api/apidocs/"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("apidocs"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/apidocs"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("This is a sample server Petstore server. You can find out more about Swagger \n at http://swagger.wordnik.com or on irc.freenode.net, #swagger. For this sample,\n you can use the api key \"special-key\" to test the authorization filters"), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("petstoreapi123"), - // DisplayName: to.Ptr("Swagger Sample App"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://petstore.swagger.wordnik.com/api"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingOai3Import.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiUsingOai3Import() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "petstore", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Path: to.Ptr("petstore"), - Format: to.Ptr(armapimanagement.ContentFormatOpenapiLink), - Value: to.Ptr("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("petstoreapi"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/petstoreapi"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("petstore"), - // DisplayName: to.Ptr("Swagger Petstore"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://petstore.swagger.io/v1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingOai3ImportWithTranslateRequiredQueryParametersConduct.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiUsingOai3ImportWithTranslateRequiredQueryParametersConduct() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "petstore", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Path: to.Ptr("petstore"), - Format: to.Ptr(armapimanagement.ContentFormatOpenapiLink), - TranslateRequiredQueryParametersConduct: to.Ptr(armapimanagement.TranslateRequiredQueryParametersConductTemplate), - Value: to.Ptr("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("petstoreapi"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/petstoreapi"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("petstore"), - // DisplayName: to.Ptr("Swagger Petstore"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://petstore.swagger.io/v1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingSwaggerImport.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiUsingSwaggerImport() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "petstore", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Path: to.Ptr("petstore"), - Format: to.Ptr(armapimanagement.ContentFormatSwaggerLinkJSON), - Value: to.Ptr("http://petstore.swagger.io/v2/swagger.json"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("petstoreapi"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/petstoreapi"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("petstore"), - // DisplayName: to.Ptr("Swagger Petstore"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTP)}, - // ServiceURL: to.Ptr("http://petstore.swagger.io/v2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiUsingWadlImport.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiUsingWadlImport() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "petstore", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Path: to.Ptr("collector"), - Format: to.Ptr(armapimanagement.ContentFormatWadlLinkJSON), - Value: to.Ptr("https://developer.cisco.com/media/wae-release-6-2-api-reference/wae-collector-rest-api/application.wadl"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("collectorwadl"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/collectorwadl"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr(""), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("collector"), - // DisplayName: to.Ptr("http://localhost:8080/collector-northbound"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://localhost:8080/collector-northbound"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiWithMultipleAuthServers.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiWithMultipleAuthServers() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "tempgroup", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Description: to.Ptr("apidescription5200"), - AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - OAuth2AuthenticationSettings: []*armapimanagement.OAuth2AuthenticationSettingsContract{ - { - AuthorizationServerID: to.Ptr("authorizationServerId2283"), - Scope: to.Ptr("oauth2scope2580"), - }, - { - AuthorizationServerID: to.Ptr("authorizationServerId2284"), - Scope: to.Ptr("oauth2scope2581"), - }}, - }, - SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - Header: to.Ptr("header4520"), - Query: to.Ptr("query3037"), - }, - Path: to.Ptr("newapiPath"), - DisplayName: to.Ptr("apiname1463"), - Protocols: []*armapimanagement.Protocol{ - to.Ptr(armapimanagement.ProtocolHTTPS), - to.Ptr(armapimanagement.ProtocolHTTP)}, - ServiceURL: to.Ptr("http://newechoapi.cloudapp.net/api"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("apiid9419"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/apiid9419"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("apidescription5200"), - // APIRevision: to.Ptr("1"), - // AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - // OAuth2: &armapimanagement.OAuth2AuthenticationSettingsContract{ - // AuthorizationServerID: to.Ptr("authorizationServerId2283"), - // Scope: to.Ptr("oauth2scope2580"), - // }, - // OAuth2AuthenticationSettings: []*armapimanagement.OAuth2AuthenticationSettingsContract{ - // { - // AuthorizationServerID: to.Ptr("authorizationServerId2283"), - // Scope: to.Ptr("oauth2scope2580"), - // }, - // { - // AuthorizationServerID: to.Ptr("authorizationServerId2284"), - // Scope: to.Ptr("oauth2scope2581"), - // }}, - // }, - // IsCurrent: to.Ptr(true), - // IsOnline: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("header4520"), - // Query: to.Ptr("query3037"), - // }, - // Path: to.Ptr("newapiPath"), - // DisplayName: to.Ptr("apiname1463"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTP), - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://newechoapi.cloudapp.net/api"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiWithMultipleOpenIdConnectProviders.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiWithMultipleOpenIdConnectProviders() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "tempgroup", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Description: to.Ptr("apidescription5200"), - AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - OpenidAuthenticationSettings: []*armapimanagement.OpenIDAuthenticationSettingsContract{ - { - BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethods{ - to.Ptr(armapimanagement.BearerTokenSendingMethodsAuthorizationHeader)}, - OpenidProviderID: to.Ptr("openidProviderId2283"), - }, - { - BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethods{ - to.Ptr(armapimanagement.BearerTokenSendingMethodsAuthorizationHeader)}, - OpenidProviderID: to.Ptr("openidProviderId2284"), - }}, - }, - SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - Header: to.Ptr("header4520"), - Query: to.Ptr("query3037"), - }, - Path: to.Ptr("newapiPath"), - DisplayName: to.Ptr("apiname1463"), - Protocols: []*armapimanagement.Protocol{ - to.Ptr(armapimanagement.ProtocolHTTPS), - to.Ptr(armapimanagement.ProtocolHTTP)}, - ServiceURL: to.Ptr("http://newechoapi.cloudapp.net/api"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("apiid9419"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/apiid9419"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("apidescription5200"), - // APIRevision: to.Ptr("1"), - // AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - // Openid: &armapimanagement.OpenIDAuthenticationSettingsContract{ - // BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethods{ - // to.Ptr(armapimanagement.BearerTokenSendingMethodsAuthorizationHeader)}, - // OpenidProviderID: to.Ptr("openidProviderId2283"), - // }, - // OpenidAuthenticationSettings: []*armapimanagement.OpenIDAuthenticationSettingsContract{ - // { - // BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethods{ - // to.Ptr(armapimanagement.BearerTokenSendingMethodsAuthorizationHeader)}, - // OpenidProviderID: to.Ptr("openidProviderId2283"), - // }, - // { - // BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethods{ - // to.Ptr(armapimanagement.BearerTokenSendingMethodsAuthorizationHeader)}, - // OpenidProviderID: to.Ptr("openidProviderId2284"), - // }}, - // }, - // IsCurrent: to.Ptr(true), - // IsOnline: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("header4520"), - // Query: to.Ptr("query3037"), - // }, - // Path: to.Ptr("newapiPath"), - // DisplayName: to.Ptr("apiname1463"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTP), - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://newechoapi.cloudapp.net/api"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiWithOpenIdConnect.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateApiWithOpenIdConnect() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "tempgroup", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Description: to.Ptr("This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."), - AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - Openid: &armapimanagement.OpenIDAuthenticationSettingsContract{ - BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethods{ - to.Ptr(armapimanagement.BearerTokenSendingMethodsAuthorizationHeader)}, - OpenidProviderID: to.Ptr("testopenid"), - }, - }, - SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - Header: to.Ptr("Ocp-Apim-Subscription-Key"), - Query: to.Ptr("subscription-key"), - }, - Path: to.Ptr("petstore"), - DisplayName: to.Ptr("Swagger Petstore"), - Protocols: []*armapimanagement.Protocol{ - to.Ptr(armapimanagement.ProtocolHTTPS)}, - ServiceURL: to.Ptr("http://petstore.swagger.io/v2"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("58da4c4ccdae970a08121230"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/58da4c4ccdae970a08121230"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."), - // APIRevision: to.Ptr("1"), - // AuthenticationSettings: &armapimanagement.AuthenticationSettingsContract{ - // Openid: &armapimanagement.OpenIDAuthenticationSettingsContract{ - // BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethods{ - // to.Ptr(armapimanagement.BearerTokenSendingMethodsAuthorizationHeader)}, - // OpenidProviderID: to.Ptr("testopenid"), - // }, - // }, - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("petstore"), - // DisplayName: to.Ptr("Swagger Petstore"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://petstore.swagger.io/v2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGraphQLApi.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateGraphQlApi() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "tempgroup", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - APIType: to.Ptr(armapimanagement.APITypeGraphql), - Description: to.Ptr("apidescription5200"), - Path: to.Ptr("graphql-api"), - DisplayName: to.Ptr("apiname1463"), - Protocols: []*armapimanagement.Protocol{ - to.Ptr(armapimanagement.ProtocolHTTP), - to.Ptr(armapimanagement.ProtocolHTTPS)}, - ServiceURL: to.Ptr("https://api.spacex.land/graphql"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("apiid9419"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/apiid9419"), - // Properties: &armapimanagement.APIContractProperties{ - // APIType: to.Ptr(armapimanagement.APITypeGraphql), - // Description: to.Ptr("apidescription5200"), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // IsOnline: to.Ptr(true), - // Path: to.Ptr("graphql-api"), - // DisplayName: to.Ptr("apiname1463"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTP), - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("https://api.spacex.land/graphql"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateSoapPassThroughApiUsingWsdlImport.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateSoapPassThroughApiUsingWsdlImport() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "soapApi", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Path: to.Ptr("currency"), - Format: to.Ptr(armapimanagement.ContentFormatWsdlLink), - SoapAPIType: to.Ptr(armapimanagement.SoapAPITypeSoapPassThrough), - Value: to.Ptr("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"), - WsdlSelector: &armapimanagement.APICreateOrUpdatePropertiesWsdlSelector{ - WsdlEndpointName: to.Ptr("CurrencyConvertorSoap"), - WsdlServiceName: to.Ptr("CurrencyConvertor"), - }, - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("soapApi"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/soapApi"), - // Properties: &armapimanagement.APIContractProperties{ - // APIType: to.Ptr(armapimanagement.APITypeSoap), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("currency"), - // DisplayName: to.Ptr("CurrencyConvertor"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://www.webservicex.net"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateSoapToRestApiUsingWsdlImport.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateSoapToRestApiUsingWsdlImport() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "soapApi", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - Path: to.Ptr("currency"), - Format: to.Ptr(armapimanagement.ContentFormatWsdlLink), - Value: to.Ptr("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"), - WsdlSelector: &armapimanagement.APICreateOrUpdatePropertiesWsdlSelector{ - WsdlEndpointName: to.Ptr("CurrencyConvertorSoap"), - WsdlServiceName: to.Ptr("CurrencyConvertor"), - }, - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("soapApi"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/soapApi"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("currency"), - // DisplayName: to.Ptr("CurrencyConvertor"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://www.webservicex.net"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateWebsocketApi.json -func ExampleAPIClient_BeginCreateOrUpdate_apiManagementCreateWebSocketApi() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPIClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "tempgroup", armapimanagement.APICreateOrUpdateParameter{ - Properties: &armapimanagement.APICreateOrUpdateProperties{ - APIType: to.Ptr(armapimanagement.APITypeWebsocket), - Description: to.Ptr("apidescription5200"), - Path: to.Ptr("newapiPath"), - DisplayName: to.Ptr("apiname1463"), - Protocols: []*armapimanagement.Protocol{ - to.Ptr(armapimanagement.ProtocolWss), - to.Ptr(armapimanagement.ProtocolWs)}, - ServiceURL: to.Ptr("wss://echo.websocket.org"), - }, - }, &armapimanagement.APIClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("apiid9419"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/apiid9419"), - // Properties: &armapimanagement.APIContractProperties{ - // APIType: to.Ptr(armapimanagement.APITypeWebsocket), - // Description: to.Ptr("apidescription5200"), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // IsOnline: to.Ptr(true), - // Path: to.Ptr("newapiPath"), - // DisplayName: to.Ptr("apiname1463"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolWs), - // to.Ptr(armapimanagement.ProtocolWss)}, - // ServiceURL: to.Ptr("wss://echo.websocket.org"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApi.json -func ExampleAPIClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIClient().Update(ctx, "rg1", "apimService1", "echo-api", "*", armapimanagement.APIUpdateContract{ - Properties: &armapimanagement.APIContractUpdateProperties{ - Path: to.Ptr("newecho"), - DisplayName: to.Ptr("Echo API New"), - ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api2"), - }, - }, 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.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("echo-api"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // IsOnline: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr("newecho"), - // DisplayName: to.Ptr("Echo API New"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApi.json -func ExampleAPIClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIClient().Delete(ctx, "rg1", "apimService1", "echo-api", "*", &armapimanagement.APIClientDeleteOptions{DeleteRevisions: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApisByTags.json -func ExampleAPIClient_NewListByTagsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIClient().NewListByTagsPager("rg1", "apimService1", &armapimanagement.APIClientListByTagsOptions{Filter: nil, - Top: nil, - Skip: nil, - IncludeNotTaggedApis: 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.TagResourceCollection = armapimanagement.TagResourceCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.TagResourceContract{ - // { - // API: &armapimanagement.APITagResourceContractProperties{ - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // Name: to.Ptr("Echo API"), - // Path: to.Ptr("echo"), - // ID: to.Ptr("/apis/echo-api"), - // ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api"), - // }, - // Tag: &armapimanagement.TagResourceContractProperties{ - // Name: to.Ptr("awesomeTag"), - // ID: to.Ptr("/tags/apitag123"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apidiagnostic_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apidiagnostic_client.go index 333b40f7e733..42b8a5668556 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apidiagnostic_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apidiagnostic_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIDiagnosticClient struct { } // NewAPIDiagnosticClient creates a new instance of APIDiagnosticClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIDiagnosticClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIDiagnosticClient, error) { @@ -47,7 +44,7 @@ func NewAPIDiagnosticClient(subscriptionID string, credential azcore.TokenCreden // CreateOrUpdate - Creates a new Diagnostic for an API or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -105,12 +102,12 @@ func (client *APIDiagnosticClient) createOrUpdateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -132,7 +129,7 @@ func (client *APIDiagnosticClient) createOrUpdateHandleResponse(resp *http.Respo // Delete - Deletes the specified Diagnostic from an API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -162,7 +159,7 @@ func (client *APIDiagnosticClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *APIDiagnosticClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, ifMatch string, options *APIDiagnosticClientDeleteOptions) (*policy.Request, error) { +func (client *APIDiagnosticClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, ifMatch string, _ *APIDiagnosticClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -189,17 +186,17 @@ func (client *APIDiagnosticClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the Diagnostic for an API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -228,7 +225,7 @@ func (client *APIDiagnosticClient) Get(ctx context.Context, resourceGroupName st } // getCreateRequest creates the Get request. -func (client *APIDiagnosticClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, options *APIDiagnosticClientGetOptions) (*policy.Request, error) { +func (client *APIDiagnosticClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, _ *APIDiagnosticClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -255,7 +252,7 @@ func (client *APIDiagnosticClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -275,7 +272,7 @@ func (client *APIDiagnosticClient) getHandleResponse(resp *http.Response) (APIDi // GetEntityTag - Gets the entity state (Etag) version of the Diagnostic for an API specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -305,7 +302,7 @@ func (client *APIDiagnosticClient) GetEntityTag(ctx context.Context, resourceGro } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIDiagnosticClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, options *APIDiagnosticClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIDiagnosticClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, _ *APIDiagnosticClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -332,7 +329,7 @@ func (client *APIDiagnosticClient) getEntityTagCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -349,7 +346,7 @@ func (client *APIDiagnosticClient) getEntityTagHandleResponse(resp *http.Respons // NewListByServicePager - Lists all diagnostics of an API. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -405,13 +402,13 @@ func (client *APIDiagnosticClient) listByServiceCreateRequest(ctx context.Contex if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -429,7 +426,7 @@ func (client *APIDiagnosticClient) listByServiceHandleResponse(resp *http.Respon // Update - Updates the details of the Diagnostic for an API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -461,7 +458,7 @@ func (client *APIDiagnosticClient) Update(ctx context.Context, resourceGroupName } // updateCreateRequest creates the Update request. -func (client *APIDiagnosticClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, ifMatch string, parameters DiagnosticContract, options *APIDiagnosticClientUpdateOptions) (*policy.Request, error) { +func (client *APIDiagnosticClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, ifMatch string, parameters DiagnosticContract, _ *APIDiagnosticClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -488,10 +485,10 @@ func (client *APIDiagnosticClient) updateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apidiagnostic_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apidiagnostic_client_example_test.go deleted file mode 100644 index 9740b5dfbebf..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apidiagnostic_client_example_test.go +++ /dev/null @@ -1,413 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiDiagnostics.json -func ExampleAPIDiagnosticClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIDiagnosticClient().NewListByServicePager("rg1", "apimService1", "echo-api", &armapimanagement.APIDiagnosticClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.DiagnosticCollection = armapimanagement.DiagnosticCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.DiagnosticContract{ - // { - // Name: to.Ptr("applicationinsights"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/diagnostics"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api/diagnostics/applicationinsights"), - // Properties: &armapimanagement.DiagnosticContractProperties{ - // AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - // Backend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // Frontend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // HTTPCorrelationProtocol: to.Ptr(armapimanagement.HTTPCorrelationProtocolLegacy), - // LogClientIP: to.Ptr(true), - // LoggerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/aisamplingtest"), - // Sampling: &armapimanagement.SamplingSettings{ - // Percentage: to.Ptr[float64](100), - // SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiDiagnostic.json -func ExampleAPIDiagnosticClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIDiagnosticClient().GetEntityTag(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "applicationinsights", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiDiagnostic.json -func ExampleAPIDiagnosticClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIDiagnosticClient().Get(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "applicationinsights", 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.DiagnosticContract = armapimanagement.DiagnosticContract{ - // Name: to.Ptr("applicationinsights"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/diagnostics"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api/diagnostics/applicationinsights"), - // Properties: &armapimanagement.DiagnosticContractProperties{ - // AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - // Backend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // Frontend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // HTTPCorrelationProtocol: to.Ptr(armapimanagement.HTTPCorrelationProtocolLegacy), - // LogClientIP: to.Ptr(true), - // LoggerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/aisamplingtest"), - // Sampling: &armapimanagement.SamplingSettings{ - // Percentage: to.Ptr[float64](100), - // SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiDiagnostic.json -func ExampleAPIDiagnosticClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIDiagnosticClient().CreateOrUpdate(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "applicationinsights", armapimanagement.DiagnosticContract{ - Properties: &armapimanagement.DiagnosticContractProperties{ - AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - Backend: &armapimanagement.PipelineDiagnosticSettings{ - Response: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - Request: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - }, - Frontend: &armapimanagement.PipelineDiagnosticSettings{ - Response: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - Request: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - }, - LoggerID: to.Ptr("/loggers/applicationinsights"), - Sampling: &armapimanagement.SamplingSettings{ - Percentage: to.Ptr[float64](50), - SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - }, - }, - }, &armapimanagement.APIDiagnosticClientCreateOrUpdateOptions{IfMatch: 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.DiagnosticContract = armapimanagement.DiagnosticContract{ - // Name: to.Ptr("applicationinsights"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/diagnostics"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/diagnostics/applicationinsights"), - // Properties: &armapimanagement.DiagnosticContractProperties{ - // AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - // Backend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // }, - // Frontend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // }, - // LoggerID: to.Ptr("/loggers/applicationinsights"), - // Sampling: &armapimanagement.SamplingSettings{ - // Percentage: to.Ptr[float64](50), - // SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiDiagnostic.json -func ExampleAPIDiagnosticClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIDiagnosticClient().Update(ctx, "rg1", "apimService1", "echo-api", "applicationinsights", "*", armapimanagement.DiagnosticContract{ - Properties: &armapimanagement.DiagnosticContractProperties{ - AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - Backend: &armapimanagement.PipelineDiagnosticSettings{ - Response: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - Request: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - }, - Frontend: &armapimanagement.PipelineDiagnosticSettings{ - Response: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - Request: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - }, - LoggerID: to.Ptr("/loggers/applicationinsights"), - Sampling: &armapimanagement.SamplingSettings{ - Percentage: to.Ptr[float64](50), - SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - }, - }, - }, 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.DiagnosticContract = armapimanagement.DiagnosticContract{ - // Name: to.Ptr("applicationinsights"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/diagnostics"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api/diagnostics/applicationinsights"), - // Properties: &armapimanagement.DiagnosticContractProperties{ - // AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - // Backend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // Frontend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // HTTPCorrelationProtocol: to.Ptr(armapimanagement.HTTPCorrelationProtocolLegacy), - // LogClientIP: to.Ptr(true), - // LoggerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/aisamplingtest"), - // Sampling: &armapimanagement.SamplingSettings{ - // Percentage: to.Ptr[float64](100), - // SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiDiagnostic.json -func ExampleAPIDiagnosticClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIDiagnosticClient().Delete(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "applicationinsights", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiexport_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiexport_client.go index 0d579ef70df9..89651954e644 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiexport_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apiexport_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type APIExportClient struct { } // NewAPIExportClient creates a new instance of APIExportClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIExportClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIExportClient, error) { @@ -47,12 +44,13 @@ func NewAPIExportClient(subscriptionID string, credential azcore.TokenCredential // valid for 5 minutes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has // ;rev=n as a suffix where n is the revision number. -// - formatParam - Format in which to export the Api Details to the Storage Blob with Sas Key valid for 5 minutes. +// - formatParam - Format in which to export the Api Details to the Storage Blob with Sas Key valid for 5 minutes. New formats +// can be added in the future. // - export - Query parameter required to export the API details. // - options - APIExportClientGetOptions contains the optional parameters for the APIExportClient.Get method. func (client *APIExportClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, formatParam ExportFormat, export ExportAPI, options *APIExportClientGetOptions) (APIExportClientGetResponse, error) { @@ -78,7 +76,7 @@ func (client *APIExportClient) Get(ctx context.Context, resourceGroupName string } // getCreateRequest creates the Get request. -func (client *APIExportClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, formatParam ExportFormat, export ExportAPI, options *APIExportClientGetOptions) (*policy.Request, error) { +func (client *APIExportClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, formatParam ExportFormat, export ExportAPI, _ *APIExportClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -101,9 +99,9 @@ func (client *APIExportClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("format", string(formatParam)) + reqQP.Set("api-version", "2024-05-01") reqQP.Set("export", string(export)) - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("format", string(formatParam)) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiexport_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiexport_client_example_test.go deleted file mode 100644 index 4924e660be77..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiexport_client_example_test.go +++ /dev/null @@ -1,72 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiExportInOpenApi2dot0.json -func ExampleAPIExportClient_Get_apiManagementGetApiExportInOpenApi2Dot0() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIExportClient().Get(ctx, "rg1", "apimService1", "echo-api", armapimanagement.ExportFormatSwagger, armapimanagement.ExportAPITrue, 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.APIExportResult = armapimanagement.APIExportResult{ - // ExportResultFormat: to.Ptr(armapimanagement.ExportResultFormatSwagger), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api"), - // Value: &armapimanagement.APIExportResultValue{ - // Link: to.Ptr("https://apimgmtstkjpszxxxxxxx.blob.core.windows.net/api-export/Swagger Petstore Extensive.json?sv=2015-07-08&sr=b&sig=mxhLsFuOonu8EXIjyFPV%2FnDra0qTIoip7N7MuU%2BTFsA%3D&se=2019-04-10T22:41:31Z&sp=r"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiExportInOpenApi3dot0.json -func ExampleAPIExportClient_Get_apiManagementGetApiExportInOpenApi3Dot0() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIExportClient().Get(ctx, "rg1", "apimService1", "aid9676", armapimanagement.ExportFormatOpenapi, armapimanagement.ExportAPITrue, 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.APIExportResult = armapimanagement.APIExportResult{ - // ExportResultFormat: to.Ptr(armapimanagement.ExportResultFormatOpenAPI), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/aid9676"), - // Value: &armapimanagement.APIExportResultValue{ - // Link: to.Ptr("https: //apimgmtstkjpszxxxxxxx.blob.core.windows.net/api-export/Swagger Petstore.yaml?storage-sas-signature"), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apigateway_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apigateway_client.go new file mode 100644 index 000000000000..4a1ed1371ab4 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apigateway_client.go @@ -0,0 +1,455 @@ +// 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 armapimanagement + +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" +) + +// APIGatewayClient contains the methods for the APIGateway group. +// Don't use this type directly, use NewAPIGatewayClient() instead. +type APIGatewayClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAPIGatewayClient creates a new instance of APIGatewayClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAPIGatewayClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIGatewayClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &APIGatewayClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates an API Management gateway. This is long running operation and could take several +// minutes to complete. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - gatewayName - The name of the API Management gateway. +// - parameters - Parameters supplied to the CreateOrUpdate API Management gateway operation. +// - options - APIGatewayClientBeginCreateOrUpdateOptions contains the optional parameters for the APIGatewayClient.BeginCreateOrUpdate +// method. +func (client *APIGatewayClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, parameters GatewayResource, options *APIGatewayClientBeginCreateOrUpdateOptions) (*runtime.Poller[APIGatewayClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, gatewayName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[APIGatewayClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[APIGatewayClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates or updates an API Management gateway. This is long running operation and could take several minutes +// to complete. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *APIGatewayClient) createOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, parameters GatewayResource, options *APIGatewayClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "APIGatewayClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, gatewayName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIGatewayClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, parameters GatewayResource, _ *APIGatewayClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Deletes an existing API Management gateway. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - gatewayName - The name of the API Management gateway. +// - options - APIGatewayClientBeginDeleteOptions contains the optional parameters for the APIGatewayClient.BeginDelete method. +func (client *APIGatewayClient) BeginDelete(ctx context.Context, resourceGroupName string, gatewayName string, options *APIGatewayClientBeginDeleteOptions) (*runtime.Poller[APIGatewayClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, gatewayName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[APIGatewayClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[APIGatewayClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes an existing API Management gateway. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *APIGatewayClient) deleteOperation(ctx context.Context, resourceGroupName string, gatewayName string, options *APIGatewayClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "APIGatewayClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, gatewayName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIGatewayClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, _ *APIGatewayClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets an API Management gateway resource description. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - gatewayName - The name of the API Management gateway. +// - options - APIGatewayClientGetOptions contains the optional parameters for the APIGatewayClient.Get method. +func (client *APIGatewayClient) Get(ctx context.Context, resourceGroupName string, gatewayName string, options *APIGatewayClientGetOptions) (APIGatewayClientGetResponse, error) { + var err error + const operationName = "APIGatewayClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, gatewayName, options) + if err != nil { + return APIGatewayClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIGatewayClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return APIGatewayClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *APIGatewayClient) getCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, _ *APIGatewayClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIGatewayClient) getHandleResponse(resp *http.Response) (APIGatewayClientGetResponse, error) { + result := APIGatewayClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GatewayResource); err != nil { + return APIGatewayClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List all API Management gateways within a subscription. +// +// Generated from API version 2024-05-01 +// - options - APIGatewayClientListOptions contains the optional parameters for the APIGatewayClient.NewListPager method. +func (client *APIGatewayClient) NewListPager(options *APIGatewayClientListOptions) *runtime.Pager[APIGatewayClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[APIGatewayClientListResponse]{ + More: func(page APIGatewayClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *APIGatewayClientListResponse) (APIGatewayClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "APIGatewayClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return APIGatewayClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *APIGatewayClient) listCreateRequest(ctx context.Context, _ *APIGatewayClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/gateways" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *APIGatewayClient) listHandleResponse(resp *http.Response) (APIGatewayClientListResponse, error) { + result := APIGatewayClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GatewayListResult); err != nil { + return APIGatewayClientListResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List all API Management gateways within a resource group. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - APIGatewayClientListByResourceGroupOptions contains the optional parameters for the APIGatewayClient.NewListByResourceGroupPager +// method. +func (client *APIGatewayClient) NewListByResourceGroupPager(resourceGroupName string, options *APIGatewayClientListByResourceGroupOptions) *runtime.Pager[APIGatewayClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[APIGatewayClientListByResourceGroupResponse]{ + More: func(page APIGatewayClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *APIGatewayClientListByResourceGroupResponse) (APIGatewayClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "APIGatewayClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return APIGatewayClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *APIGatewayClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *APIGatewayClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *APIGatewayClient) listByResourceGroupHandleResponse(resp *http.Response) (APIGatewayClientListByResourceGroupResponse, error) { + result := APIGatewayClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GatewayListResult); err != nil { + return APIGatewayClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates an existing API Management gateway. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - gatewayName - The name of the API Management gateway. +// - parameters - Parameters supplied to the CreateOrUpdate API Management gateway operation. +// - options - APIGatewayClientBeginUpdateOptions contains the optional parameters for the APIGatewayClient.BeginUpdate method. +func (client *APIGatewayClient) BeginUpdate(ctx context.Context, resourceGroupName string, gatewayName string, parameters GatewayUpdateParameters, options *APIGatewayClientBeginUpdateOptions) (*runtime.Poller[APIGatewayClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, gatewayName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[APIGatewayClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[APIGatewayClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Updates an existing API Management gateway. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *APIGatewayClient) update(ctx context.Context, resourceGroupName string, gatewayName string, parameters GatewayUpdateParameters, options *APIGatewayClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "APIGatewayClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, gatewayName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *APIGatewayClient) updateCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, parameters GatewayUpdateParameters, _ *APIGatewayClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apigatewayconfigconnection_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apigatewayconfigconnection_client.go new file mode 100644 index 000000000000..3179dbc1d3d3 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apigatewayconfigconnection_client.go @@ -0,0 +1,348 @@ +// 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 armapimanagement + +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" +) + +// APIGatewayConfigConnectionClient contains the methods for the APIGatewayConfigConnection group. +// Don't use this type directly, use NewAPIGatewayConfigConnectionClient() instead. +type APIGatewayConfigConnectionClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAPIGatewayConfigConnectionClient creates a new instance of APIGatewayConfigConnectionClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAPIGatewayConfigConnectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIGatewayConfigConnectionClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &APIGatewayConfigConnectionClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates an API Management gateway config connection. This is long running operation and +// could take several minutes to complete. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - gatewayName - The name of the API Management gateway. +// - configConnectionName - The name of the API Management gateway config connection. +// - parameters - Parameters supplied to the CreateOrUpdate API Management gateway config connection operation. +// - options - APIGatewayConfigConnectionClientBeginCreateOrUpdateOptions contains the optional parameters for the APIGatewayConfigConnectionClient.BeginCreateOrUpdate +// method. +func (client *APIGatewayConfigConnectionClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, parameters GatewayConfigConnectionResource, options *APIGatewayConfigConnectionClientBeginCreateOrUpdateOptions) (*runtime.Poller[APIGatewayConfigConnectionClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, gatewayName, configConnectionName, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[APIGatewayConfigConnectionClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[APIGatewayConfigConnectionClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates or updates an API Management gateway config connection. This is long running operation and could +// take several minutes to complete. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *APIGatewayConfigConnectionClient) createOrUpdate(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, parameters GatewayConfigConnectionResource, options *APIGatewayConfigConnectionClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "APIGatewayConfigConnectionClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, gatewayName, configConnectionName, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIGatewayConfigConnectionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, parameters GatewayConfigConnectionResource, _ *APIGatewayConfigConnectionClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections/{configConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + if configConnectionName == "" { + return nil, errors.New("parameter configConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configConnectionName}", url.PathEscape(configConnectionName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Deletes an existing API Management gateway config connection. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - gatewayName - The name of the API Management gateway. +// - configConnectionName - The name of the API Management gateway config connection. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - APIGatewayConfigConnectionClientBeginDeleteOptions contains the optional parameters for the APIGatewayConfigConnectionClient.BeginDelete +// method. +func (client *APIGatewayConfigConnectionClient) BeginDelete(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, ifMatch string, options *APIGatewayConfigConnectionClientBeginDeleteOptions) (*runtime.Poller[APIGatewayConfigConnectionClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, gatewayName, configConnectionName, ifMatch, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[APIGatewayConfigConnectionClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[APIGatewayConfigConnectionClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes an existing API Management gateway config connection. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *APIGatewayConfigConnectionClient) deleteOperation(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, ifMatch string, options *APIGatewayConfigConnectionClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "APIGatewayConfigConnectionClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, gatewayName, configConnectionName, ifMatch, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIGatewayConfigConnectionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, ifMatch string, _ *APIGatewayConfigConnectionClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections/{configConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + if configConnectionName == "" { + return nil, errors.New("parameter configConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configConnectionName}", url.PathEscape(configConnectionName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets an API Management gateway config connection resource description. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - gatewayName - The name of the API Management gateway. +// - configConnectionName - The name of the API Management gateway config connection. +// - options - APIGatewayConfigConnectionClientGetOptions contains the optional parameters for the APIGatewayConfigConnectionClient.Get +// method. +func (client *APIGatewayConfigConnectionClient) Get(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, options *APIGatewayConfigConnectionClientGetOptions) (APIGatewayConfigConnectionClientGetResponse, error) { + var err error + const operationName = "APIGatewayConfigConnectionClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, gatewayName, configConnectionName, options) + if err != nil { + return APIGatewayConfigConnectionClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIGatewayConfigConnectionClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return APIGatewayConfigConnectionClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *APIGatewayConfigConnectionClient) getCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, _ *APIGatewayConfigConnectionClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections/{configConnectionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + if configConnectionName == "" { + return nil, errors.New("parameter configConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configConnectionName}", url.PathEscape(configConnectionName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIGatewayConfigConnectionClient) getHandleResponse(resp *http.Response) (APIGatewayConfigConnectionClientGetResponse, error) { + result := APIGatewayConfigConnectionClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GatewayConfigConnectionResource); err != nil { + return APIGatewayConfigConnectionClientGetResponse{}, err + } + return result, nil +} + +// NewListByGatewayPager - List all API Management gateway config connections within a gateway. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - gatewayName - The name of the API Management gateway. +// - options - APIGatewayConfigConnectionClientListByGatewayOptions contains the optional parameters for the APIGatewayConfigConnectionClient.NewListByGatewayPager +// method. +func (client *APIGatewayConfigConnectionClient) NewListByGatewayPager(resourceGroupName string, gatewayName string, options *APIGatewayConfigConnectionClientListByGatewayOptions) *runtime.Pager[APIGatewayConfigConnectionClientListByGatewayResponse] { + return runtime.NewPager(runtime.PagingHandler[APIGatewayConfigConnectionClientListByGatewayResponse]{ + More: func(page APIGatewayConfigConnectionClientListByGatewayResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *APIGatewayConfigConnectionClientListByGatewayResponse) (APIGatewayConfigConnectionClientListByGatewayResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "APIGatewayConfigConnectionClient.NewListByGatewayPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByGatewayCreateRequest(ctx, resourceGroupName, gatewayName, options) + }, nil) + if err != nil { + return APIGatewayConfigConnectionClientListByGatewayResponse{}, err + } + return client.listByGatewayHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByGatewayCreateRequest creates the ListByGateway request. +func (client *APIGatewayConfigConnectionClient) listByGatewayCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, _ *APIGatewayConfigConnectionClientListByGatewayOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByGatewayHandleResponse handles the ListByGateway response. +func (client *APIGatewayConfigConnectionClient) listByGatewayHandleResponse(resp *http.Response) (APIGatewayConfigConnectionClientListByGatewayResponse, error) { + result := APIGatewayConfigConnectionClientListByGatewayResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GatewayConfigConnectionListResult); err != nil { + return APIGatewayConfigConnectionClientListByGatewayResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiissue_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiissue_client.go index 0d8dea49fe45..f89a9eabca8c 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiissue_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apiissue_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIIssueClient struct { } // NewAPIIssueClient creates a new instance of APIIssueClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIIssueClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIIssueClient, error) { @@ -47,7 +44,7 @@ func NewAPIIssueClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Creates a new Issue for an API or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -104,12 +101,12 @@ func (client *APIIssueClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -131,7 +128,7 @@ func (client *APIIssueClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Deletes the specified Issue from an API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -161,7 +158,7 @@ func (client *APIIssueClient) Delete(ctx context.Context, resourceGroupName stri } // deleteCreateRequest creates the Delete request. -func (client *APIIssueClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, ifMatch string, options *APIIssueClientDeleteOptions) (*policy.Request, error) { +func (client *APIIssueClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, ifMatch string, _ *APIIssueClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -188,17 +185,17 @@ func (client *APIIssueClient) deleteCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the Issue for an API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -254,10 +251,10 @@ func (client *APIIssueClient) getCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.ExpandCommentsAttachments != nil { reqQP.Set("expandCommentsAttachments", strconv.FormatBool(*options.ExpandCommentsAttachments)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -277,7 +274,7 @@ func (client *APIIssueClient) getHandleResponse(resp *http.Response) (APIIssueCl // GetEntityTag - Gets the entity state (Etag) version of the Issue for an API specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -306,7 +303,7 @@ func (client *APIIssueClient) GetEntityTag(ctx context.Context, resourceGroupNam } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIIssueClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, options *APIIssueClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIIssueClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, _ *APIIssueClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -333,7 +330,7 @@ func (client *APIIssueClient) getEntityTagCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -350,7 +347,7 @@ func (client *APIIssueClient) getEntityTagHandleResponse(resp *http.Response) (A // NewListByServicePager - Lists all issues associated with the specified API. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -406,16 +403,16 @@ func (client *APIIssueClient) listByServiceCreateRequest(ctx context.Context, re if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.ExpandCommentsAttachments != nil { - reqQP.Set("expandCommentsAttachments", strconv.FormatBool(*options.ExpandCommentsAttachments)) + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - if options != nil && options.Skip != nil { - reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.ExpandCommentsAttachments != nil { + reqQP.Set("expandCommentsAttachments", strconv.FormatBool(*options.ExpandCommentsAttachments)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -433,7 +430,7 @@ func (client *APIIssueClient) listByServiceHandleResponse(resp *http.Response) ( // Update - Updates an existing issue for an API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -465,7 +462,7 @@ func (client *APIIssueClient) Update(ctx context.Context, resourceGroupName stri } // updateCreateRequest creates the Update request. -func (client *APIIssueClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, ifMatch string, parameters IssueUpdateContract, options *APIIssueClientUpdateOptions) (*policy.Request, error) { +func (client *APIIssueClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, ifMatch string, parameters IssueUpdateContract, _ *APIIssueClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -492,10 +489,10 @@ func (client *APIIssueClient) updateCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiissue_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiissue_client_example_test.go deleted file mode 100644 index 3964490a2fb7..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiissue_client_example_test.go +++ /dev/null @@ -1,211 +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 armapimanagement_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiIssues.json -func ExampleAPIIssueClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIIssueClient().NewListByServicePager("rg1", "apimService1", "57d1f7558aa04f15146d9d8a", &armapimanagement.APIIssueClientListByServiceOptions{Filter: nil, - ExpandCommentsAttachments: nil, - Top: nil, - Skip: 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.IssueCollection = armapimanagement.IssueCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.IssueContract{ - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.IssueContractProperties{ - // APIID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a"), - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // State: to.Ptr(armapimanagement.StateOpen), - // Description: to.Ptr("New API issue description"), - // Title: to.Ptr("New API issue"), - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiIssue.json -func ExampleAPIIssueClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIIssueClient().GetEntityTag(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiIssue.json -func ExampleAPIIssueClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIIssueClient().Get(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", &armapimanagement.APIIssueClientGetOptions{ExpandCommentsAttachments: 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.IssueContract = armapimanagement.IssueContract{ - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.IssueContractProperties{ - // APIID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a"), - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // State: to.Ptr(armapimanagement.StateOpen), - // Description: to.Ptr("New API issue description"), - // Title: to.Ptr("New API issue"), - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiIssue.json -func ExampleAPIIssueClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIIssueClient().CreateOrUpdate(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "57d2ef278aa04f0ad01d6cdc", armapimanagement.IssueContract{ - Properties: &armapimanagement.IssueContractProperties{ - CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t }()), - State: to.Ptr(armapimanagement.StateOpen), - Description: to.Ptr("New API issue description"), - Title: to.Ptr("New API issue"), - UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - }, - }, &armapimanagement.APIIssueClientCreateOrUpdateOptions{IfMatch: 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.IssueContract = armapimanagement.IssueContract{ - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.IssueContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // State: to.Ptr(armapimanagement.StateOpen), - // Description: to.Ptr("New API issue description"), - // Title: to.Ptr("New API issue"), - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiIssue.json -func ExampleAPIIssueClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIIssueClient().Update(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "57d2ef278aa04f0ad01d6cdc", "*", armapimanagement.IssueUpdateContract{ - Properties: &armapimanagement.IssueUpdateContractProperties{ - State: to.Ptr(armapimanagement.StateClosed), - }, - }, 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.IssueContract = armapimanagement.IssueContract{ - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.IssueContractProperties{ - // APIID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a"), - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // State: to.Ptr(armapimanagement.StateOpen), - // Description: to.Ptr("New API issue description"), - // Title: to.Ptr("New API issue"), - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiIssue.json -func ExampleAPIIssueClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIIssueClient().Delete(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "57d2ef278aa04f0ad01d6cdc", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiissueattachment_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiissueattachment_client.go index 2d8b5d420d49..0c87c6a6b8ea 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiissueattachment_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apiissueattachment_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIIssueAttachmentClient struct { } // NewAPIIssueAttachmentClient creates a new instance of APIIssueAttachmentClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIIssueAttachmentClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIIssueAttachmentClient, error) { @@ -47,7 +44,7 @@ func NewAPIIssueAttachmentClient(subscriptionID string, credential azcore.TokenC // CreateOrUpdate - Creates a new Attachment for the Issue in an API or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -110,12 +107,12 @@ func (client *APIIssueAttachmentClient) createOrUpdateCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -137,7 +134,7 @@ func (client *APIIssueAttachmentClient) createOrUpdateHandleResponse(resp *http. // Delete - Deletes the specified comment from an Issue. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -169,7 +166,7 @@ func (client *APIIssueAttachmentClient) Delete(ctx context.Context, resourceGrou } // deleteCreateRequest creates the Delete request. -func (client *APIIssueAttachmentClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, ifMatch string, options *APIIssueAttachmentClientDeleteOptions) (*policy.Request, error) { +func (client *APIIssueAttachmentClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, ifMatch string, _ *APIIssueAttachmentClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -200,17 +197,17 @@ func (client *APIIssueAttachmentClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the issue Attachment for an API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -240,7 +237,7 @@ func (client *APIIssueAttachmentClient) Get(ctx context.Context, resourceGroupNa } // getCreateRequest creates the Get request. -func (client *APIIssueAttachmentClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, options *APIIssueAttachmentClientGetOptions) (*policy.Request, error) { +func (client *APIIssueAttachmentClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, _ *APIIssueAttachmentClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -271,7 +268,7 @@ func (client *APIIssueAttachmentClient) getCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -291,7 +288,7 @@ func (client *APIIssueAttachmentClient) getHandleResponse(resp *http.Response) ( // GetEntityTag - Gets the entity state (Etag) version of the issue Attachment for an API specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -322,7 +319,7 @@ func (client *APIIssueAttachmentClient) GetEntityTag(ctx context.Context, resour } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIIssueAttachmentClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, options *APIIssueAttachmentClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIIssueAttachmentClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, _ *APIIssueAttachmentClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -353,7 +350,7 @@ func (client *APIIssueAttachmentClient) getEntityTagCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -370,7 +367,7 @@ func (client *APIIssueAttachmentClient) getEntityTagHandleResponse(resp *http.Re // NewListByServicePager - Lists all attachments for the Issue associated with the specified API. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -431,13 +428,13 @@ func (client *APIIssueAttachmentClient) listByServiceCreateRequest(ctx context.C if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiissueattachment_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiissueattachment_client_example_test.go deleted file mode 100644 index 651183e25714..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiissueattachment_client_example_test.go +++ /dev/null @@ -1,161 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiIssueAttachments.json -func ExampleAPIIssueAttachmentClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIIssueAttachmentClient().NewListByServicePager("rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "57d2ef278aa04f0ad01d6cdc", &armapimanagement.APIIssueAttachmentClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.IssueAttachmentCollection = armapimanagement.IssueAttachmentCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.IssueAttachmentContract{ - // { - // Name: to.Ptr("57d2ef278aa04f0888cba3f3"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues/attachments"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc/attachments/57d2ef278aa04f0888cba3f3"), - // Properties: &armapimanagement.IssueAttachmentContractProperties{ - // Content: to.Ptr("https://.../image.jpg"), - // ContentFormat: to.Ptr("link"), - // Title: to.Ptr("Issue attachment."), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiIssueAttachment.json -func ExampleAPIIssueAttachmentClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIIssueAttachmentClient().GetEntityTag(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", "57d2ef278aa04f0888cba3f3", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiIssueAttachment.json -func ExampleAPIIssueAttachmentClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIIssueAttachmentClient().Get(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", "57d2ef278aa04f0888cba3f3", 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.IssueAttachmentContract = armapimanagement.IssueAttachmentContract{ - // Name: to.Ptr("57d2ef278aa04f0888cba3f3"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues/attachments"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc/attachments/57d2ef278aa04f0888cba3f3"), - // Properties: &armapimanagement.IssueAttachmentContractProperties{ - // Content: to.Ptr("https://.../image.jpg"), - // ContentFormat: to.Ptr("link"), - // Title: to.Ptr("Issue attachment."), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiIssueAttachment.json -func ExampleAPIIssueAttachmentClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIIssueAttachmentClient().CreateOrUpdate(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "57d2ef278aa04f0ad01d6cdc", "57d2ef278aa04f0888cba3f3", armapimanagement.IssueAttachmentContract{ - Properties: &armapimanagement.IssueAttachmentContractProperties{ - Content: to.Ptr("IEJhc2U2NA=="), - ContentFormat: to.Ptr("image/jpeg"), - Title: to.Ptr("Issue attachment."), - }, - }, &armapimanagement.APIIssueAttachmentClientCreateOrUpdateOptions{IfMatch: 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.IssueAttachmentContract = armapimanagement.IssueAttachmentContract{ - // Name: to.Ptr("57d2ef278aa04f0888cba3f3"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues/attachments"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc/attachments/57d2ef278aa04f0888cba3f3"), - // Properties: &armapimanagement.IssueAttachmentContractProperties{ - // Content: to.Ptr("https://.../image.jpg"), - // ContentFormat: to.Ptr("link"), - // Title: to.Ptr("Issue attachment."), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiIssueAttachment.json -func ExampleAPIIssueAttachmentClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIIssueAttachmentClient().Delete(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "57d2ef278aa04f0ad01d6cdc", "57d2ef278aa04f0888cba3f3", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiissuecomment_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiissuecomment_client.go index 6a98902f6a64..8d03287c63d3 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiissuecomment_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apiissuecomment_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIIssueCommentClient struct { } // NewAPIIssueCommentClient creates a new instance of APIIssueCommentClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIIssueCommentClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIIssueCommentClient, error) { @@ -47,7 +44,7 @@ func NewAPIIssueCommentClient(subscriptionID string, credential azcore.TokenCred // CreateOrUpdate - Creates a new Comment for the Issue in an API or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -110,12 +107,12 @@ func (client *APIIssueCommentClient) createOrUpdateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -137,7 +134,7 @@ func (client *APIIssueCommentClient) createOrUpdateHandleResponse(resp *http.Res // Delete - Deletes the specified comment from an Issue. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -168,7 +165,7 @@ func (client *APIIssueCommentClient) Delete(ctx context.Context, resourceGroupNa } // deleteCreateRequest creates the Delete request. -func (client *APIIssueCommentClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, ifMatch string, options *APIIssueCommentClientDeleteOptions) (*policy.Request, error) { +func (client *APIIssueCommentClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, ifMatch string, _ *APIIssueCommentClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -199,17 +196,17 @@ func (client *APIIssueCommentClient) deleteCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the issue Comment for an API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -239,7 +236,7 @@ func (client *APIIssueCommentClient) Get(ctx context.Context, resourceGroupName } // getCreateRequest creates the Get request. -func (client *APIIssueCommentClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, options *APIIssueCommentClientGetOptions) (*policy.Request, error) { +func (client *APIIssueCommentClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, _ *APIIssueCommentClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -270,7 +267,7 @@ func (client *APIIssueCommentClient) getCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -290,7 +287,7 @@ func (client *APIIssueCommentClient) getHandleResponse(resp *http.Response) (API // GetEntityTag - Gets the entity state (Etag) version of the issue Comment for an API specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -321,7 +318,7 @@ func (client *APIIssueCommentClient) GetEntityTag(ctx context.Context, resourceG } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIIssueCommentClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, options *APIIssueCommentClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIIssueCommentClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, _ *APIIssueCommentClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -352,7 +349,7 @@ func (client *APIIssueCommentClient) getEntityTagCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -369,7 +366,7 @@ func (client *APIIssueCommentClient) getEntityTagHandleResponse(resp *http.Respo // NewListByServicePager - Lists all comments for the Issue associated with the specified API. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -430,13 +427,13 @@ func (client *APIIssueCommentClient) listByServiceCreateRequest(ctx context.Cont if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiissuecomment_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiissuecomment_client_example_test.go deleted file mode 100644 index ff7e37ce9d8e..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiissuecomment_client_example_test.go +++ /dev/null @@ -1,163 +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 armapimanagement_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiIssueComments.json -func ExampleAPIIssueCommentClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIIssueCommentClient().NewListByServicePager("rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "57d2ef278aa04f0ad01d6cdc", &armapimanagement.APIIssueCommentClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.IssueCommentCollection = armapimanagement.IssueCommentCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.IssueCommentContract{ - // { - // Name: to.Ptr("599e29ab193c3c0bd0b3e2fb"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues/comments"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc/comments/599e29ab193c3c0bd0b3e2fb"), - // Properties: &armapimanagement.IssueCommentContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // Text: to.Ptr("Issue comment."), - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiIssueComment.json -func ExampleAPIIssueCommentClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIIssueCommentClient().GetEntityTag(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", "599e29ab193c3c0bd0b3e2fb", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiIssueComment.json -func ExampleAPIIssueCommentClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIIssueCommentClient().Get(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", "599e29ab193c3c0bd0b3e2fb", 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.IssueCommentContract = armapimanagement.IssueCommentContract{ - // Name: to.Ptr("599e29ab193c3c0bd0b3e2fb"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues/comments"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc/comments/599e29ab193c3c0bd0b3e2fb"), - // Properties: &armapimanagement.IssueCommentContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // Text: to.Ptr("Issue comment."), - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiIssueComment.json -func ExampleAPIIssueCommentClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIIssueCommentClient().CreateOrUpdate(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "57d2ef278aa04f0ad01d6cdc", "599e29ab193c3c0bd0b3e2fb", armapimanagement.IssueCommentContract{ - Properties: &armapimanagement.IssueCommentContractProperties{ - CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t }()), - Text: to.Ptr("Issue comment."), - UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - }, - }, &armapimanagement.APIIssueCommentClientCreateOrUpdateOptions{IfMatch: 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.IssueCommentContract = armapimanagement.IssueCommentContract{ - // Name: to.Ptr("599e29ab193c3c0bd0b3e2fb"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/issues/comments"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/issues/57d2ef278aa04f0ad01d6cdc/comments/599e29ab193c3c0bd0b3e2fb"), - // Properties: &armapimanagement.IssueCommentContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // Text: to.Ptr("Issue comment."), - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiIssueComment.json -func ExampleAPIIssueCommentClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIIssueCommentClient().Delete(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "57d2ef278aa04f0ad01d6cdc", "599e29ab193c3c0bd0b3e2fb", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimapis_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimapis_live_test.go index 3a9208eca241..7334ba4e25c6 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimapis_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimapis_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimapiversionsets_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimapiversionsets_live_test.go index ad166c423537..84d9f121a4aa 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimapiversionsets_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimapiversionsets_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimauthorizationservers_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimauthorizationservers_live_test.go index 53d87551e1ae..d6a85fdb1b39 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimauthorizationservers_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimauthorizationservers_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimcaches_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimcaches_live_test.go index 7769b3edaf46..5fe0b9f44dad 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimcaches_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimcaches_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimdeployment_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimdeployment_live_test.go index 00ea15c99d18..f4f7a83b9419 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimdeployment_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimdeployment_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimgateways_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimgateways_live_test.go index 509584393039..e1d667457d2c 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimgateways_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimgateways_live_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimgroups_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimgroups_live_test.go index c9c06b2a4aad..7c46dbe6c595 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimgroups_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimgroups_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimidentityprovider_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimidentityprovider_live_test.go index 5a6763b95444..f8d552c7a999 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimidentityprovider_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimidentityprovider_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimnamedvalues_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimnamedvalues_live_test.go index 394e5d4bf386..096c19327d36 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimnamedvalues_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimnamedvalues_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimnotifications_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimnotifications_live_test.go index a6d6aeac09fa..1852e3e4f61a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimnotifications_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimnotifications_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimopenidconnectproviders_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimopenidconnectproviders_live_test.go index 1dd3d9932031..58175a623328 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimopenidconnectproviders_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimopenidconnectproviders_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimpolicies_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimpolicies_live_test.go index 628781c1142a..fd379bc383c2 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimpolicies_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimpolicies_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimportalrevisions_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimportalrevisions_live_test.go index dc65b5f299fc..ccde619ee8c1 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimportalrevisions_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimportalrevisions_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimportalsettings_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimportalsettings_live_test.go index 3a8623fa325c..1d314c3da214 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimportalsettings_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimportalsettings_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimprivatelink_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimprivatelink_live_test.go index 0a2375415d93..1948e14681b3 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimprivatelink_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimprivatelink_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimproducts_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimproducts_live_test.go index 03d13a4189fd..31b2293f293a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimproducts_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimproducts_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimreports_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimreports_live_test.go index 23935ef40a41..1aa144ce1532 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimreports_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimreports_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimschema_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimschema_live_test.go index b7fa76b307d1..848ebcd0cf84 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimschema_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimschema_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimsubscriptions_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimsubscriptions_live_test.go index 29f88de853ed..c7695becd090 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimsubscriptions_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimsubscriptions_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimtags_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimtags_live_test.go index 47124ee874b8..184395a8546f 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimtags_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimtags_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimtenant_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimtenant_live_test.go index b36e07cb681a..e027e4ca706a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimtenant_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimtenant_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apimusers_live_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apimusers_live_test.go index 96861455ff80..e4a98c5899de 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apimusers_live_test.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apimusers_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apioperation_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apioperation_client.go index e4965abbc676..c3e76b8cc282 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apioperation_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apioperation_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIOperationClient struct { } // NewAPIOperationClient creates a new instance of APIOperationClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIOperationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIOperationClient, error) { @@ -47,7 +44,7 @@ func NewAPIOperationClient(subscriptionID string, credential azcore.TokenCredent // CreateOrUpdate - Creates a new operation in the API or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -106,12 +103,12 @@ func (client *APIOperationClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -133,7 +130,7 @@ func (client *APIOperationClient) createOrUpdateHandleResponse(resp *http.Respon // Delete - Deletes the specified operation in the API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -164,7 +161,7 @@ func (client *APIOperationClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *APIOperationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string, options *APIOperationClientDeleteOptions) (*policy.Request, error) { +func (client *APIOperationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string, _ *APIOperationClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -191,17 +188,17 @@ func (client *APIOperationClient) deleteCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the API Operation specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -231,7 +228,7 @@ func (client *APIOperationClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *APIOperationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *APIOperationClientGetOptions) (*policy.Request, error) { +func (client *APIOperationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, _ *APIOperationClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -258,7 +255,7 @@ func (client *APIOperationClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -278,7 +275,7 @@ func (client *APIOperationClient) getHandleResponse(resp *http.Response) (APIOpe // GetEntityTag - Gets the entity state (Etag) version of the API operation specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -309,7 +306,7 @@ func (client *APIOperationClient) GetEntityTag(ctx context.Context, resourceGrou } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIOperationClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *APIOperationClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIOperationClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, _ *APIOperationClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -336,7 +333,7 @@ func (client *APIOperationClient) getEntityTagCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -353,7 +350,7 @@ func (client *APIOperationClient) getEntityTagHandleResponse(resp *http.Response // NewListByAPIPager - Lists a collection of the operations for the specified API. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -410,16 +407,16 @@ func (client *APIOperationClient) listByAPICreateRequest(ctx context.Context, re if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Tags != nil { reqQP.Set("tags", *options.Tags) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -437,7 +434,7 @@ func (client *APIOperationClient) listByAPIHandleResponse(resp *http.Response) ( // Update - Updates the details of the operation in the API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -470,7 +467,7 @@ func (client *APIOperationClient) Update(ctx context.Context, resourceGroupName } // updateCreateRequest creates the Update request. -func (client *APIOperationClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string, parameters OperationUpdateContract, options *APIOperationClientUpdateOptions) (*policy.Request, error) { +func (client *APIOperationClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string, parameters OperationUpdateContract, _ *APIOperationClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -497,10 +494,10 @@ func (client *APIOperationClient) updateCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apioperation_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apioperation_client_example_test.go deleted file mode 100644 index 768b215065a9..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apioperation_client_example_test.go +++ /dev/null @@ -1,476 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiOperations.json -func ExampleAPIOperationClient_NewListByAPIPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIOperationClient().NewListByAPIPager("rg1", "apimService1", "57d2ef278aa04f0888cba3f3", &armapimanagement.APIOperationClientListByAPIOptions{Filter: nil, - Top: nil, - Skip: nil, - Tags: 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.OperationCollection = armapimanagement.OperationCollection{ - // Count: to.Ptr[int64](5), - // Value: []*armapimanagement.OperationContract{ - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/operations/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.OperationContractProperties{ - // Method: to.Ptr("POST"), - // DisplayName: to.Ptr("CancelOrder"), - // URLTemplate: to.Ptr("/?soapAction=http://tempuri.org/IFazioService/CancelOrder"), - // }, - // }, - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cda"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/operations/57d2ef278aa04f0ad01d6cda"), - // Properties: &armapimanagement.OperationContractProperties{ - // Method: to.Ptr("POST"), - // DisplayName: to.Ptr("GetMostRecentOrder"), - // URLTemplate: to.Ptr("/?soapAction=http://tempuri.org/IFazioService/GetMostRecentOrder"), - // }, - // }, - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cd9"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/operations/57d2ef278aa04f0ad01d6cd9"), - // Properties: &armapimanagement.OperationContractProperties{ - // Method: to.Ptr("POST"), - // DisplayName: to.Ptr("GetOpenOrders"), - // URLTemplate: to.Ptr("/?soapAction=http://tempuri.org/IFazioService/GetOpenOrders"), - // }, - // }, - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdb"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/operations/57d2ef278aa04f0ad01d6cdb"), - // Properties: &armapimanagement.OperationContractProperties{ - // Method: to.Ptr("POST"), - // DisplayName: to.Ptr("GetOrder"), - // URLTemplate: to.Ptr("/?soapAction=http://tempuri.org/IFazioService/GetOrder"), - // }, - // }, - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cd8"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/operations/57d2ef278aa04f0ad01d6cd8"), - // Properties: &armapimanagement.OperationContractProperties{ - // Method: to.Ptr("POST"), - // DisplayName: to.Ptr("submitOrder"), - // URLTemplate: to.Ptr("/?soapAction=http://tempuri.org/IFazioService/submitOrder"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiOperation.json -func ExampleAPIOperationClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIOperationClient().GetEntityTag(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiOperation.json -func ExampleAPIOperationClient_Get_apiManagementGetApiOperation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIOperationClient().Get(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", 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.OperationContract = armapimanagement.OperationContract{ - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/operations/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.OperationContractProperties{ - // TemplateParameters: []*armapimanagement.ParameterContract{ - // }, - // Request: &armapimanagement.RequestContract{ - // Description: to.Ptr("IFazioService_CancelOrder_InputMessage"), - // Headers: []*armapimanagement.ParameterContract{ - // }, - // QueryParameters: []*armapimanagement.ParameterContract{ - // }, - // Representations: []*armapimanagement.RepresentationContract{ - // { - // ContentType: to.Ptr("text/xml"), - // SchemaID: to.Ptr("6980a395-f08b-4a59-8295-1440cbd909b8"), - // TypeName: to.Ptr("CancelOrder"), - // }}, - // }, - // Responses: []*armapimanagement.ResponseContract{ - // { - // Description: to.Ptr("IFazioService_CancelOrder_OutputMessage"), - // Headers: []*armapimanagement.ParameterContract{ - // }, - // Representations: []*armapimanagement.RepresentationContract{ - // { - // ContentType: to.Ptr("text/xml"), - // SchemaID: to.Ptr("6980a395-f08b-4a59-8295-1440cbd909b8"), - // TypeName: to.Ptr("CancelOrderResponse"), - // }}, - // StatusCode: to.Ptr[int32](200), - // }}, - // Method: to.Ptr("POST"), - // DisplayName: to.Ptr("CancelOrder"), - // URLTemplate: to.Ptr("/?soapAction=http://tempuri.org/IFazioService/CancelOrder"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiOperationPetStore.json -func ExampleAPIOperationClient_Get_apiManagementGetApiOperationPetStore() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIOperationClient().Get(ctx, "rg1", "apimService1", "swagger-petstore", "loginUser", 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.OperationContract = armapimanagement.OperationContract{ - // Name: to.Ptr("loginUser"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/swagger-petstore/operations/loginUser"), - // Properties: &armapimanagement.OperationContractProperties{ - // Description: to.Ptr(""), - // TemplateParameters: []*armapimanagement.ParameterContract{ - // { - // Name: to.Ptr("username"), - // Type: to.Ptr("string"), - // Description: to.Ptr("The user name for login"), - // Required: to.Ptr(true), - // Values: []*string{ - // }, - // }, - // { - // Name: to.Ptr("password"), - // Type: to.Ptr("string"), - // Description: to.Ptr("The password for login in clear text"), - // Required: to.Ptr(true), - // Values: []*string{ - // }, - // }}, - // Request: &armapimanagement.RequestContract{ - // Headers: []*armapimanagement.ParameterContract{ - // }, - // QueryParameters: []*armapimanagement.ParameterContract{ - // }, - // Representations: []*armapimanagement.RepresentationContract{ - // }, - // }, - // Responses: []*armapimanagement.ResponseContract{ - // { - // Description: to.Ptr("successful operation"), - // Headers: []*armapimanagement.ParameterContract{ - // { - // Name: to.Ptr("X-Rate-Limit"), - // Type: to.Ptr("integer"), - // Description: to.Ptr("calls per hour allowed by the user"), - // Values: []*string{ - // }, - // }, - // { - // Name: to.Ptr("X-Expires-After"), - // Type: to.Ptr("string"), - // Description: to.Ptr("date in UTC when token expires"), - // Values: []*string{ - // }, - // }}, - // Representations: []*armapimanagement.RepresentationContract{ - // { - // ContentType: to.Ptr("application/xml"), - // SchemaID: to.Ptr("5ba91a35f373b513a0bf31c6"), - // TypeName: to.Ptr("UserLoginGet200ApplicationXmlResponse"), - // }, - // { - // ContentType: to.Ptr("application/json"), - // SchemaID: to.Ptr("5ba91a35f373b513a0bf31c6"), - // TypeName: to.Ptr("UserLoginGet200ApplicationJsonResponse"), - // }}, - // StatusCode: to.Ptr[int32](200), - // }, - // { - // Description: to.Ptr("Invalid username/password supplied"), - // Headers: []*armapimanagement.ParameterContract{ - // }, - // Representations: []*armapimanagement.RepresentationContract{ - // { - // ContentType: to.Ptr("application/xml"), - // }, - // { - // ContentType: to.Ptr("application/json"), - // }}, - // StatusCode: to.Ptr[int32](400), - // }}, - // Method: to.Ptr("GET"), - // DisplayName: to.Ptr("Logs user into the system"), - // URLTemplate: to.Ptr("/user/login?username={username}&password={password}"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiOperation.json -func ExampleAPIOperationClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIOperationClient().CreateOrUpdate(ctx, "rg1", "apimService1", "PetStoreTemplate2", "newoperations", armapimanagement.OperationContract{ - Properties: &armapimanagement.OperationContractProperties{ - Description: to.Ptr("This can only be done by the logged in user."), - TemplateParameters: []*armapimanagement.ParameterContract{}, - Request: &armapimanagement.RequestContract{ - Description: to.Ptr("Created user object"), - Headers: []*armapimanagement.ParameterContract{}, - QueryParameters: []*armapimanagement.ParameterContract{}, - Representations: []*armapimanagement.RepresentationContract{ - { - ContentType: to.Ptr("application/json"), - SchemaID: to.Ptr("592f6c1d0af5840ca8897f0c"), - TypeName: to.Ptr("User"), - }}, - }, - Responses: []*armapimanagement.ResponseContract{ - { - Description: to.Ptr("successful operation"), - Headers: []*armapimanagement.ParameterContract{}, - Representations: []*armapimanagement.RepresentationContract{ - { - ContentType: to.Ptr("application/xml"), - }, - { - ContentType: to.Ptr("application/json"), - }}, - StatusCode: to.Ptr[int32](200), - }}, - Method: to.Ptr("POST"), - DisplayName: to.Ptr("createUser2"), - URLTemplate: to.Ptr("/user1"), - }, - }, &armapimanagement.APIOperationClientCreateOrUpdateOptions{IfMatch: 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.OperationContract = armapimanagement.OperationContract{ - // Name: to.Ptr("newoperations"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/PetStoreTemplate2/operations/newoperations"), - // Properties: &armapimanagement.OperationContractProperties{ - // Description: to.Ptr("This can only be done by the logged in user."), - // TemplateParameters: []*armapimanagement.ParameterContract{ - // }, - // Request: &armapimanagement.RequestContract{ - // Description: to.Ptr("Created user object"), - // Headers: []*armapimanagement.ParameterContract{ - // }, - // QueryParameters: []*armapimanagement.ParameterContract{ - // }, - // Representations: []*armapimanagement.RepresentationContract{ - // { - // ContentType: to.Ptr("application/json"), - // SchemaID: to.Ptr("592f6c1d0af5840ca8897f0c"), - // TypeName: to.Ptr("User"), - // }}, - // }, - // Responses: []*armapimanagement.ResponseContract{ - // { - // Description: to.Ptr("successful operation"), - // Headers: []*armapimanagement.ParameterContract{ - // }, - // Representations: []*armapimanagement.RepresentationContract{ - // { - // ContentType: to.Ptr("application/xml"), - // }, - // { - // ContentType: to.Ptr("application/json"), - // }}, - // StatusCode: to.Ptr[int32](200), - // }}, - // Method: to.Ptr("POST"), - // DisplayName: to.Ptr("createUser2"), - // URLTemplate: to.Ptr("/user1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiOperation.json -func ExampleAPIOperationClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIOperationClient().Update(ctx, "rg1", "apimService1", "echo-api", "operationId", "*", armapimanagement.OperationUpdateContract{ - Properties: &armapimanagement.OperationUpdateContractProperties{ - TemplateParameters: []*armapimanagement.ParameterContract{}, - Request: &armapimanagement.RequestContract{ - QueryParameters: []*armapimanagement.ParameterContract{ - { - Name: to.Ptr("param1"), - Type: to.Ptr("string"), - Description: to.Ptr("A sample parameter that is required and has a default value of \"sample\"."), - DefaultValue: to.Ptr("sample"), - Required: to.Ptr(true), - Values: []*string{ - to.Ptr("sample")}, - }}, - }, - Responses: []*armapimanagement.ResponseContract{ - { - Description: to.Ptr("Returned in all cases."), - Headers: []*armapimanagement.ParameterContract{}, - Representations: []*armapimanagement.RepresentationContract{}, - StatusCode: to.Ptr[int32](200), - }, - { - Description: to.Ptr("Server Error."), - Headers: []*armapimanagement.ParameterContract{}, - Representations: []*armapimanagement.RepresentationContract{}, - StatusCode: to.Ptr[int32](500), - }}, - Method: to.Ptr("GET"), - DisplayName: to.Ptr("Retrieve resource"), - URLTemplate: to.Ptr("/resource"), - }, - }, 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.OperationContract = armapimanagement.OperationContract{ - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/operations/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.OperationContractProperties{ - // TemplateParameters: []*armapimanagement.ParameterContract{ - // }, - // Request: &armapimanagement.RequestContract{ - // Description: to.Ptr("IFazioService_CancelOrder_InputMessage"), - // Headers: []*armapimanagement.ParameterContract{ - // }, - // QueryParameters: []*armapimanagement.ParameterContract{ - // }, - // Representations: []*armapimanagement.RepresentationContract{ - // { - // ContentType: to.Ptr("text/xml"), - // SchemaID: to.Ptr("6980a395-f08b-4a59-8295-1440cbd909b8"), - // TypeName: to.Ptr("CancelOrder"), - // }}, - // }, - // Responses: []*armapimanagement.ResponseContract{ - // { - // Description: to.Ptr("IFazioService_CancelOrder_OutputMessage"), - // Headers: []*armapimanagement.ParameterContract{ - // }, - // Representations: []*armapimanagement.RepresentationContract{ - // { - // ContentType: to.Ptr("text/xml"), - // SchemaID: to.Ptr("6980a395-f08b-4a59-8295-1440cbd909b8"), - // TypeName: to.Ptr("CancelOrderResponse"), - // }}, - // StatusCode: to.Ptr[int32](200), - // }}, - // Method: to.Ptr("POST"), - // DisplayName: to.Ptr("CancelOrder"), - // URLTemplate: to.Ptr("/?soapAction=http://tempuri.org/IFazioService/CancelOrder"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiOperation.json -func ExampleAPIOperationClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIOperationClient().Delete(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apioperationpolicy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apioperationpolicy_client.go index d52e7337c9e1..3440cff3fb31 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apioperationpolicy_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apioperationpolicy_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type APIOperationPolicyClient struct { } // NewAPIOperationPolicyClient creates a new instance of APIOperationPolicyClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIOperationPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIOperationPolicyClient, error) { @@ -46,7 +43,7 @@ func NewAPIOperationPolicyClient(subscriptionID string, credential azcore.TokenC // CreateOrUpdate - Creates or updates policy configuration for the API Operation level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -110,12 +107,12 @@ func (client *APIOperationPolicyClient) createOrUpdateCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -137,7 +134,7 @@ func (client *APIOperationPolicyClient) createOrUpdateHandleResponse(resp *http. // Delete - Deletes the policy configuration at the Api Operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -170,7 +167,7 @@ func (client *APIOperationPolicyClient) Delete(ctx context.Context, resourceGrou } // deleteCreateRequest creates the Delete request. -func (client *APIOperationPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, ifMatch string, options *APIOperationPolicyClientDeleteOptions) (*policy.Request, error) { +func (client *APIOperationPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, ifMatch string, _ *APIOperationPolicyClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -201,17 +198,17 @@ func (client *APIOperationPolicyClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Get the policy configuration at the API Operation level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -273,10 +270,10 @@ func (client *APIOperationPolicyClient) getCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Format != nil { reqQP.Set("format", string(*options.Format)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -296,7 +293,7 @@ func (client *APIOperationPolicyClient) getHandleResponse(resp *http.Response) ( // GetEntityTag - Gets the entity state (Etag) version of the API operation policy specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -328,7 +325,7 @@ func (client *APIOperationPolicyClient) GetEntityTag(ctx context.Context, resour } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIOperationPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, options *APIOperationPolicyClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIOperationPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, _ *APIOperationPolicyClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -359,7 +356,7 @@ func (client *APIOperationPolicyClient) getEntityTagCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -377,7 +374,7 @@ func (client *APIOperationPolicyClient) getEntityTagHandleResponse(resp *http.Re // ListByOperation - Get the list of policy configuration at the API Operation level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -408,7 +405,7 @@ func (client *APIOperationPolicyClient) ListByOperation(ctx context.Context, res } // listByOperationCreateRequest creates the ListByOperation request. -func (client *APIOperationPolicyClient) listByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *APIOperationPolicyClientListByOperationOptions) (*policy.Request, error) { +func (client *APIOperationPolicyClient) listByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, _ *APIOperationPolicyClientListByOperationOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -435,7 +432,7 @@ func (client *APIOperationPolicyClient) listByOperationCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apioperationpolicy_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apioperationpolicy_client_example_test.go deleted file mode 100644 index fd7519fc67ca..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apioperationpolicy_client_example_test.go +++ /dev/null @@ -1,146 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiOperationPolicies.json -func ExampleAPIOperationPolicyClient_ListByOperation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIOperationPolicyClient().ListByOperation(ctx, "rg1", "apimService1", "599e2953193c3c0bd0b3e2fa", "599e29ab193c3c0bd0b3e2fb", 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.PolicyCollection = armapimanagement.PolicyCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.PolicyContract{ - // { - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/599e2953193c3c0bd0b3e2fa/operations/599e29ab193c3c0bd0b3e2fb/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n\r\n \r\n \r\n \r\n \r\n xxx\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiOperationPolicy.json -func ExampleAPIOperationPolicyClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIOperationPolicyClient().GetEntityTag(ctx, "rg1", "apimService1", "5600b539c53f5b0062040001", "5600b53ac53f5b0062080006", armapimanagement.PolicyIDNamePolicy, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiOperationPolicy.json -func ExampleAPIOperationPolicyClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIOperationPolicyClient().Get(ctx, "rg1", "apimService1", "5600b539c53f5b0062040001", "5600b53ac53f5b0062080006", armapimanagement.PolicyIDNamePolicy, &armapimanagement.APIOperationPolicyClientGetOptions{Format: 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b539c53f5b0062040001/operations/5600b53ac53f5b0062080006/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n This is a sample\r\n \r\n \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiOperationPolicy.json -func ExampleAPIOperationPolicyClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIOperationPolicyClient().CreateOrUpdate(ctx, "rg1", "apimService1", "5600b57e7e8880006a040001", "5600b57e7e8880006a080001", armapimanagement.PolicyIDNamePolicy, armapimanagement.PolicyContract{ - Properties: &armapimanagement.PolicyContractProperties{ - Format: to.Ptr(armapimanagement.PolicyContentFormatXML), - Value: to.Ptr(" "), - }, - }, &armapimanagement.APIOperationPolicyClientCreateOrUpdateOptions{IfMatch: to.Ptr("*")}) - 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b57e7e8880006a040001/operations/5600b57e7e8880006a080001/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiOperationPolicy.json -func ExampleAPIOperationPolicyClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIOperationPolicyClient().Delete(ctx, "rg1", "apimService1", "testapi", "testoperation", armapimanagement.PolicyIDNamePolicy, "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apipolicy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apipolicy_client.go index ce6bce491521..8bd514b52f5a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apipolicy_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apipolicy_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type APIPolicyClient struct { } // NewAPIPolicyClient creates a new instance of APIPolicyClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIPolicyClient, error) { @@ -46,7 +43,7 @@ func NewAPIPolicyClient(subscriptionID string, credential azcore.TokenCredential // CreateOrUpdate - Creates or updates policy configuration for the API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -105,12 +102,12 @@ func (client *APIPolicyClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -132,7 +129,7 @@ func (client *APIPolicyClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Deletes the policy configuration at the Api. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -163,7 +160,7 @@ func (client *APIPolicyClient) Delete(ctx context.Context, resourceGroupName str } // deleteCreateRequest creates the Delete request. -func (client *APIPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, ifMatch string, options *APIPolicyClientDeleteOptions) (*policy.Request, error) { +func (client *APIPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, ifMatch string, _ *APIPolicyClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -190,17 +187,17 @@ func (client *APIPolicyClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Get the policy configuration at the API level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -257,10 +254,10 @@ func (client *APIPolicyClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Format != nil { reqQP.Set("format", string(*options.Format)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml"} return req, nil @@ -280,7 +277,7 @@ func (client *APIPolicyClient) getHandleResponse(resp *http.Response) (APIPolicy // GetEntityTag - Gets the entity state (Etag) version of the API policy specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -310,7 +307,7 @@ func (client *APIPolicyClient) GetEntityTag(ctx context.Context, resourceGroupNa } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, options *APIPolicyClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, _ *APIPolicyClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -337,7 +334,7 @@ func (client *APIPolicyClient) getEntityTagCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -355,7 +352,7 @@ func (client *APIPolicyClient) getEntityTagHandleResponse(resp *http.Response) ( // ListByAPI - Get the policy configuration at the API level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -384,7 +381,7 @@ func (client *APIPolicyClient) ListByAPI(ctx context.Context, resourceGroupName } // listByAPICreateRequest creates the ListByAPI request. -func (client *APIPolicyClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIPolicyClientListByAPIOptions) (*policy.Request, error) { +func (client *APIPolicyClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, _ *APIPolicyClientListByAPIOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -407,7 +404,7 @@ func (client *APIPolicyClient) listByAPICreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apipolicy_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apipolicy_client_example_test.go deleted file mode 100644 index 4fb8cbd527b9..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apipolicy_client_example_test.go +++ /dev/null @@ -1,179 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiPolicies.json -func ExampleAPIPolicyClient_ListByAPI() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIPolicyClient().ListByAPI(ctx, "rg1", "apimService1", "5600b59475ff190048040001", 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.PolicyCollection = armapimanagement.PolicyCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.PolicyContract{ - // { - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b59475ff190048040001/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n@{\r\n Random Random = new Random();\r\n const string Chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \"; \r\n return string.Join(\",\", DateTime.UtcNow, new string(\r\n Enumerable.Repeat(Chars, Random.Next(2150400))\r\n .Select(s => s[Random.Next(s.Length)])\r\n .ToArray()));\r\n } \r\n \r\n \r\n \r\n"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiPolicy.json -func ExampleAPIPolicyClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIPolicyClient().GetEntityTag(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", armapimanagement.PolicyIDNamePolicy, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiPolicy.json -func ExampleAPIPolicyClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIPolicyClient().Get(ctx, "rg1", "apimService1", "5600b59475ff190048040001", armapimanagement.PolicyIDNamePolicy, &armapimanagement.APIPolicyClientGetOptions{Format: 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b59475ff190048040001/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n@{\r\n Random Random = new Random();\r\n const string Chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \"; \r\n return string.Join(\",\", DateTime.UtcNow, new string(\r\n Enumerable.Repeat(Chars, Random.Next(2150400))\r\n .Select(s => s[Random.Next(s.Length)])\r\n .ToArray()));\r\n } \r\n \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiPolicy.json -func ExampleAPIPolicyClient_CreateOrUpdate_apiManagementCreateApiPolicy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIPolicyClient().CreateOrUpdate(ctx, "rg1", "apimService1", "5600b57e7e8880006a040001", armapimanagement.PolicyIDNamePolicy, armapimanagement.PolicyContract{ - Properties: &armapimanagement.PolicyContractProperties{ - Format: to.Ptr(armapimanagement.PolicyContentFormatXML), - Value: to.Ptr(" "), - }, - }, &armapimanagement.APIPolicyClientCreateOrUpdateOptions{IfMatch: to.Ptr("*")}) - 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b57e7e8880006a040001/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiPolicyNonXmlEncoded.json -func ExampleAPIPolicyClient_CreateOrUpdate_apiManagementCreateApiPolicyNonXmlEncoded() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIPolicyClient().CreateOrUpdate(ctx, "rg1", "apimService1", "5600b57e7e8880006a040001", armapimanagement.PolicyIDNamePolicy, armapimanagement.PolicyContract{ - Properties: &armapimanagement.PolicyContractProperties{ - Format: to.Ptr(armapimanagement.PolicyContentFormatRawxml), - Value: to.Ptr("\r\n \r\n \r\n \r\n \"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" \r\n \r\n \r\n "), - }, - }, &armapimanagement.APIPolicyClientCreateOrUpdateOptions{IfMatch: to.Ptr("*")}) - 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/operations/policies"), - // ID: to.Ptr("/subscriptions/4c1a3bc6-89f9-46fe-a175-5d8984b25095/resourcegroups/Api-DF-West-US/providers/Microsoft.ApiManagement/service/samirmsiservice2/apis/echo-api/operations/create-resource/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiPolicy.json -func ExampleAPIPolicyClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIPolicyClient().Delete(ctx, "rg1", "apimService1", "loggerId", armapimanagement.PolicyIDNamePolicy, "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiproduct_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiproduct_client.go index 8312fb2f2ea5..a9a70d5dce61 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiproduct_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apiproduct_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIProductClient struct { } // NewAPIProductClient creates a new instance of APIProductClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIProductClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIProductClient, error) { @@ -46,7 +43,7 @@ func NewAPIProductClient(subscriptionID string, credential azcore.TokenCredentia // NewListByApisPager - Lists all Products, which the API is part of. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -102,13 +99,13 @@ func (client *APIProductClient) listByApisCreateRequest(ctx context.Context, res if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiproduct_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiproduct_client_example_test.go deleted file mode 100644 index cbe00708a38c..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiproduct_client_example_test.go +++ /dev/null @@ -1,63 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiProducts.json -func ExampleAPIProductClient_NewListByApisPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIProductClient().NewListByApisPager("rg1", "apimService1", "57d2ef278aa04f0888cba3f3", &armapimanagement.APIProductClientListByApisOptions{Filter: nil, - Top: nil, - Skip: 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.ProductCollection = armapimanagement.ProductCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.ProductContract{ - // { - // Name: to.Ptr("5600b539c53f5b0062060002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/products"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b539c53f5b0062060002"), - // Properties: &armapimanagement.ProductContractProperties{ - // Description: to.Ptr("Subscribers have completely unlimited access to the API. Administrator approval is required."), - // ApprovalRequired: to.Ptr(true), - // State: to.Ptr(armapimanagement.ProductStatePublished), - // SubscriptionRequired: to.Ptr(true), - // SubscriptionsLimit: to.Ptr[int32](1), - // DisplayName: to.Ptr("Unlimited"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apirelease_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apirelease_client.go index 1b31e14b802a..bd4ad456989d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apirelease_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apirelease_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIReleaseClient struct { } // NewAPIReleaseClient creates a new instance of APIReleaseClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIReleaseClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIReleaseClient, error) { @@ -47,7 +44,7 @@ func NewAPIReleaseClient(subscriptionID string, credential azcore.TokenCredentia // CreateOrUpdate - Creates a new Release for the API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -105,12 +102,12 @@ func (client *APIReleaseClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -132,7 +129,7 @@ func (client *APIReleaseClient) createOrUpdateHandleResponse(resp *http.Response // Delete - Deletes the specified release in the API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -162,7 +159,7 @@ func (client *APIReleaseClient) Delete(ctx context.Context, resourceGroupName st } // deleteCreateRequest creates the Delete request. -func (client *APIReleaseClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, ifMatch string, options *APIReleaseClientDeleteOptions) (*policy.Request, error) { +func (client *APIReleaseClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, ifMatch string, _ *APIReleaseClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -189,17 +186,17 @@ func (client *APIReleaseClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Returns the details of an API release. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -228,7 +225,7 @@ func (client *APIReleaseClient) Get(ctx context.Context, resourceGroupName strin } // getCreateRequest creates the Get request. -func (client *APIReleaseClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, options *APIReleaseClientGetOptions) (*policy.Request, error) { +func (client *APIReleaseClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, _ *APIReleaseClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -255,7 +252,7 @@ func (client *APIReleaseClient) getCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -275,7 +272,7 @@ func (client *APIReleaseClient) getHandleResponse(resp *http.Response) (APIRelea // GetEntityTag - Returns the etag of an API release. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -304,7 +301,7 @@ func (client *APIReleaseClient) GetEntityTag(ctx context.Context, resourceGroupN } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIReleaseClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, options *APIReleaseClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIReleaseClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, _ *APIReleaseClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -331,7 +328,7 @@ func (client *APIReleaseClient) getEntityTagCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -350,7 +347,7 @@ func (client *APIReleaseClient) getEntityTagHandleResponse(resp *http.Response) // are also used to rollback to previous revisions. Results will be paged and can be constrained by // the $top and $skip parameters. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -406,13 +403,13 @@ func (client *APIReleaseClient) listByServiceCreateRequest(ctx context.Context, if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -430,7 +427,7 @@ func (client *APIReleaseClient) listByServiceHandleResponse(resp *http.Response) // Update - Updates the details of the release of the API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -462,7 +459,7 @@ func (client *APIReleaseClient) Update(ctx context.Context, resourceGroupName st } // updateCreateRequest creates the Update request. -func (client *APIReleaseClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, ifMatch string, parameters APIReleaseContract, options *APIReleaseClientUpdateOptions) (*policy.Request, error) { +func (client *APIReleaseClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, ifMatch string, parameters APIReleaseContract, _ *APIReleaseClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -489,10 +486,10 @@ func (client *APIReleaseClient) updateCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apirelease_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apirelease_client_example_test.go deleted file mode 100644 index d4f700512cfa..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apirelease_client_example_test.go +++ /dev/null @@ -1,198 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiReleases.json -func ExampleAPIReleaseClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIReleaseClient().NewListByServicePager("rg1", "apimService1", "a1", &armapimanagement.APIReleaseClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.APIReleaseCollection = armapimanagement.APIReleaseCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.APIReleaseContract{ - // { - // Name: to.Ptr("5a7cb545298324c53224a799"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/releases"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1/releases/5a7cb545298324c53224a799"), - // Properties: &armapimanagement.APIReleaseContractProperties{ - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T20:38:29.173Z"); return t}()), - // Notes: to.Ptr("yahoo"), - // UpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T20:38:29.173Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiRelease.json -func ExampleAPIReleaseClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIReleaseClient().GetEntityTag(ctx, "rg1", "apimService1", "a1", "5a7cb545298324c53224a799", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiRelease.json -func ExampleAPIReleaseClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIReleaseClient().Get(ctx, "rg1", "apimService1", "a1", "5a7cb545298324c53224a799", 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.APIReleaseContract = armapimanagement.APIReleaseContract{ - // Name: to.Ptr("5a7cb545298324c53224a799"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/releases"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1/releases/5a7cb545298324c53224a799"), - // Properties: &armapimanagement.APIReleaseContractProperties{ - // APIID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1"), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T20:38:29.173Z"); return t}()), - // Notes: to.Ptr("yahoo"), - // UpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T20:38:29.173Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiRelease.json -func ExampleAPIReleaseClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIReleaseClient().CreateOrUpdate(ctx, "rg1", "apimService1", "a1", "testrev", armapimanagement.APIReleaseContract{ - Properties: &armapimanagement.APIReleaseContractProperties{ - APIID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1"), - Notes: to.Ptr("yahooagain"), - }, - }, &armapimanagement.APIReleaseClientCreateOrUpdateOptions{IfMatch: 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.APIReleaseContract = armapimanagement.APIReleaseContract{ - // Name: to.Ptr("testrev"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/releases"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1/releases/testrev"), - // Properties: &armapimanagement.APIReleaseContractProperties{ - // APIID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1"), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T20:52:00.650Z"); return t}()), - // Notes: to.Ptr("yahooagain"), - // UpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T20:52:00.650Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiRelease.json -func ExampleAPIReleaseClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIReleaseClient().Update(ctx, "rg1", "apimService1", "a1", "testrev", "*", armapimanagement.APIReleaseContract{ - Properties: &armapimanagement.APIReleaseContractProperties{ - APIID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1"), - Notes: to.Ptr("yahooagain"), - }, - }, 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.APIReleaseContract = armapimanagement.APIReleaseContract{ - // Name: to.Ptr("testrev"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/releases"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1/releases/testrev"), - // Properties: &armapimanagement.APIReleaseContractProperties{ - // APIID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1"), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T20:38:29.173Z"); return t}()), - // Notes: to.Ptr("yahoo"), - // UpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T20:38:29.173Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiRelease.json -func ExampleAPIReleaseClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIReleaseClient().Delete(ctx, "rg1", "apimService1", "5a5fcc09124a7fa9b89f2f1d", "testrev", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apirevision_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apirevision_client.go index 61bd0d148131..0f14446ae91d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apirevision_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apirevision_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIRevisionClient struct { } // NewAPIRevisionClient creates a new instance of APIRevisionClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIRevisionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIRevisionClient, error) { @@ -46,7 +43,7 @@ func NewAPIRevisionClient(subscriptionID string, credential azcore.TokenCredenti // NewListByServicePager - Lists all revisions of an API. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -102,13 +99,13 @@ func (client *APIRevisionClient) listByServiceCreateRequest(ctx context.Context, if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apirevision_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apirevision_client_example_test.go deleted file mode 100644 index 7f4a0b2e9d03..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apirevision_client_example_test.go +++ /dev/null @@ -1,58 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiRevisions.json -func ExampleAPIRevisionClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIRevisionClient().NewListByServicePager("rg1", "apimService1", "57d2ef278aa04f0888cba3f3", &armapimanagement.APIRevisionClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.APIRevisionCollection = armapimanagement.APIRevisionCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.APIRevisionContract{ - // { - // APIID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1;rev=1"), - // APIRevision: to.Ptr("1"), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // IsCurrent: to.Ptr(true), - // IsOnline: to.Ptr(true), - // UpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apischema_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apischema_client.go index f7fd8ddc9a4f..6dca9a363312 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apischema_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apischema_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APISchemaClient struct { } // NewAPISchemaClient creates a new instance of APISchemaClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPISchemaClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APISchemaClient, error) { @@ -47,7 +44,7 @@ func NewAPISchemaClient(subscriptionID string, credential azcore.TokenCredential // BeginCreateOrUpdate - Creates or updates schema configuration for the API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -77,7 +74,7 @@ func (client *APISchemaClient) BeginCreateOrUpdate(ctx context.Context, resource // CreateOrUpdate - Creates or updates schema configuration for the API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *APISchemaClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, parameters SchemaContract, options *APISchemaClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "APISchemaClient.BeginCreateOrUpdate" @@ -92,7 +89,7 @@ func (client *APISchemaClient) createOrUpdate(ctx context.Context, resourceGroup if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -127,12 +124,12 @@ func (client *APISchemaClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -142,7 +139,7 @@ func (client *APISchemaClient) createOrUpdateCreateRequest(ctx context.Context, // Delete - Deletes the schema configuration at the Api. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -200,20 +197,20 @@ func (client *APISchemaClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Get the schema configuration at the API level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -243,7 +240,7 @@ func (client *APISchemaClient) Get(ctx context.Context, resourceGroupName string } // getCreateRequest creates the Get request. -func (client *APISchemaClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, options *APISchemaClientGetOptions) (*policy.Request, error) { +func (client *APISchemaClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, _ *APISchemaClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -270,7 +267,7 @@ func (client *APISchemaClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -290,7 +287,7 @@ func (client *APISchemaClient) getHandleResponse(resp *http.Response) (APISchema // GetEntityTag - Gets the entity state (Etag) version of the schema specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -320,7 +317,7 @@ func (client *APISchemaClient) GetEntityTag(ctx context.Context, resourceGroupNa } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APISchemaClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, options *APISchemaClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APISchemaClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, _ *APISchemaClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -347,7 +344,7 @@ func (client *APISchemaClient) getEntityTagCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -364,7 +361,7 @@ func (client *APISchemaClient) getEntityTagHandleResponse(resp *http.Response) ( // NewListByAPIPager - Get the schema configuration at the API level. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -420,13 +417,13 @@ func (client *APISchemaClient) listByAPICreateRequest(ctx context.Context, resou if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apischema_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apischema_client_example_test.go deleted file mode 100644 index 01ab61e314c3..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apischema_client_example_test.go +++ /dev/null @@ -1,169 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiSchemas.json -func ExampleAPISchemaClient_NewListByAPIPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPISchemaClient().NewListByAPIPager("rg1", "apimService1", "59d5b28d1f7fab116c282650", &armapimanagement.APISchemaClientListByAPIOptions{Filter: nil, - Top: nil, - Skip: 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.SchemaCollection = armapimanagement.SchemaCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.SchemaContract{ - // { - // Name: to.Ptr("59d5b28e1f7fab116402044e"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/schemas"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/59d5b28d1f7fab116c282650/schemas/59d5b28e1f7fab116402044e"), - // Properties: &armapimanagement.SchemaContractProperties{ - // ContentType: to.Ptr("application/vnd.ms-azure-apim.xsd+xml"), - // Document: &armapimanagement.SchemaDocumentProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiSchema.json -func ExampleAPISchemaClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPISchemaClient().GetEntityTag(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "ec12520d-9d48-4e7b-8f39-698ca2ac63f1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiSchema.json -func ExampleAPISchemaClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPISchemaClient().Get(ctx, "rg1", "apimService1", "59d6bb8f1f7fab13dc67ec9b", "ec12520d-9d48-4e7b-8f39-698ca2ac63f1", 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.SchemaContract = armapimanagement.SchemaContract{ - // Name: to.Ptr("ec12520d-9d48-4e7b-8f39-698ca2ac63f1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/schemas"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/59d6bb8f1f7fab13dc67ec9b/schemas/ec12520d-9d48-4e7b-8f39-698ca2ac63f1"), - // Properties: &armapimanagement.SchemaContractProperties{ - // ContentType: to.Ptr("application/vnd.ms-azure-apim.xsd+xml"), - // Document: &armapimanagement.SchemaDocumentProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiSchema.json -func ExampleAPISchemaClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAPISchemaClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "59d6bb8f1f7fab13dc67ec9b", "ec12520d-9d48-4e7b-8f39-698ca2ac63f1", armapimanagement.SchemaContract{ - Properties: &armapimanagement.SchemaContractProperties{ - ContentType: to.Ptr("application/vnd.ms-azure-apim.xsd+xml"), - Document: &armapimanagement.SchemaDocumentProperties{ - Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - }, - }, - }, &armapimanagement.APISchemaClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.SchemaContract = armapimanagement.SchemaContract{ - // Name: to.Ptr("ec12520d-9d48-4e7b-8f39-698ca2ac63f1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/schemas"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/59d6bb8f1f7fab13dc67ec9b/schemas/ec12520d-9d48-4e7b-8f39-698ca2ac63f1"), - // Properties: &armapimanagement.SchemaContractProperties{ - // ContentType: to.Ptr("application/vnd.ms-azure-apim.xsd+xml"), - // Document: &armapimanagement.SchemaDocumentProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiSchema.json -func ExampleAPISchemaClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPISchemaClient().Delete(ctx, "rg1", "apimService1", "59d5b28d1f7fab116c282650", "59d5b28e1f7fab116402044e", "*", &armapimanagement.APISchemaClientDeleteOptions{Force: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apitagdescription_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apitagdescription_client.go index a1a3ac4ff79b..dcabcbc77345 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apitagdescription_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apitagdescription_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APITagDescriptionClient struct { } // NewAPITagDescriptionClient creates a new instance of APITagDescriptionClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPITagDescriptionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APITagDescriptionClient, error) { @@ -47,7 +44,7 @@ func NewAPITagDescriptionClient(subscriptionID string, credential azcore.TokenCr // CreateOrUpdate - Create/Update tag description in scope of the Api. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -107,12 +104,12 @@ func (client *APITagDescriptionClient) createOrUpdateCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -134,7 +131,7 @@ func (client *APITagDescriptionClient) createOrUpdateHandleResponse(resp *http.R // Delete - Delete tag description for the Api. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -167,7 +164,7 @@ func (client *APITagDescriptionClient) Delete(ctx context.Context, resourceGroup } // deleteCreateRequest creates the Delete request. -func (client *APITagDescriptionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, ifMatch string, options *APITagDescriptionClientDeleteOptions) (*policy.Request, error) { +func (client *APITagDescriptionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, ifMatch string, _ *APITagDescriptionClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -194,17 +191,17 @@ func (client *APITagDescriptionClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Get Tag description in scope of API // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -235,7 +232,7 @@ func (client *APITagDescriptionClient) Get(ctx context.Context, resourceGroupNam } // getCreateRequest creates the Get request. -func (client *APITagDescriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, options *APITagDescriptionClientGetOptions) (*policy.Request, error) { +func (client *APITagDescriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, _ *APITagDescriptionClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -262,7 +259,7 @@ func (client *APITagDescriptionClient) getCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -282,7 +279,7 @@ func (client *APITagDescriptionClient) getHandleResponse(resp *http.Response) (A // GetEntityTag - Gets the entity state version of the tag specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -314,7 +311,7 @@ func (client *APITagDescriptionClient) GetEntityTag(ctx context.Context, resourc } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APITagDescriptionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, options *APITagDescriptionClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APITagDescriptionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, _ *APITagDescriptionClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -341,7 +338,7 @@ func (client *APITagDescriptionClient) getEntityTagCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -359,7 +356,7 @@ func (client *APITagDescriptionClient) getEntityTagHandleResponse(resp *http.Res // NewListByServicePager - Lists all Tags descriptions in scope of API. Model similar to swagger - tagDescription is defined // on API level but tag may be assigned to the Operations // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -416,13 +413,13 @@ func (client *APITagDescriptionClient) listByServiceCreateRequest(ctx context.Co if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apitagdescription_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apitagdescription_client_example_test.go deleted file mode 100644 index d006d8b2560a..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apitagdescription_client_example_test.go +++ /dev/null @@ -1,165 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiTagDescriptions.json -func ExampleAPITagDescriptionClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPITagDescriptionClient().NewListByServicePager("rg1", "apimService1", "57d2ef278aa04f0888cba3f3", &armapimanagement.APITagDescriptionClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.TagDescriptionCollection = armapimanagement.TagDescriptionCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.TagDescriptionContract{ - // { - // Name: to.Ptr("5600b539c53f5b0062060002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tagDescriptions/5600b539c53f5b0062060002"), - // Properties: &armapimanagement.TagDescriptionContractProperties{ - // ExternalDocsDescription: to.Ptr("some additional info"), - // ExternalDocsURL: to.Ptr("http://some_url.com"), - // DisplayName: to.Ptr("tag1"), - // TagID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/5600b539c53f5b0062060002"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiTagDescription.json -func ExampleAPITagDescriptionClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPITagDescriptionClient().GetEntityTag(ctx, "rg1", "apimService1", "59d6bb8f1f7fab13dc67ec9b", "59306a29e4bbd510dc24e5f9", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiTagDescription.json -func ExampleAPITagDescriptionClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPITagDescriptionClient().Get(ctx, "rg1", "apimService1", "59d6bb8f1f7fab13dc67ec9b", "59306a29e4bbd510dc24e5f9", 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.TagDescriptionContract = armapimanagement.TagDescriptionContract{ - // Name: to.Ptr("59306a29e4bbd510dc24e5f9"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/tagDescriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/59d6bb8f1f7fab13dc67ec9b/tagDescriptions/59306a29e4bbd510dc24e5f9"), - // Properties: &armapimanagement.TagDescriptionContractProperties{ - // ExternalDocsDescription: to.Ptr("some additional info"), - // ExternalDocsURL: to.Ptr("http://some_url.com"), - // DisplayName: to.Ptr("tag1"), - // TagID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/59306a29e4bbd510dc24e5f9"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiTagDescription.json -func ExampleAPITagDescriptionClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPITagDescriptionClient().CreateOrUpdate(ctx, "rg1", "apimService1", "5931a75ae4bbd512a88c680b", "tagId1", armapimanagement.TagDescriptionCreateParameters{ - Properties: &armapimanagement.TagDescriptionBaseProperties{ - Description: to.Ptr("Some description that will be displayed for operation's tag if the tag is assigned to operation of the API"), - ExternalDocsDescription: to.Ptr("Description of the external docs resource"), - ExternalDocsURL: to.Ptr("http://some.url/additionaldoc"), - }, - }, &armapimanagement.APITagDescriptionClientCreateOrUpdateOptions{IfMatch: 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.TagDescriptionContract = armapimanagement.TagDescriptionContract{ - // Name: to.Ptr("tagId1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/tagDescriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5931a75ae4bbd512a88c680b/tagDescriptions/tagId1"), - // Properties: &armapimanagement.TagDescriptionContractProperties{ - // Description: to.Ptr("Some description that will be displayed for operation's tag if the tag is assigned to operation of the API"), - // ExternalDocsDescription: to.Ptr("some additional info"), - // ExternalDocsURL: to.Ptr("http://some_url.com"), - // DisplayName: to.Ptr("tag1"), - // TagID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/tagId1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiTagDescription.json -func ExampleAPITagDescriptionClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPITagDescriptionClient().Delete(ctx, "rg1", "apimService1", "59d5b28d1f7fab116c282650", "59d5b28e1f7fab116402044e", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiversionset_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiversionset_client.go index 5ec6227a08e2..f36b7c2489a4 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiversionset_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apiversionset_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIVersionSetClient struct { } // NewAPIVersionSetClient creates a new instance of APIVersionSetClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIVersionSetClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIVersionSetClient, error) { @@ -47,7 +44,7 @@ func NewAPIVersionSetClient(subscriptionID string, credential azcore.TokenCreden // CreateOrUpdate - Creates or Updates a Api Version Set. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. @@ -100,12 +97,12 @@ func (client *APIVersionSetClient) createOrUpdateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -127,7 +124,7 @@ func (client *APIVersionSetClient) createOrUpdateHandleResponse(resp *http.Respo // Delete - Deletes specific Api Version Set. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. @@ -156,7 +153,7 @@ func (client *APIVersionSetClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *APIVersionSetClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string, options *APIVersionSetClientDeleteOptions) (*policy.Request, error) { +func (client *APIVersionSetClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string, _ *APIVersionSetClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -179,17 +176,17 @@ func (client *APIVersionSetClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the Api Version Set specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. @@ -217,7 +214,7 @@ func (client *APIVersionSetClient) Get(ctx context.Context, resourceGroupName st } // getCreateRequest creates the Get request. -func (client *APIVersionSetClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, options *APIVersionSetClientGetOptions) (*policy.Request, error) { +func (client *APIVersionSetClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, _ *APIVersionSetClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -240,7 +237,7 @@ func (client *APIVersionSetClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -260,7 +257,7 @@ func (client *APIVersionSetClient) getHandleResponse(resp *http.Response) (APIVe // GetEntityTag - Gets the entity state (Etag) version of the Api Version Set specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. @@ -289,7 +286,7 @@ func (client *APIVersionSetClient) GetEntityTag(ctx context.Context, resourceGro } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIVersionSetClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, options *APIVersionSetClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIVersionSetClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, _ *APIVersionSetClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -312,7 +309,7 @@ func (client *APIVersionSetClient) getEntityTagCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -329,7 +326,7 @@ func (client *APIVersionSetClient) getEntityTagHandleResponse(resp *http.Respons // NewListByServicePager - Lists a collection of API Version Sets in the specified service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - APIVersionSetClientListByServiceOptions contains the optional parameters for the APIVersionSetClient.NewListByServicePager @@ -380,13 +377,13 @@ func (client *APIVersionSetClient) listByServiceCreateRequest(ctx context.Contex if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -404,7 +401,7 @@ func (client *APIVersionSetClient) listByServiceHandleResponse(resp *http.Respon // Update - Updates the details of the Api VersionSet specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. @@ -435,7 +432,7 @@ func (client *APIVersionSetClient) Update(ctx context.Context, resourceGroupName } // updateCreateRequest creates the Update request. -func (client *APIVersionSetClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string, parameters APIVersionSetUpdateParameters, options *APIVersionSetClientUpdateOptions) (*policy.Request, error) { +func (client *APIVersionSetClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string, parameters APIVersionSetUpdateParameters, _ *APIVersionSetClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -458,10 +455,10 @@ func (client *APIVersionSetClient) updateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiversionset_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiversionset_client_example_test.go deleted file mode 100644 index 03d6dd780eef..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiversionset_client_example_test.go +++ /dev/null @@ -1,207 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiVersionSets.json -func ExampleAPIVersionSetClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIVersionSetClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.APIVersionSetClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.APIVersionSetCollection = armapimanagement.APIVersionSetCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.APIVersionSetContract{ - // { - // Name: to.Ptr("vs1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/api-version-sets"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/vs1"), - // Properties: &armapimanagement.APIVersionSetContractProperties{ - // Description: to.Ptr("Version configuration"), - // DisplayName: to.Ptr("api set 1"), - // VersioningScheme: to.Ptr(armapimanagement.VersioningSchemeSegment), - // }, - // }, - // { - // Name: to.Ptr("vs2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/api-version-sets"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/vs2"), - // Properties: &armapimanagement.APIVersionSetContractProperties{ - // Description: to.Ptr("Version configuration 2"), - // DisplayName: to.Ptr("api set 2"), - // VersioningScheme: to.Ptr(armapimanagement.VersioningSchemeQuery), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiVersionSet.json -func ExampleAPIVersionSetClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIVersionSetClient().GetEntityTag(ctx, "rg1", "apimService1", "vs1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiVersionSet.json -func ExampleAPIVersionSetClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIVersionSetClient().Get(ctx, "rg1", "apimService1", "vs1", 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.APIVersionSetContract = armapimanagement.APIVersionSetContract{ - // Name: to.Ptr("vs1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/api-version-sets"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/vs1"), - // Properties: &armapimanagement.APIVersionSetContractProperties{ - // Description: to.Ptr("Version configuration"), - // DisplayName: to.Ptr("Version Set 1"), - // VersioningScheme: to.Ptr(armapimanagement.VersioningSchemeSegment), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiVersionSet.json -func ExampleAPIVersionSetClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIVersionSetClient().CreateOrUpdate(ctx, "rg1", "apimService1", "api1", armapimanagement.APIVersionSetContract{ - Properties: &armapimanagement.APIVersionSetContractProperties{ - Description: to.Ptr("Version configuration"), - DisplayName: to.Ptr("api set 1"), - VersioningScheme: to.Ptr(armapimanagement.VersioningSchemeSegment), - }, - }, &armapimanagement.APIVersionSetClientCreateOrUpdateOptions{IfMatch: 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.APIVersionSetContract = armapimanagement.APIVersionSetContract{ - // Name: to.Ptr("api1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/api-version-sets"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/api1"), - // Properties: &armapimanagement.APIVersionSetContractProperties{ - // Description: to.Ptr("Version configuration"), - // DisplayName: to.Ptr("api set 1"), - // VersioningScheme: to.Ptr(armapimanagement.VersioningSchemeSegment), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiVersionSet.json -func ExampleAPIVersionSetClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIVersionSetClient().Update(ctx, "rg1", "apimService1", "vs1", "*", armapimanagement.APIVersionSetUpdateParameters{ - Properties: &armapimanagement.APIVersionSetUpdateParametersProperties{ - Description: to.Ptr("Version configuration"), - DisplayName: to.Ptr("api set 1"), - VersioningScheme: to.Ptr(armapimanagement.VersioningSchemeSegment), - }, - }, 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.APIVersionSetContract = armapimanagement.APIVersionSetContract{ - // Name: to.Ptr("vs1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/api-version-sets"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apiVersionSets/vs1"), - // Properties: &armapimanagement.APIVersionSetContractProperties{ - // Description: to.Ptr("Version configuration"), - // DisplayName: to.Ptr("api set 1"), - // VersioningScheme: to.Ptr(armapimanagement.VersioningSchemeSegment), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiVersionSet.json -func ExampleAPIVersionSetClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIVersionSetClient().Delete(ctx, "rg1", "apimService1", "a1", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiwiki_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiwiki_client.go index b3d76aa2d701..1e5576787866 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiwiki_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apiwiki_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type APIWikiClient struct { } // NewAPIWikiClient creates a new instance of APIWikiClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIWikiClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIWikiClient, error) { @@ -46,7 +43,7 @@ func NewAPIWikiClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Creates a new Wiki for an API or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -98,12 +95,12 @@ func (client *APIWikiClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -125,7 +122,7 @@ func (client *APIWikiClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - Deletes the specified Wiki from an API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -154,7 +151,7 @@ func (client *APIWikiClient) Delete(ctx context.Context, resourceGroupName strin } // deleteCreateRequest creates the Delete request. -func (client *APIWikiClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *APIWikiClientDeleteOptions) (*policy.Request, error) { +func (client *APIWikiClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, _ *APIWikiClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -177,17 +174,17 @@ func (client *APIWikiClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the Wiki for an API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -215,7 +212,7 @@ func (client *APIWikiClient) Get(ctx context.Context, resourceGroupName string, } // getCreateRequest creates the Get request. -func (client *APIWikiClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIWikiClientGetOptions) (*policy.Request, error) { +func (client *APIWikiClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, _ *APIWikiClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -238,7 +235,7 @@ func (client *APIWikiClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -258,7 +255,7 @@ func (client *APIWikiClient) getHandleResponse(resp *http.Response) (APIWikiClie // GetEntityTag - Gets the entity state (Etag) version of the Wiki for an API specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -286,7 +283,7 @@ func (client *APIWikiClient) GetEntityTag(ctx context.Context, resourceGroupName } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *APIWikiClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIWikiClientGetEntityTagOptions) (*policy.Request, error) { +func (client *APIWikiClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, _ *APIWikiClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -309,7 +306,7 @@ func (client *APIWikiClient) getEntityTagCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -327,7 +324,7 @@ func (client *APIWikiClient) getEntityTagHandleResponse(resp *http.Response) (AP // Update - Updates the details of the Wiki for an API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -358,7 +355,7 @@ func (client *APIWikiClient) Update(ctx context.Context, resourceGroupName strin } // updateCreateRequest creates the Update request. -func (client *APIWikiClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, parameters WikiUpdateContract, options *APIWikiClientUpdateOptions) (*policy.Request, error) { +func (client *APIWikiClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, parameters WikiUpdateContract, _ *APIWikiClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -381,10 +378,10 @@ func (client *APIWikiClient) updateCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiwiki_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiwiki_client_example_test.go deleted file mode 100644 index 09f72468a449..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiwiki_client_example_test.go +++ /dev/null @@ -1,169 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiWiki.json -func ExampleAPIWikiClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIWikiClient().GetEntityTag(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiWiki.json -func ExampleAPIWikiClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIWikiClient().Get(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", 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.WikiContract = armapimanagement.WikiContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/wikis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/wikis/default"), - // Properties: &armapimanagement.WikiContractProperties{ - // Documents: []*armapimanagement.WikiDocumentationContract{ - // { - // DocumentationID: to.Ptr("docId1"), - // }, - // { - // DocumentationID: to.Ptr("docId2"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiWiki.json -func ExampleAPIWikiClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIWikiClient().CreateOrUpdate(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", armapimanagement.WikiContract{ - Properties: &armapimanagement.WikiContractProperties{ - Documents: []*armapimanagement.WikiDocumentationContract{ - { - DocumentationID: to.Ptr("docId1"), - }, - { - DocumentationID: to.Ptr("docId2"), - }}, - }, - }, &armapimanagement.APIWikiClientCreateOrUpdateOptions{IfMatch: 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.WikiContract = armapimanagement.WikiContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/wikis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/wikis/default"), - // Properties: &armapimanagement.WikiContractProperties{ - // Documents: []*armapimanagement.WikiDocumentationContract{ - // { - // DocumentationID: to.Ptr("docId1"), - // }, - // { - // DocumentationID: to.Ptr("docId2"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateApiWiki.json -func ExampleAPIWikiClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAPIWikiClient().Update(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "*", armapimanagement.WikiUpdateContract{ - Properties: &armapimanagement.WikiContractProperties{ - Documents: []*armapimanagement.WikiDocumentationContract{ - { - DocumentationID: to.Ptr("docId1"), - }}, - }, - }, 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.WikiContract = armapimanagement.WikiContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/wikis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/wikis/default"), - // Properties: &armapimanagement.WikiContractProperties{ - // Documents: []*armapimanagement.WikiDocumentationContract{ - // { - // DocumentationID: to.Ptr("docId1"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiWiki.json -func ExampleAPIWikiClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAPIWikiClient().Delete(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiwikis_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiwikis_client.go index c48237c6a22f..3e7318e520cc 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiwikis_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/apiwikis_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type APIWikisClient struct { } // NewAPIWikisClient creates a new instance of APIWikisClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAPIWikisClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIWikisClient, error) { @@ -46,7 +43,7 @@ func NewAPIWikisClient(subscriptionID string, credential azcore.TokenCredential, // NewListPager - Gets the wikis for an API specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API identifier. Must be unique in the current API Management service instance. @@ -101,13 +98,13 @@ func (client *APIWikisClient) listCreateRequest(ctx context.Context, resourceGro if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/apiwikis_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/apiwikis_client_example_test.go deleted file mode 100644 index c5068b7644f8..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/apiwikis_client_example_test.go +++ /dev/null @@ -1,63 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiWikis.json -func ExampleAPIWikisClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAPIWikisClient().NewListPager("rg1", "apimService1", "57d1f7558aa04f15146d9d8a", &armapimanagement.APIWikisClientListOptions{Filter: nil, - Top: nil, - Skip: 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.WikiCollection = armapimanagement.WikiCollection{ - // Value: []*armapimanagement.WikiContract{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/wikis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a/wikis/default"), - // Properties: &armapimanagement.WikiContractProperties{ - // Documents: []*armapimanagement.WikiDocumentationContract{ - // { - // DocumentationID: to.Ptr("docId1"), - // }, - // { - // DocumentationID: to.Ptr("docId2"), - // }}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorization_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorization_client.go index 73b7444fc15d..7f68b0988595 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorization_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/authorization_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type AuthorizationClient struct { } // NewAuthorizationClient creates a new instance of AuthorizationClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAuthorizationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AuthorizationClient, error) { @@ -47,7 +44,7 @@ func NewAuthorizationClient(subscriptionID string, credential azcore.TokenCreden // ConfirmConsentCode - Confirm valid consent code to suppress Authorizations anti-phishing page. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -78,7 +75,7 @@ func (client *AuthorizationClient) ConfirmConsentCode(ctx context.Context, resou } // confirmConsentCodeCreateRequest creates the ConfirmConsentCode request. -func (client *AuthorizationClient) confirmConsentCodeCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, parameters AuthorizationConfirmConsentCodeRequestContract, options *AuthorizationClientConfirmConsentCodeOptions) (*policy.Request, error) { +func (client *AuthorizationClient) confirmConsentCodeCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, parameters AuthorizationConfirmConsentCodeRequestContract, _ *AuthorizationClientConfirmConsentCodeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/confirmConsentCode" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -105,7 +102,7 @@ func (client *AuthorizationClient) confirmConsentCodeCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -126,7 +123,7 @@ func (client *AuthorizationClient) confirmConsentCodeHandleResponse(resp *http.R // CreateOrUpdate - Creates or updates authorization. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -184,12 +181,12 @@ func (client *AuthorizationClient) createOrUpdateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -211,7 +208,7 @@ func (client *AuthorizationClient) createOrUpdateHandleResponse(resp *http.Respo // Delete - Deletes specific Authorization from the Authorization provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -241,7 +238,7 @@ func (client *AuthorizationClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *AuthorizationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, ifMatch string, options *AuthorizationClientDeleteOptions) (*policy.Request, error) { +func (client *AuthorizationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, ifMatch string, _ *AuthorizationClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -268,17 +265,17 @@ func (client *AuthorizationClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the authorization specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -307,7 +304,7 @@ func (client *AuthorizationClient) Get(ctx context.Context, resourceGroupName st } // getCreateRequest creates the Get request. -func (client *AuthorizationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, options *AuthorizationClientGetOptions) (*policy.Request, error) { +func (client *AuthorizationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, _ *AuthorizationClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -334,7 +331,7 @@ func (client *AuthorizationClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -354,7 +351,7 @@ func (client *AuthorizationClient) getHandleResponse(resp *http.Response) (Autho // NewListByAuthorizationProviderPager - Lists a collection of authorization providers defined within a authorization provider. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -410,13 +407,13 @@ func (client *AuthorizationClient) listByAuthorizationProviderCreateRequest(ctx if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorization_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorization_client_example_test.go deleted file mode 100644 index 9bbe7936bd55..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorization_client_example_test.go +++ /dev/null @@ -1,282 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationsAuthCode.json -func ExampleAuthorizationClient_NewListByAuthorizationProviderPager_apiManagementListAuthorizationsAuthCode() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAuthorizationClient().NewListByAuthorizationProviderPager("rg1", "apimService1", "aadwithauthcode", &armapimanagement.AuthorizationClientListByAuthorizationProviderOptions{Filter: nil, - Top: nil, - Skip: 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.AuthorizationCollection = armapimanagement.AuthorizationCollection{ - // Value: []*armapimanagement.AuthorizationContract{ - // { - // Name: to.Ptr("authz1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz1"), - // Properties: &armapimanagement.AuthorizationContractProperties{ - // AuthorizationType: to.Ptr(armapimanagement.AuthorizationTypeOAuth2), - // OAuth2GrantType: to.Ptr(armapimanagement.OAuth2GrantTypeAuthorizationCode), - // Status: to.Ptr("Connected"), - // }, - // }, - // { - // Name: to.Ptr("authz2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz2"), - // Properties: &armapimanagement.AuthorizationContractProperties{ - // AuthorizationType: to.Ptr(armapimanagement.AuthorizationTypeOAuth2), - // Error: &armapimanagement.AuthorizationError{ - // Code: to.Ptr("Unauthenticated"), - // Message: to.Ptr("This connection is not authenticated."), - // }, - // OAuth2GrantType: to.Ptr(armapimanagement.OAuth2GrantTypeAuthorizationCode), - // Status: to.Ptr("Error"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationsClientCred.json -func ExampleAuthorizationClient_NewListByAuthorizationProviderPager_apiManagementListAuthorizationsClientCred() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAuthorizationClient().NewListByAuthorizationProviderPager("rg1", "apimService1", "aadwithclientcred", &armapimanagement.AuthorizationClientListByAuthorizationProviderOptions{Filter: nil, - Top: nil, - Skip: 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.AuthorizationCollection = armapimanagement.AuthorizationCollection{ - // Value: []*armapimanagement.AuthorizationContract{ - // { - // Name: to.Ptr("authz1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred/authorizations/authz1"), - // Properties: &armapimanagement.AuthorizationContractProperties{ - // AuthorizationType: to.Ptr(armapimanagement.AuthorizationTypeOAuth2), - // OAuth2GrantType: to.Ptr(armapimanagement.OAuth2GrantTypeClientCredentials), - // Parameters: map[string]*string{ - // "clientId": to.Ptr("53790925-fdd3-4b80-bc7a-4c3aaf25801d"), - // }, - // Status: to.Ptr("Connected"), - // }, - // }, - // { - // Name: to.Ptr("authz2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred/authorizations/authz2"), - // Properties: &armapimanagement.AuthorizationContractProperties{ - // AuthorizationType: to.Ptr(armapimanagement.AuthorizationTypeOAuth2), - // Error: &armapimanagement.AuthorizationError{ - // Code: to.Ptr("Unauthorized"), - // Message: to.Ptr("Failed to acquire access token for service using client credentials flow: IdentityProvider=aadwithclientcred. Correlation Id=6299d09b-03b7-46ed-b355-0453451d7e49, UTC TimeStamp=5/14/2022 4:53:19 PM, Error: Failed to exchange client credentials for token. Response code=Unauthorized, Details:\r\n{\"error\":\"invalid_client\",\"error_description\":\"AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app '53790925-fdd3-4b80-bc7a-4c3aaf25801d'.\\r\\nTrace ID: 4a18d3cd-9ad5-4664-b3eb-daaa2f435f00\\r\\nCorrelation ID: dde60c16-35cb-4572-8226-bfb4233af8d7\\r\\nTimestamp: 2022-05-14 16:53:19Z\",\"error_codes\":[7000215],\"timestamp\":\"2022-05-14 16:53:19Z\",\"trace_id\":\"4a18d3cd-9ad5-4664-b3eb-daaa2f435f00\",\"correlation_id\":\"dde60c16-35cb-4572-8226-bfb4233af8d7\",\"error_uri\":\"https://login.windows.net/error?code=7000215\"}"), - // }, - // OAuth2GrantType: to.Ptr(armapimanagement.OAuth2GrantTypeClientCredentials), - // Parameters: map[string]*string{ - // "clientId": to.Ptr("53790925-fdd3-4b80-bc7a-4c3aaf25801d"), - // }, - // Status: to.Ptr("Error"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorization.json -func ExampleAuthorizationClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationClient().Get(ctx, "rg1", "apimService1", "aadwithauthcode", "authz1", 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.AuthorizationContract = armapimanagement.AuthorizationContract{ - // Name: to.Ptr("authz1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz1"), - // Properties: &armapimanagement.AuthorizationContractProperties{ - // AuthorizationType: to.Ptr(armapimanagement.AuthorizationTypeOAuth2), - // OAuth2GrantType: to.Ptr(armapimanagement.OAuth2GrantTypeAuthorizationCode), - // Status: to.Ptr("Connected"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationAADAuthCode.json -func ExampleAuthorizationClient_CreateOrUpdate_apiManagementCreateAuthorizationAadAuthCode() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationClient().CreateOrUpdate(ctx, "rg1", "apimService1", "aadwithauthcode", "authz2", armapimanagement.AuthorizationContract{ - Properties: &armapimanagement.AuthorizationContractProperties{ - AuthorizationType: to.Ptr(armapimanagement.AuthorizationTypeOAuth2), - OAuth2GrantType: to.Ptr(armapimanagement.OAuth2GrantTypeAuthorizationCode), - }, - }, &armapimanagement.AuthorizationClientCreateOrUpdateOptions{IfMatch: 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.AuthorizationContract = armapimanagement.AuthorizationContract{ - // Name: to.Ptr("authz2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz2"), - // Properties: &armapimanagement.AuthorizationContractProperties{ - // AuthorizationType: to.Ptr(armapimanagement.AuthorizationTypeOAuth2), - // Error: &armapimanagement.AuthorizationError{ - // Code: to.Ptr("Unauthenticated"), - // Message: to.Ptr("This connection is not authenticated."), - // }, - // OAuth2GrantType: to.Ptr(armapimanagement.OAuth2GrantTypeAuthorizationCode), - // Status: to.Ptr("Error"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationAADClientCred.json -func ExampleAuthorizationClient_CreateOrUpdate_apiManagementCreateAuthorizationAadClientCred() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationClient().CreateOrUpdate(ctx, "rg1", "apimService1", "aadwithclientcred", "authz1", armapimanagement.AuthorizationContract{ - Properties: &armapimanagement.AuthorizationContractProperties{ - AuthorizationType: to.Ptr(armapimanagement.AuthorizationTypeOAuth2), - OAuth2GrantType: to.Ptr(armapimanagement.OAuth2GrantTypeAuthorizationCode), - Parameters: map[string]*string{ - "clientId": to.Ptr("53790925-fdd3-4b80-bc7a-4c3aaf25801d"), - "clientSecret": to.Ptr("FcJkQ3iPSaKAQRA7Ft8Q~fZ1X5vKmqzUAfJagcJ8"), - }, - }, - }, &armapimanagement.AuthorizationClientCreateOrUpdateOptions{IfMatch: 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.AuthorizationContract = armapimanagement.AuthorizationContract{ - // Name: to.Ptr("authz1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred/authorizations/authz1"), - // Properties: &armapimanagement.AuthorizationContractProperties{ - // AuthorizationType: to.Ptr(armapimanagement.AuthorizationTypeOAuth2), - // OAuth2GrantType: to.Ptr(armapimanagement.OAuth2GrantTypeClientCredentials), - // Parameters: map[string]*string{ - // "clientId": to.Ptr("53790925-fdd3-4b80-bc7a-4c3aaf25801d"), - // }, - // Status: to.Ptr("Connected"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteAuthorization.json -func ExampleAuthorizationClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAuthorizationClient().Delete(ctx, "rg1", "apimService1", "aadwithauthcode", "authz1", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPostAuthorizationConfirmConsentCodeRequest.json -func ExampleAuthorizationClient_ConfirmConsentCode() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAuthorizationClient().ConfirmConsentCode(ctx, "rg1", "apimService1", "aadwithauthcode", "authz1", armapimanagement.AuthorizationConfirmConsentCodeRequestContract{ - ConsentCode: to.Ptr("theconsentcode"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationaccesspolicy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationaccesspolicy_client.go index d05dabd129d5..656f0cf89d42 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationaccesspolicy_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationaccesspolicy_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type AuthorizationAccessPolicyClient struct { } // NewAuthorizationAccessPolicyClient creates a new instance of AuthorizationAccessPolicyClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAuthorizationAccessPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AuthorizationAccessPolicyClient, error) { @@ -47,7 +44,7 @@ func NewAuthorizationAccessPolicyClient(subscriptionID string, credential azcore // CreateOrUpdate - Creates or updates Authorization Access Policy. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -110,12 +107,12 @@ func (client *AuthorizationAccessPolicyClient) createOrUpdateCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -137,7 +134,7 @@ func (client *AuthorizationAccessPolicyClient) createOrUpdateHandleResponse(resp // Delete - Deletes specific access policy from the Authorization. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -169,7 +166,7 @@ func (client *AuthorizationAccessPolicyClient) Delete(ctx context.Context, resou } // deleteCreateRequest creates the Delete request. -func (client *AuthorizationAccessPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, authorizationAccessPolicyID string, ifMatch string, options *AuthorizationAccessPolicyClientDeleteOptions) (*policy.Request, error) { +func (client *AuthorizationAccessPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, authorizationAccessPolicyID string, ifMatch string, _ *AuthorizationAccessPolicyClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies/{authorizationAccessPolicyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -200,17 +197,17 @@ func (client *AuthorizationAccessPolicyClient) deleteCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the authorization access policy specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -241,7 +238,7 @@ func (client *AuthorizationAccessPolicyClient) Get(ctx context.Context, resource } // getCreateRequest creates the Get request. -func (client *AuthorizationAccessPolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, authorizationAccessPolicyID string, options *AuthorizationAccessPolicyClientGetOptions) (*policy.Request, error) { +func (client *AuthorizationAccessPolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, authorizationAccessPolicyID string, _ *AuthorizationAccessPolicyClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies/{authorizationAccessPolicyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -272,7 +269,7 @@ func (client *AuthorizationAccessPolicyClient) getCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -292,7 +289,7 @@ func (client *AuthorizationAccessPolicyClient) getHandleResponse(resp *http.Resp // NewListByAuthorizationPager - Lists a collection of authorization access policy defined within a authorization. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -353,13 +350,13 @@ func (client *AuthorizationAccessPolicyClient) listByAuthorizationCreateRequest( if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationaccesspolicy_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationaccesspolicy_client_example_test.go deleted file mode 100644 index f0b6a6686aec..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationaccesspolicy_client_example_test.go +++ /dev/null @@ -1,148 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationAccessPolicies.json -func ExampleAuthorizationAccessPolicyClient_NewListByAuthorizationPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAuthorizationAccessPolicyClient().NewListByAuthorizationPager("rg1", "apimService1", "aadwithauthcode", "authz1", &armapimanagement.AuthorizationAccessPolicyClientListByAuthorizationOptions{Filter: nil, - Top: nil, - Skip: 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.AuthorizationAccessPolicyCollection = armapimanagement.AuthorizationAccessPolicyCollection{ - // Value: []*armapimanagement.AuthorizationAccessPolicyContract{ - // { - // Name: to.Ptr("fe0bed83-631f-4149-bd0b-0464b1bc7cab"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations/accessPolicies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz1/accessPolicies"), - // Properties: &armapimanagement.AuthorizationAccessPolicyContractProperties{ - // ObjectID: to.Ptr("fe0bed83-631f-4149-bd0b-0464b1bc7cab"), - // TenantID: to.Ptr("13932a0d-5c63-4d37-901d-1df9c97722ff"), - // }, - // }, - // { - // Name: to.Ptr("5585d6cd-2289-42e9-ab9b-3e2e23d74b4a"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations/accessPolicies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz1/accessPolicies"), - // Properties: &armapimanagement.AuthorizationAccessPolicyContractProperties{ - // ObjectID: to.Ptr("5585d6cd-2289-42e9-ab9b-3e2e23d74b4a"), - // TenantID: to.Ptr("13932a0d-5c63-4d37-901d-1df9c97722ff"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorizationAccessPolicy.json -func ExampleAuthorizationAccessPolicyClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationAccessPolicyClient().Get(ctx, "rg1", "apimService1", "aadwithauthcode", "authz1", "fe0bed83-631f-4149-bd0b-0464b1bc7cab", 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.AuthorizationAccessPolicyContract = armapimanagement.AuthorizationAccessPolicyContract{ - // Name: to.Ptr("fe0bed83-631f-4149-bd0b-0464b1bc7cab"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations/accessPolicies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz1/accessPolicies"), - // Properties: &armapimanagement.AuthorizationAccessPolicyContractProperties{ - // ObjectID: to.Ptr("fe0bed83-631f-4149-bd0b-0464b1bc7cab"), - // TenantID: to.Ptr("13932a0d-5c63-4d37-901d-1df9c97722ff"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationAccessPolicy.json -func ExampleAuthorizationAccessPolicyClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationAccessPolicyClient().CreateOrUpdate(ctx, "rg1", "apimService1", "aadwithauthcode", "authz1", "fe0bed83-631f-4149-bd0b-0464b1bc7cab", armapimanagement.AuthorizationAccessPolicyContract{ - Properties: &armapimanagement.AuthorizationAccessPolicyContractProperties{ - ObjectID: to.Ptr("fe0bed83-631f-4149-bd0b-0464b1bc7cab"), - TenantID: to.Ptr("13932a0d-5c63-4d37-901d-1df9c97722ff"), - }, - }, &armapimanagement.AuthorizationAccessPolicyClientCreateOrUpdateOptions{IfMatch: 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.AuthorizationAccessPolicyContract = armapimanagement.AuthorizationAccessPolicyContract{ - // Name: to.Ptr("fe0bed83-631f-4149-bd0b-0464b1bc7cab"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders/authorizations/accessPolicies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz1/accessPolicies"), - // Properties: &armapimanagement.AuthorizationAccessPolicyContractProperties{ - // ObjectID: to.Ptr("fe0bed83-631f-4149-bd0b-0464b1bc7cab"), - // TenantID: to.Ptr("13932a0d-5c63-4d37-901d-1df9c97722ff"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteAuthorizationAccessPolicy.json -func ExampleAuthorizationAccessPolicyClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAuthorizationAccessPolicyClient().Delete(ctx, "rg1", "apimService1", "aadwithauthcode", "authz1", "fe0bed83-631f-4149-bd0b-0464b1bc7cab", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationloginlinks_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationloginlinks_client.go index ad1bb6774fbe..490273d1fecd 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationloginlinks_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationloginlinks_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type AuthorizationLoginLinksClient struct { } // NewAuthorizationLoginLinksClient creates a new instance of AuthorizationLoginLinksClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAuthorizationLoginLinksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AuthorizationLoginLinksClient, error) { @@ -46,7 +43,7 @@ func NewAuthorizationLoginLinksClient(subscriptionID string, credential azcore.T // Post - Gets authorization login links. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -77,7 +74,7 @@ func (client *AuthorizationLoginLinksClient) Post(ctx context.Context, resourceG } // postCreateRequest creates the Post request. -func (client *AuthorizationLoginLinksClient) postCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, parameters AuthorizationLoginRequestContract, options *AuthorizationLoginLinksClientPostOptions) (*policy.Request, error) { +func (client *AuthorizationLoginLinksClient) postCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, authorizationID string, parameters AuthorizationLoginRequestContract, _ *AuthorizationLoginLinksClientPostOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/getLoginLinks" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -104,7 +101,7 @@ func (client *AuthorizationLoginLinksClient) postCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationloginlinks_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationloginlinks_client_example_test.go deleted file mode 100644 index 608059b958b3..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationloginlinks_client_example_test.go +++ /dev/null @@ -1,44 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorizationLoginRequest.json -func ExampleAuthorizationLoginLinksClient_Post() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationLoginLinksClient().Post(ctx, "rg1", "apimService1", "aadwithauthcode", "authz1", armapimanagement.AuthorizationLoginRequestContract{ - PostLoginRedirectURL: to.Ptr("https://www.bing.com/"), - }, 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.AuthorizationLoginResponseContract = armapimanagement.AuthorizationLoginResponseContract{ - // LoginLink: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1/login?data=eyJMb2dpbklkIjoiY2YtODNmYzQ5N2YyZWYxNDA4MzlmNDdjZDU3YWY3MmZmODctYW5nYW50aS1wcmV2aWV3X2FhZC1hdXRoY29kZV9vYXV0aDItY29kZV90b2tlbiIsIlNlc3Npb25JZCI6IiIsIkxvZ0Nvbm5lY3Rpb25JZCI6ImF1dGh6MiIsIkxvZ0Nvbm5lY3RvcklkIjoiYWFkLWF1dGhjb2RlIiwiTG9nRW52aXJvbm1lbnRJZCI6ImFuZ2FudGktcHJld"), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationprovider_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationprovider_client.go index 87c2ec73d677..5f0c7883d29a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationprovider_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationprovider_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type AuthorizationProviderClient struct { } // NewAuthorizationProviderClient creates a new instance of AuthorizationProviderClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAuthorizationProviderClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AuthorizationProviderClient, error) { @@ -47,7 +44,7 @@ func NewAuthorizationProviderClient(subscriptionID string, credential azcore.Tok // CreateOrUpdate - Creates or updates authorization provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -100,12 +97,12 @@ func (client *AuthorizationProviderClient) createOrUpdateCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -127,7 +124,7 @@ func (client *AuthorizationProviderClient) createOrUpdateHandleResponse(resp *ht // Delete - Deletes specific authorization provider from the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -157,7 +154,7 @@ func (client *AuthorizationProviderClient) Delete(ctx context.Context, resourceG } // deleteCreateRequest creates the Delete request. -func (client *AuthorizationProviderClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, ifMatch string, options *AuthorizationProviderClientDeleteOptions) (*policy.Request, error) { +func (client *AuthorizationProviderClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, ifMatch string, _ *AuthorizationProviderClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -180,17 +177,17 @@ func (client *AuthorizationProviderClient) deleteCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the authorization provider specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authorizationProviderID - Identifier of the authorization provider. @@ -219,7 +216,7 @@ func (client *AuthorizationProviderClient) Get(ctx context.Context, resourceGrou } // getCreateRequest creates the Get request. -func (client *AuthorizationProviderClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, options *AuthorizationProviderClientGetOptions) (*policy.Request, error) { +func (client *AuthorizationProviderClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authorizationProviderID string, _ *AuthorizationProviderClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -242,7 +239,7 @@ func (client *AuthorizationProviderClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -262,7 +259,7 @@ func (client *AuthorizationProviderClient) getHandleResponse(resp *http.Response // NewListByServicePager - Lists a collection of authorization providers defined within a service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - AuthorizationProviderClientListByServiceOptions contains the optional parameters for the AuthorizationProviderClient.NewListByServicePager @@ -313,13 +310,13 @@ func (client *AuthorizationProviderClient) listByServiceCreateRequest(ctx contex if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationprovider_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationprovider_client_example_test.go deleted file mode 100644 index 5cc61d2a747e..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationprovider_client_example_test.go +++ /dev/null @@ -1,411 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationProviders.json -func ExampleAuthorizationProviderClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAuthorizationProviderClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.AuthorizationProviderClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.AuthorizationProviderCollection = armapimanagement.AuthorizationProviderCollection{ - // Value: []*armapimanagement.AuthorizationProviderContract{ - // { - // Name: to.Ptr("aadwithauthcode"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode"), - // Properties: &armapimanagement.AuthorizationProviderContractProperties{ - // DisplayName: to.Ptr("aadwithauthcode"), - // IdentityProvider: to.Ptr("aad"), - // Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - // GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - // AuthorizationCode: map[string]*string{ - // "clientId": to.Ptr("53790825-fdd3-4b80-bc7a-4c3aaf25801d"), - // "loginUri": to.Ptr("https://login.windows.net"), - // "resourceUri": to.Ptr("https://graph.microsoft.com"), - // "scopes": to.Ptr("User.Read.All Group.Read.All"), - // "tenantId": to.Ptr("common"), - // }, - // }, - // RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - // }, - // }, - // }, - // { - // Name: to.Ptr("aadwithclientcred"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred"), - // Properties: &armapimanagement.AuthorizationProviderContractProperties{ - // DisplayName: to.Ptr("aadwithclientcred"), - // IdentityProvider: to.Ptr("aad"), - // Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - // GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - // ClientCredentials: map[string]*string{ - // "loginUri": to.Ptr("https://login.windows.net"), - // "resourceUri": to.Ptr("https://graph.microsoft.com"), - // "scopes": to.Ptr("User.Read.All Group.Read.All"), - // "tenantId": to.Ptr("common"), - // }, - // }, - // RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - // }, - // }, - // }, - // { - // Name: to.Ptr("google"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/google"), - // Properties: &armapimanagement.AuthorizationProviderContractProperties{ - // DisplayName: to.Ptr("google"), - // IdentityProvider: to.Ptr("google"), - // Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - // GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - // AuthorizationCode: map[string]*string{ - // "clientId": to.Ptr("508791967882-5qv6o2i99a75un7329vlegtk78kr766h.apps.googleusercontent.com"), - // "scopes": to.Ptr("openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"), - // }, - // }, - // RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - // }, - // }, - // }, - // { - // Name: to.Ptr("eventbrite"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/eventbrite"), - // Properties: &armapimanagement.AuthorizationProviderContractProperties{ - // DisplayName: to.Ptr("eventbrite"), - // IdentityProvider: to.Ptr("oauth2"), - // Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - // GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - // AuthorizationCode: map[string]*string{ - // "authorizationUrl": to.Ptr("https://www.eventbrite.com/oauth/authorize"), - // "clientId": to.Ptr("ZYIJTBTABHOUQQDLZY"), - // "refreshUrl": to.Ptr("https://www.eventbrite.com/oauth/token"), - // "scopes": nil, - // "tokenUrl": to.Ptr("https://www.eventbrite.com/oauth/token"), - // }, - // }, - // RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorizationProvider.json -func ExampleAuthorizationProviderClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationProviderClient().Get(ctx, "rg1", "apimService1", "aadwithauthcode", 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.AuthorizationProviderContract = armapimanagement.AuthorizationProviderContract{ - // Name: to.Ptr("aadwithauthcode"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode"), - // Properties: &armapimanagement.AuthorizationProviderContractProperties{ - // DisplayName: to.Ptr("aadwithauthcode"), - // IdentityProvider: to.Ptr("aad"), - // Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - // GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - // AuthorizationCode: map[string]*string{ - // "clientId": to.Ptr("53790825-fdd3-4b80-bc7a-4c3aaf25801d"), - // "loginUri": to.Ptr("https://login.windows.net"), - // "resourceUri": to.Ptr("https://graph.microsoft.com"), - // "scopes": to.Ptr("User.Read.All Group.Read.All"), - // "tenantId": to.Ptr("common"), - // }, - // }, - // RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json -func ExampleAuthorizationProviderClient_CreateOrUpdate_apiManagementCreateAuthorizationProviderAadAuthCode() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", "aadwithauthcode", armapimanagement.AuthorizationProviderContract{ - Properties: &armapimanagement.AuthorizationProviderContractProperties{ - DisplayName: to.Ptr("aadwithauthcode"), - IdentityProvider: to.Ptr("aad"), - Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - AuthorizationCode: map[string]*string{ - "clientId": to.Ptr("59790825-fdd3-4b10-bc7a-4c3aaf25801d"), - "clientSecret": to.Ptr("Q3iPSaKQ~fZFcJk5vKmqzUAfJagcJ8"), - "resourceUri": to.Ptr("https://graph.microsoft.com"), - "scopes": to.Ptr("User.Read.All Group.Read.All"), - }, - }, - RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - }, - }, - }, &armapimanagement.AuthorizationProviderClientCreateOrUpdateOptions{IfMatch: 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.AuthorizationProviderContract = armapimanagement.AuthorizationProviderContract{ - // Name: to.Ptr("aadwithauthcode"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode"), - // Properties: &armapimanagement.AuthorizationProviderContractProperties{ - // DisplayName: to.Ptr("aadwithauthcode"), - // IdentityProvider: to.Ptr("aad"), - // Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - // GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - // AuthorizationCode: map[string]*string{ - // "clientId": to.Ptr("53790825-fdd3-4b80-bc7a-4c3aaf25801d"), - // "loginUri": to.Ptr("https://login.windows.net"), - // "resourceUri": to.Ptr("https://graph.microsoft.com"), - // "scopes": to.Ptr("User.Read.All Group.Read.All"), - // "tenantId": to.Ptr("common"), - // }, - // }, - // RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json -func ExampleAuthorizationProviderClient_CreateOrUpdate_apiManagementCreateAuthorizationProviderAadClientCred() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", "aadwithclientcred", armapimanagement.AuthorizationProviderContract{ - Properties: &armapimanagement.AuthorizationProviderContractProperties{ - DisplayName: to.Ptr("aadwithclientcred"), - IdentityProvider: to.Ptr("aad"), - Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - AuthorizationCode: map[string]*string{ - "resourceUri": to.Ptr("https://graph.microsoft.com"), - "scopes": to.Ptr("User.Read.All Group.Read.All"), - }, - }, - RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - }, - }, - }, &armapimanagement.AuthorizationProviderClientCreateOrUpdateOptions{IfMatch: 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.AuthorizationProviderContract = armapimanagement.AuthorizationProviderContract{ - // Name: to.Ptr("aadwithclientcred"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred"), - // Properties: &armapimanagement.AuthorizationProviderContractProperties{ - // DisplayName: to.Ptr("aadwithclientcred"), - // IdentityProvider: to.Ptr("aad"), - // Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - // GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - // ClientCredentials: map[string]*string{ - // "loginUri": to.Ptr("https://login.windows.net"), - // "resourceUri": to.Ptr("https://graph.microsoft.com"), - // "scopes": to.Ptr("User.Read.All Group.Read.All"), - // "tenantId": to.Ptr("common"), - // }, - // }, - // RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json -func ExampleAuthorizationProviderClient_CreateOrUpdate_apiManagementCreateAuthorizationProviderGenericOAuth2() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", "eventbrite", armapimanagement.AuthorizationProviderContract{ - Properties: &armapimanagement.AuthorizationProviderContractProperties{ - DisplayName: to.Ptr("eventbrite"), - IdentityProvider: to.Ptr("oauth2"), - Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - AuthorizationCode: map[string]*string{ - "authorizationUrl": to.Ptr("https://www.eventbrite.com/oauth/authorize"), - "clientId": to.Ptr("ZYIJTBTABHOUQQDLZY"), - "clientSecret": to.Ptr("Q3iPSaKQ~fZFcJk5vKmqzUAfJagcJ8"), - "refreshUrl": to.Ptr("https://www.eventbrite.com/oauth/token"), - "scopes": nil, - "tokenUrl": to.Ptr("https://www.eventbrite.com/oauth/token"), - }, - }, - RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - }, - }, - }, &armapimanagement.AuthorizationProviderClientCreateOrUpdateOptions{IfMatch: 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.AuthorizationProviderContract = armapimanagement.AuthorizationProviderContract{ - // Name: to.Ptr("eventbrite"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/eventbrite"), - // Properties: &armapimanagement.AuthorizationProviderContractProperties{ - // DisplayName: to.Ptr("eventbrite"), - // IdentityProvider: to.Ptr("oauth2"), - // Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - // GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - // AuthorizationCode: map[string]*string{ - // "authorizationUrl": to.Ptr("https://www.eventbrite.com/oauth/authorize"), - // "clientId": to.Ptr("ZYIJTBTABHOUQQDLZY"), - // "refreshUrl": to.Ptr("https://www.eventbrite.com/oauth/token"), - // "scopes": nil, - // "tokenUrl": to.Ptr("https://www.eventbrite.com/oauth/token"), - // }, - // }, - // RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json -func ExampleAuthorizationProviderClient_CreateOrUpdate_apiManagementCreateAuthorizationProviderOobGoogle() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", "google", armapimanagement.AuthorizationProviderContract{ - Properties: &armapimanagement.AuthorizationProviderContractProperties{ - DisplayName: to.Ptr("google"), - IdentityProvider: to.Ptr("google"), - Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - AuthorizationCode: map[string]*string{ - "clientId": to.Ptr("508791967882-5qv6o2i99a75un7329vlegtk78kr766h.apps.googleusercontent.com"), - "clientSecret": to.Ptr("qDN0VyVFjU1OsOyT5Kz8ce"), - "scopes": to.Ptr("openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"), - }, - }, - RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - }, - }, - }, &armapimanagement.AuthorizationProviderClientCreateOrUpdateOptions{IfMatch: 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.AuthorizationProviderContract = armapimanagement.AuthorizationProviderContract{ - // Name: to.Ptr("google"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/google"), - // Properties: &armapimanagement.AuthorizationProviderContractProperties{ - // DisplayName: to.Ptr("google"), - // IdentityProvider: to.Ptr("google"), - // Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{ - // GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{ - // AuthorizationCode: map[string]*string{ - // "clientId": to.Ptr("508791967882-5qv6o2i99a75un7329vlegtk78kr766h.apps.googleusercontent.com"), - // "scopes": to.Ptr("openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"), - // }, - // }, - // RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteAuthorizationProvider.json -func ExampleAuthorizationProviderClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAuthorizationProviderClient().Delete(ctx, "rg1", "apimService1", "aadwithauthcode", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationserver_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationserver_client.go index c354e8fc187f..679f180a3d7f 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationserver_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationserver_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type AuthorizationServerClient struct { } // NewAuthorizationServerClient creates a new instance of AuthorizationServerClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewAuthorizationServerClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AuthorizationServerClient, error) { @@ -47,7 +44,7 @@ func NewAuthorizationServerClient(subscriptionID string, credential azcore.Token // CreateOrUpdate - Creates new authorization server or updates an existing authorization server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authsid - Identifier of the authorization server. @@ -100,12 +97,12 @@ func (client *AuthorizationServerClient) createOrUpdateCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -127,7 +124,7 @@ func (client *AuthorizationServerClient) createOrUpdateHandleResponse(resp *http // Delete - Deletes specific authorization server instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authsid - Identifier of the authorization server. @@ -157,7 +154,7 @@ func (client *AuthorizationServerClient) Delete(ctx context.Context, resourceGro } // deleteCreateRequest creates the Delete request. -func (client *AuthorizationServerClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string, options *AuthorizationServerClientDeleteOptions) (*policy.Request, error) { +func (client *AuthorizationServerClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string, _ *AuthorizationServerClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -180,17 +177,17 @@ func (client *AuthorizationServerClient) deleteCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the authorization server specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authsid - Identifier of the authorization server. @@ -218,7 +215,7 @@ func (client *AuthorizationServerClient) Get(ctx context.Context, resourceGroupN } // getCreateRequest creates the Get request. -func (client *AuthorizationServerClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, options *AuthorizationServerClientGetOptions) (*policy.Request, error) { +func (client *AuthorizationServerClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, _ *AuthorizationServerClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -241,7 +238,7 @@ func (client *AuthorizationServerClient) getCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -261,7 +258,7 @@ func (client *AuthorizationServerClient) getHandleResponse(resp *http.Response) // GetEntityTag - Gets the entity state (Etag) version of the authorizationServer specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authsid - Identifier of the authorization server. @@ -290,7 +287,7 @@ func (client *AuthorizationServerClient) GetEntityTag(ctx context.Context, resou } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *AuthorizationServerClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, options *AuthorizationServerClientGetEntityTagOptions) (*policy.Request, error) { +func (client *AuthorizationServerClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, _ *AuthorizationServerClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -313,7 +310,7 @@ func (client *AuthorizationServerClient) getEntityTagCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -330,7 +327,7 @@ func (client *AuthorizationServerClient) getEntityTagHandleResponse(resp *http.R // NewListByServicePager - Lists a collection of authorization servers defined within a service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - AuthorizationServerClientListByServiceOptions contains the optional parameters for the AuthorizationServerClient.NewListByServicePager @@ -381,13 +378,13 @@ func (client *AuthorizationServerClient) listByServiceCreateRequest(ctx context. if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -405,7 +402,7 @@ func (client *AuthorizationServerClient) listByServiceHandleResponse(resp *http. // ListSecrets - Gets the client secret details of the authorization server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authsid - Identifier of the authorization server. @@ -434,7 +431,7 @@ func (client *AuthorizationServerClient) ListSecrets(ctx context.Context, resour } // listSecretsCreateRequest creates the ListSecrets request. -func (client *AuthorizationServerClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, options *AuthorizationServerClientListSecretsOptions) (*policy.Request, error) { +func (client *AuthorizationServerClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, _ *AuthorizationServerClientListSecretsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -457,7 +454,7 @@ func (client *AuthorizationServerClient) listSecretsCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -478,7 +475,7 @@ func (client *AuthorizationServerClient) listSecretsHandleResponse(resp *http.Re // Update - Updates the details of the authorization server specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - authsid - Identifier of the authorization server. @@ -510,7 +507,7 @@ func (client *AuthorizationServerClient) Update(ctx context.Context, resourceGro } // updateCreateRequest creates the Update request. -func (client *AuthorizationServerClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string, parameters AuthorizationServerUpdateContract, options *AuthorizationServerClientUpdateOptions) (*policy.Request, error) { +func (client *AuthorizationServerClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string, parameters AuthorizationServerUpdateContract, _ *AuthorizationServerClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -533,10 +530,10 @@ func (client *AuthorizationServerClient) updateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationserver_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/authorizationserver_client_example_test.go deleted file mode 100644 index d5d97f8cdc5c..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/authorizationserver_client_example_test.go +++ /dev/null @@ -1,335 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListAuthorizationServers.json -func ExampleAuthorizationServerClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAuthorizationServerClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.AuthorizationServerClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.AuthorizationServerCollection = armapimanagement.AuthorizationServerCollection{ - // Value: []*armapimanagement.AuthorizationServerContract{ - // { - // Name: to.Ptr("newauthServer"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationServers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationServers/newauthServer"), - // Properties: &armapimanagement.AuthorizationServerContractProperties{ - // Description: to.Ptr("test server"), - // AuthorizationMethods: []*armapimanagement.AuthorizationMethod{ - // to.Ptr(armapimanagement.AuthorizationMethodGET)}, - // BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethod{ - // to.Ptr(armapimanagement.BearerTokenSendingMethodAuthorizationHeader)}, - // DefaultScope: to.Ptr("read write"), - // ResourceOwnerPassword: to.Ptr("pwd"), - // ResourceOwnerUsername: to.Ptr("un"), - // SupportState: to.Ptr(true), - // TokenEndpoint: to.Ptr("https://www.contoso.com/oauth2/token"), - // AuthorizationEndpoint: to.Ptr("https://www.contoso.com/oauth2/auth"), - // ClientID: to.Ptr("1"), - // ClientRegistrationEndpoint: to.Ptr("https://www.contoso.com/apps"), - // DisplayName: to.Ptr("test2"), - // GrantTypes: []*armapimanagement.GrantType{ - // to.Ptr(armapimanagement.GrantTypeAuthorizationCode), - // to.Ptr(armapimanagement.GrantTypeImplicit)}, - // UseInAPIDocumentation: to.Ptr(false), - // UseInTestConsole: to.Ptr(true), - // }, - // }, - // { - // Name: to.Ptr("newauthServer2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationServers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationServers/newauthServer2"), - // Properties: &armapimanagement.AuthorizationServerContractProperties{ - // Description: to.Ptr("test server"), - // AuthorizationMethods: []*armapimanagement.AuthorizationMethod{ - // to.Ptr(armapimanagement.AuthorizationMethodGET)}, - // BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethod{ - // to.Ptr(armapimanagement.BearerTokenSendingMethodAuthorizationHeader)}, - // ClientAuthenticationMethod: []*armapimanagement.ClientAuthenticationMethod{ - // to.Ptr(armapimanagement.ClientAuthenticationMethodBasic)}, - // DefaultScope: to.Ptr("read write"), - // ResourceOwnerPassword: to.Ptr("pwd"), - // ResourceOwnerUsername: to.Ptr("un"), - // SupportState: to.Ptr(true), - // TokenEndpoint: to.Ptr("https://www.contoso.com/oauth2/token"), - // AuthorizationEndpoint: to.Ptr("https://www.contoso.com/oauth2/auth"), - // ClientID: to.Ptr("1"), - // ClientRegistrationEndpoint: to.Ptr("https://www.contoso.com/apps"), - // DisplayName: to.Ptr("test3"), - // GrantTypes: []*armapimanagement.GrantType{ - // to.Ptr(armapimanagement.GrantTypeAuthorizationCode), - // to.Ptr(armapimanagement.GrantTypeImplicit)}, - // UseInAPIDocumentation: to.Ptr(true), - // UseInTestConsole: to.Ptr(false), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadAuthorizationServer.json -func ExampleAuthorizationServerClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAuthorizationServerClient().GetEntityTag(ctx, "rg1", "apimService1", "newauthServer2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetAuthorizationServer.json -func ExampleAuthorizationServerClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationServerClient().Get(ctx, "rg1", "apimService1", "newauthServer2", 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.AuthorizationServerContract = armapimanagement.AuthorizationServerContract{ - // Name: to.Ptr("newauthServer2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationServers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationServers/newauthServer2"), - // Properties: &armapimanagement.AuthorizationServerContractProperties{ - // Description: to.Ptr("test server"), - // AuthorizationMethods: []*armapimanagement.AuthorizationMethod{ - // to.Ptr(armapimanagement.AuthorizationMethodGET)}, - // BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethod{ - // to.Ptr(armapimanagement.BearerTokenSendingMethodAuthorizationHeader)}, - // ClientAuthenticationMethod: []*armapimanagement.ClientAuthenticationMethod{ - // to.Ptr(armapimanagement.ClientAuthenticationMethodBasic)}, - // DefaultScope: to.Ptr("read write"), - // ResourceOwnerPassword: to.Ptr("pwd"), - // ResourceOwnerUsername: to.Ptr("un"), - // SupportState: to.Ptr(true), - // TokenEndpoint: to.Ptr("https://www.contoso.com/oauth2/token"), - // AuthorizationEndpoint: to.Ptr("https://www.contoso.com/oauth2/auth"), - // ClientID: to.Ptr("1"), - // ClientRegistrationEndpoint: to.Ptr("https://www.contoso.com/apps"), - // DisplayName: to.Ptr("test3"), - // GrantTypes: []*armapimanagement.GrantType{ - // to.Ptr(armapimanagement.GrantTypeAuthorizationCode), - // to.Ptr(armapimanagement.GrantTypeImplicit)}, - // UseInAPIDocumentation: to.Ptr(true), - // UseInTestConsole: to.Ptr(false), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationServer.json -func ExampleAuthorizationServerClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationServerClient().CreateOrUpdate(ctx, "rg1", "apimService1", "newauthServer", armapimanagement.AuthorizationServerContract{ - Properties: &armapimanagement.AuthorizationServerContractProperties{ - Description: to.Ptr("test server"), - AuthorizationMethods: []*armapimanagement.AuthorizationMethod{ - to.Ptr(armapimanagement.AuthorizationMethodGET)}, - BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethod{ - to.Ptr(armapimanagement.BearerTokenSendingMethodAuthorizationHeader)}, - DefaultScope: to.Ptr("read write"), - ResourceOwnerPassword: to.Ptr("pwd"), - ResourceOwnerUsername: to.Ptr("un"), - SupportState: to.Ptr(true), - TokenEndpoint: to.Ptr("https://www.contoso.com/oauth2/token"), - AuthorizationEndpoint: to.Ptr("https://www.contoso.com/oauth2/auth"), - ClientID: to.Ptr("1"), - ClientRegistrationEndpoint: to.Ptr("https://www.contoso.com/apps"), - ClientSecret: to.Ptr("2"), - DisplayName: to.Ptr("test2"), - GrantTypes: []*armapimanagement.GrantType{ - to.Ptr(armapimanagement.GrantTypeAuthorizationCode), - to.Ptr(armapimanagement.GrantTypeImplicit)}, - UseInAPIDocumentation: to.Ptr(true), - UseInTestConsole: to.Ptr(false), - }, - }, &armapimanagement.AuthorizationServerClientCreateOrUpdateOptions{IfMatch: 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.AuthorizationServerContract = armapimanagement.AuthorizationServerContract{ - // Name: to.Ptr("newauthServer"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationServers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationServers/newauthServer"), - // Properties: &armapimanagement.AuthorizationServerContractProperties{ - // Description: to.Ptr("test server"), - // AuthorizationMethods: []*armapimanagement.AuthorizationMethod{ - // to.Ptr(armapimanagement.AuthorizationMethodGET)}, - // BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethod{ - // to.Ptr(armapimanagement.BearerTokenSendingMethodAuthorizationHeader)}, - // DefaultScope: to.Ptr("read write"), - // ResourceOwnerPassword: to.Ptr("pwd"), - // ResourceOwnerUsername: to.Ptr("un"), - // SupportState: to.Ptr(true), - // TokenEndpoint: to.Ptr("https://www.contoso.com/oauth2/token"), - // AuthorizationEndpoint: to.Ptr("https://www.contoso.com/oauth2/auth"), - // ClientID: to.Ptr("1"), - // ClientRegistrationEndpoint: to.Ptr("https://www.contoso.com/apps"), - // DisplayName: to.Ptr("test2"), - // GrantTypes: []*armapimanagement.GrantType{ - // to.Ptr(armapimanagement.GrantTypeAuthorizationCode), - // to.Ptr(armapimanagement.GrantTypeImplicit)}, - // UseInAPIDocumentation: to.Ptr(true), - // UseInTestConsole: to.Ptr(false), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateAuthorizationServer.json -func ExampleAuthorizationServerClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationServerClient().Update(ctx, "rg1", "apimService1", "newauthServer", "*", armapimanagement.AuthorizationServerUpdateContract{ - Properties: &armapimanagement.AuthorizationServerUpdateContractProperties{ - ClientID: to.Ptr("update"), - ClientSecret: to.Ptr("updated"), - UseInAPIDocumentation: to.Ptr(true), - UseInTestConsole: to.Ptr(false), - }, - }, 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.AuthorizationServerContract = armapimanagement.AuthorizationServerContract{ - // Name: to.Ptr("newauthServer"), - // Type: to.Ptr("Microsoft.ApiManagement/service/authorizationServers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationServers/newauthServer"), - // Properties: &armapimanagement.AuthorizationServerContractProperties{ - // Description: to.Ptr("test server"), - // AuthorizationMethods: []*armapimanagement.AuthorizationMethod{ - // to.Ptr(armapimanagement.AuthorizationMethodGET)}, - // BearerTokenSendingMethods: []*armapimanagement.BearerTokenSendingMethod{ - // to.Ptr(armapimanagement.BearerTokenSendingMethodAuthorizationHeader)}, - // ClientAuthenticationMethod: []*armapimanagement.ClientAuthenticationMethod{ - // to.Ptr(armapimanagement.ClientAuthenticationMethodBasic)}, - // DefaultScope: to.Ptr("read write"), - // ResourceOwnerPassword: to.Ptr("pwd"), - // ResourceOwnerUsername: to.Ptr("un"), - // SupportState: to.Ptr(true), - // TokenEndpoint: to.Ptr("https://www.contoso.com/oauth2/token"), - // AuthorizationEndpoint: to.Ptr("https://www.contoso.com/oauth2/auth"), - // ClientID: to.Ptr("updated"), - // ClientRegistrationEndpoint: to.Ptr("https://www.contoso.com/apps"), - // DisplayName: to.Ptr("test3"), - // GrantTypes: []*armapimanagement.GrantType{ - // to.Ptr(armapimanagement.GrantTypeAuthorizationCode), - // to.Ptr(armapimanagement.GrantTypeImplicit)}, - // UseInAPIDocumentation: to.Ptr(true), - // UseInTestConsole: to.Ptr(false), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteAuthorizationServer.json -func ExampleAuthorizationServerClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAuthorizationServerClient().Delete(ctx, "rg1", "apimService1", "newauthServer2", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementAuthorizationServerListSecrets.json -func ExampleAuthorizationServerClient_ListSecrets() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAuthorizationServerClient().ListSecrets(ctx, "rg1", "apimService1", "newauthServer2", 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.AuthorizationServerSecretsContract = armapimanagement.AuthorizationServerSecretsContract{ - // ClientSecret: to.Ptr("2"), - // ResourceOwnerPassword: to.Ptr("pwd"), - // ResourceOwnerUsername: to.Ptr("un"), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/autorest.md b/sdk/resourcemanager/apimanagement/armapimanagement/autorest.md index 5d7bd154d435..0286845ad89f 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/autorest.md +++ b/sdk/resourcemanager/apimanagement/armapimanagement/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/apimanagement/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/apimanagement/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.1.0 -tag: package-2022-08 +module-version: 3.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/backend_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/backend_client.go index c4d8dfcbf830..559d6ccec924 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/backend_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/backend_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type BackendClient struct { } // NewBackendClient creates a new instance of BackendClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewBackendClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BackendClient, error) { @@ -47,7 +44,7 @@ func NewBackendClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Creates or Updates a backend. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. @@ -99,12 +96,12 @@ func (client *BackendClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -126,7 +123,7 @@ func (client *BackendClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - Deletes the specified backend. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. @@ -155,7 +152,7 @@ func (client *BackendClient) Delete(ctx context.Context, resourceGroupName strin } // deleteCreateRequest creates the Delete request. -func (client *BackendClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string, options *BackendClientDeleteOptions) (*policy.Request, error) { +func (client *BackendClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string, _ *BackendClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -178,17 +175,17 @@ func (client *BackendClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the backend specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. @@ -216,7 +213,7 @@ func (client *BackendClient) Get(ctx context.Context, resourceGroupName string, } // getCreateRequest creates the Get request. -func (client *BackendClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, options *BackendClientGetOptions) (*policy.Request, error) { +func (client *BackendClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, _ *BackendClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -239,7 +236,7 @@ func (client *BackendClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -259,7 +256,7 @@ func (client *BackendClient) getHandleResponse(resp *http.Response) (BackendClie // GetEntityTag - Gets the entity state (Etag) version of the backend specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. @@ -287,7 +284,7 @@ func (client *BackendClient) GetEntityTag(ctx context.Context, resourceGroupName } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *BackendClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, options *BackendClientGetEntityTagOptions) (*policy.Request, error) { +func (client *BackendClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, _ *BackendClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -310,7 +307,7 @@ func (client *BackendClient) getEntityTagCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -327,7 +324,7 @@ func (client *BackendClient) getEntityTagHandleResponse(resp *http.Response) (Ba // NewListByServicePager - Lists a collection of backends in the specified service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - BackendClientListByServiceOptions contains the optional parameters for the BackendClient.NewListByServicePager @@ -378,13 +375,13 @@ func (client *BackendClient) listByServiceCreateRequest(ctx context.Context, res if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -403,7 +400,7 @@ func (client *BackendClient) listByServiceHandleResponse(resp *http.Response) (B // If no timeout was specified, timeout of 2 minutes is used. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. @@ -453,7 +450,7 @@ func (client *BackendClient) reconnectCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { @@ -468,7 +465,7 @@ func (client *BackendClient) reconnectCreateRequest(ctx context.Context, resourc // Update - Updates an existing backend. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. @@ -499,7 +496,7 @@ func (client *BackendClient) Update(ctx context.Context, resourceGroupName strin } // updateCreateRequest creates the Update request. -func (client *BackendClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string, parameters BackendUpdateParameters, options *BackendClientUpdateOptions) (*policy.Request, error) { +func (client *BackendClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string, parameters BackendUpdateParameters, _ *BackendClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -522,10 +519,10 @@ func (client *BackendClient) updateCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/backend_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/backend_client_example_test.go deleted file mode 100644 index a25353dc84b0..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/backend_client_example_test.go +++ /dev/null @@ -1,423 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListBackends.json -func ExampleBackendClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBackendClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.BackendClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.BackendCollection = armapimanagement.BackendCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.BackendContract{ - // { - // Name: to.Ptr("proxybackend"), - // Type: to.Ptr("Microsoft.ApiManagement/service/backends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/proxybackend"), - // Properties: &armapimanagement.BackendContractProperties{ - // Description: to.Ptr("description5308"), - // Credentials: &armapimanagement.BackendCredentialsContract{ - // Authorization: &armapimanagement.BackendAuthorizationHeaderCredentials{ - // Parameter: to.Ptr("opensesma"), - // Scheme: to.Ptr("Basic"), - // }, - // Header: map[string][]*string{ - // "x-my-1": []*string{ - // to.Ptr("val1"), - // to.Ptr("val2")}, - // }, - // Query: map[string][]*string{ - // "sv": []*string{ - // to.Ptr("xx"), - // to.Ptr("bb"), - // to.Ptr("cc")}, - // }, - // }, - // Proxy: &armapimanagement.BackendProxyContract{ - // Password: to.Ptr(""), - // URL: to.Ptr("http://192.168.1.1:8080"), - // Username: to.Ptr("Contoso\\admin"), - // }, - // TLS: &armapimanagement.BackendTLSProperties{ - // ValidateCertificateChain: to.Ptr(false), - // ValidateCertificateName: to.Ptr(false), - // }, - // URL: to.Ptr("https://backendname2644/"), - // Protocol: to.Ptr(armapimanagement.BackendProtocolHTTP), - // }, - // }, - // { - // Name: to.Ptr("sfbackend"), - // Type: to.Ptr("Microsoft.ApiManagement/service/backends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/sfbackend"), - // Properties: &armapimanagement.BackendContractProperties{ - // Description: to.Ptr("Service Fabric Test App 1"), - // Properties: &armapimanagement.BackendProperties{ - // ServiceFabricCluster: &armapimanagement.BackendServiceFabricClusterProperties{ - // ClientCertificateID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1"), - // ManagementEndpoints: []*string{ - // to.Ptr("https://somecluster.com")}, - // MaxPartitionResolutionRetries: to.Ptr[int32](5), - // ServerX509Names: []*armapimanagement.X509CertificateName{ - // { - // Name: to.Ptr("ServerCommonName1"), - // IssuerCertificateThumbprint: to.Ptr("IssuerCertificateThumbprint1"), - // }}, - // }, - // }, - // URL: to.Ptr("fabric:/mytestapp/mytestservice"), - // Protocol: to.Ptr(armapimanagement.BackendProtocolHTTP), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadBackend.json -func ExampleBackendClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewBackendClient().GetEntityTag(ctx, "rg1", "apimService1", "sfbackend", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetBackend.json -func ExampleBackendClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackendClient().Get(ctx, "rg1", "apimService1", "sfbackend", 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.BackendContract = armapimanagement.BackendContract{ - // Name: to.Ptr("sfbackend"), - // Type: to.Ptr("Microsoft.ApiManagement/service/backends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/sfbackend"), - // Properties: &armapimanagement.BackendContractProperties{ - // Description: to.Ptr("Service Fabric Test App 1"), - // Properties: &armapimanagement.BackendProperties{ - // ServiceFabricCluster: &armapimanagement.BackendServiceFabricClusterProperties{ - // ClientCertificateID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1"), - // ManagementEndpoints: []*string{ - // to.Ptr("https://somecluster.com")}, - // MaxPartitionResolutionRetries: to.Ptr[int32](5), - // ServerX509Names: []*armapimanagement.X509CertificateName{ - // { - // Name: to.Ptr("ServerCommonName1"), - // IssuerCertificateThumbprint: to.Ptr("IssuerCertificateThumbprint1"), - // }}, - // }, - // }, - // URL: to.Ptr("fabric:/mytestapp/mytestservice"), - // Protocol: to.Ptr(armapimanagement.BackendProtocolHTTP), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateBackendProxyBackend.json -func ExampleBackendClient_CreateOrUpdate_apiManagementCreateBackendProxyBackend() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackendClient().CreateOrUpdate(ctx, "rg1", "apimService1", "proxybackend", armapimanagement.BackendContract{ - Properties: &armapimanagement.BackendContractProperties{ - Description: to.Ptr("description5308"), - Credentials: &armapimanagement.BackendCredentialsContract{ - Authorization: &armapimanagement.BackendAuthorizationHeaderCredentials{ - Parameter: to.Ptr("opensesma"), - Scheme: to.Ptr("Basic"), - }, - Header: map[string][]*string{ - "x-my-1": { - to.Ptr("val1"), - to.Ptr("val2")}, - }, - Query: map[string][]*string{ - "sv": { - to.Ptr("xx"), - to.Ptr("bb"), - to.Ptr("cc")}, - }, - }, - Proxy: &armapimanagement.BackendProxyContract{ - Password: to.Ptr(""), - URL: to.Ptr("http://192.168.1.1:8080"), - Username: to.Ptr("Contoso\\admin"), - }, - TLS: &armapimanagement.BackendTLSProperties{ - ValidateCertificateChain: to.Ptr(true), - ValidateCertificateName: to.Ptr(true), - }, - URL: to.Ptr("https://backendname2644/"), - Protocol: to.Ptr(armapimanagement.BackendProtocolHTTP), - }, - }, &armapimanagement.BackendClientCreateOrUpdateOptions{IfMatch: 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.BackendContract = armapimanagement.BackendContract{ - // Name: to.Ptr("proxybackend"), - // Type: to.Ptr("Microsoft.ApiManagement/service/backends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/proxybackend"), - // Properties: &armapimanagement.BackendContractProperties{ - // Description: to.Ptr("description5308"), - // Credentials: &armapimanagement.BackendCredentialsContract{ - // Authorization: &armapimanagement.BackendAuthorizationHeaderCredentials{ - // Parameter: to.Ptr("opensesma"), - // Scheme: to.Ptr("Basic"), - // }, - // Header: map[string][]*string{ - // "x-my-1": []*string{ - // to.Ptr("val1"), - // to.Ptr("val2")}, - // }, - // Query: map[string][]*string{ - // "sv": []*string{ - // to.Ptr("xx"), - // to.Ptr("bb"), - // to.Ptr("cc")}, - // }, - // }, - // Proxy: &armapimanagement.BackendProxyContract{ - // Password: to.Ptr(""), - // URL: to.Ptr("http://192.168.1.1:8080"), - // Username: to.Ptr("Contoso\\admin"), - // }, - // TLS: &armapimanagement.BackendTLSProperties{ - // ValidateCertificateChain: to.Ptr(false), - // ValidateCertificateName: to.Ptr(false), - // }, - // URL: to.Ptr("https://backendname2644/"), - // Protocol: to.Ptr(armapimanagement.BackendProtocolHTTP), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateBackendServiceFabric.json -func ExampleBackendClient_CreateOrUpdate_apiManagementCreateBackendServiceFabric() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackendClient().CreateOrUpdate(ctx, "rg1", "apimService1", "sfbackend", armapimanagement.BackendContract{ - Properties: &armapimanagement.BackendContractProperties{ - Description: to.Ptr("Service Fabric Test App 1"), - Properties: &armapimanagement.BackendProperties{ - ServiceFabricCluster: &armapimanagement.BackendServiceFabricClusterProperties{ - ClientCertificateID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1"), - ManagementEndpoints: []*string{ - to.Ptr("https://somecluster.com")}, - MaxPartitionResolutionRetries: to.Ptr[int32](5), - ServerX509Names: []*armapimanagement.X509CertificateName{ - { - Name: to.Ptr("ServerCommonName1"), - IssuerCertificateThumbprint: to.Ptr("IssuerCertificateThumbprint1"), - }}, - }, - }, - URL: to.Ptr("fabric:/mytestapp/mytestservice"), - Protocol: to.Ptr(armapimanagement.BackendProtocolHTTP), - }, - }, &armapimanagement.BackendClientCreateOrUpdateOptions{IfMatch: 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.BackendContract = armapimanagement.BackendContract{ - // Name: to.Ptr("sfbackend"), - // Type: to.Ptr("Microsoft.ApiManagement/service/backends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/sfbackend"), - // Properties: &armapimanagement.BackendContractProperties{ - // Description: to.Ptr("Service Fabric Test App 1"), - // Properties: &armapimanagement.BackendProperties{ - // ServiceFabricCluster: &armapimanagement.BackendServiceFabricClusterProperties{ - // ClientCertificateID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1"), - // ManagementEndpoints: []*string{ - // to.Ptr("https://somecluster.com")}, - // MaxPartitionResolutionRetries: to.Ptr[int32](5), - // ServerX509Names: []*armapimanagement.X509CertificateName{ - // { - // Name: to.Ptr("ServerCommonName1"), - // IssuerCertificateThumbprint: to.Ptr("IssuerCertificateThumbprint1"), - // }}, - // }, - // }, - // URL: to.Ptr("fabric:/mytestapp/mytestservice"), - // Protocol: to.Ptr(armapimanagement.BackendProtocolHTTP), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateBackend.json -func ExampleBackendClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackendClient().Update(ctx, "rg1", "apimService1", "proxybackend", "*", armapimanagement.BackendUpdateParameters{ - Properties: &armapimanagement.BackendUpdateParameterProperties{ - Description: to.Ptr("description5308"), - TLS: &armapimanagement.BackendTLSProperties{ - ValidateCertificateChain: to.Ptr(false), - ValidateCertificateName: to.Ptr(true), - }, - }, - }, 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.BackendContract = armapimanagement.BackendContract{ - // Name: to.Ptr("proxybackend"), - // Type: to.Ptr("Microsoft.ApiManagement/service/backends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/proxybackend"), - // Properties: &armapimanagement.BackendContractProperties{ - // Description: to.Ptr("description5308"), - // Credentials: &armapimanagement.BackendCredentialsContract{ - // Authorization: &armapimanagement.BackendAuthorizationHeaderCredentials{ - // Parameter: to.Ptr("opensesma"), - // Scheme: to.Ptr("Basic"), - // }, - // Header: map[string][]*string{ - // "x-my-1": []*string{ - // to.Ptr("val1"), - // to.Ptr("val2")}, - // }, - // Query: map[string][]*string{ - // "sv": []*string{ - // to.Ptr("xx"), - // to.Ptr("bb"), - // to.Ptr("cc")}, - // }, - // }, - // Proxy: &armapimanagement.BackendProxyContract{ - // Password: to.Ptr(""), - // URL: to.Ptr("http://192.168.1.1:8080"), - // Username: to.Ptr("Contoso\\admin"), - // }, - // TLS: &armapimanagement.BackendTLSProperties{ - // ValidateCertificateChain: to.Ptr(false), - // ValidateCertificateName: to.Ptr(true), - // }, - // URL: to.Ptr("https://backendname2644/"), - // Protocol: to.Ptr(armapimanagement.BackendProtocolHTTP), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteBackend.json -func ExampleBackendClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewBackendClient().Delete(ctx, "rg1", "apimService1", "sfbackend", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementBackendReconnect.json -func ExampleBackendClient_Reconnect() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewBackendClient().Reconnect(ctx, "rg1", "apimService1", "proxybackend", &armapimanagement.BackendClientReconnectOptions{Parameters: &armapimanagement.BackendReconnectContract{ - Properties: &armapimanagement.BackendReconnectProperties{ - After: to.Ptr("PT3S"), - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/cache_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/cache_client.go index 49b77356c732..1fc470fcd554 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/cache_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/cache_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type CacheClient struct { } // NewCacheClient creates a new instance of CacheClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewCacheClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CacheClient, error) { @@ -47,7 +44,7 @@ func NewCacheClient(subscriptionID string, credential azcore.TokenCredential, op // CreateOrUpdate - Creates or updates an External Cache to be used in Api Management instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - cacheID - Identifier of the Cache entity. Cache identifier (should be either 'default' or valid Azure region identifier). @@ -99,12 +96,12 @@ func (client *CacheClient) createOrUpdateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -126,7 +123,7 @@ func (client *CacheClient) createOrUpdateHandleResponse(resp *http.Response) (Ca // Delete - Deletes specific Cache. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - cacheID - Identifier of the Cache entity. Cache identifier (should be either 'default' or valid Azure region identifier). @@ -155,7 +152,7 @@ func (client *CacheClient) Delete(ctx context.Context, resourceGroupName string, } // deleteCreateRequest creates the Delete request. -func (client *CacheClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string, options *CacheClientDeleteOptions) (*policy.Request, error) { +func (client *CacheClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string, _ *CacheClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -178,17 +175,17 @@ func (client *CacheClient) deleteCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the Cache specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - cacheID - Identifier of the Cache entity. Cache identifier (should be either 'default' or valid Azure region identifier). @@ -216,7 +213,7 @@ func (client *CacheClient) Get(ctx context.Context, resourceGroupName string, se } // getCreateRequest creates the Get request. -func (client *CacheClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, options *CacheClientGetOptions) (*policy.Request, error) { +func (client *CacheClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, _ *CacheClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -239,7 +236,7 @@ func (client *CacheClient) getCreateRequest(ctx context.Context, resourceGroupNa return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -259,7 +256,7 @@ func (client *CacheClient) getHandleResponse(resp *http.Response) (CacheClientGe // GetEntityTag - Gets the entity state (Etag) version of the Cache specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - cacheID - Identifier of the Cache entity. Cache identifier (should be either 'default' or valid Azure region identifier). @@ -287,7 +284,7 @@ func (client *CacheClient) GetEntityTag(ctx context.Context, resourceGroupName s } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *CacheClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, options *CacheClientGetEntityTagOptions) (*policy.Request, error) { +func (client *CacheClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, _ *CacheClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -310,7 +307,7 @@ func (client *CacheClient) getEntityTagCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -327,7 +324,7 @@ func (client *CacheClient) getEntityTagHandleResponse(resp *http.Response) (Cach // NewListByServicePager - Lists a collection of all external Caches in the specified service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - CacheClientListByServiceOptions contains the optional parameters for the CacheClient.NewListByServicePager method. @@ -374,13 +371,13 @@ func (client *CacheClient) listByServiceCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -398,7 +395,7 @@ func (client *CacheClient) listByServiceHandleResponse(resp *http.Response) (Cac // Update - Updates the details of the cache specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - cacheID - Identifier of the Cache entity. Cache identifier (should be either 'default' or valid Azure region identifier). @@ -429,7 +426,7 @@ func (client *CacheClient) Update(ctx context.Context, resourceGroupName string, } // updateCreateRequest creates the Update request. -func (client *CacheClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string, parameters CacheUpdateParameters, options *CacheClientUpdateOptions) (*policy.Request, error) { +func (client *CacheClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string, parameters CacheUpdateParameters, _ *CacheClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -452,10 +449,10 @@ func (client *CacheClient) updateCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/cache_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/cache_client_example_test.go deleted file mode 100644 index c628a17f90e0..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/cache_client_example_test.go +++ /dev/null @@ -1,199 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListCaches.json -func ExampleCacheClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCacheClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.CacheClientListByServiceOptions{Top: nil, - Skip: 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.CacheCollection = armapimanagement.CacheCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.CacheContract{ - // { - // Name: to.Ptr("c1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/caches"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/caches/c1"), - // Properties: &armapimanagement.CacheContractProperties{ - // Description: to.Ptr("Redis cache instances in West India"), - // ConnectionString: to.Ptr("{{5f7fbca77a891a2200f3db38}}"), - // ResourceID: to.Ptr("https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/apimservice1"), - // UseFromLocation: to.Ptr("default"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadCache.json -func ExampleCacheClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewCacheClient().GetEntityTag(ctx, "rg1", "apimService1", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetCache.json -func ExampleCacheClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCacheClient().Get(ctx, "rg1", "apimService1", "c1", 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.CacheContract = armapimanagement.CacheContract{ - // Name: to.Ptr("c1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/caches"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/caches/c1"), - // Properties: &armapimanagement.CacheContractProperties{ - // Description: to.Ptr("Redis cache instances in West India"), - // ConnectionString: to.Ptr("{{5f7fbca77a891a2200f3db38}}"), - // ResourceID: to.Ptr("https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/apimservice1"), - // UseFromLocation: to.Ptr("default"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateCache.json -func ExampleCacheClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCacheClient().CreateOrUpdate(ctx, "rg1", "apimService1", "c1", armapimanagement.CacheContract{ - Properties: &armapimanagement.CacheContractProperties{ - Description: to.Ptr("Redis cache instances in West India"), - ConnectionString: to.Ptr("apim.redis.cache.windows.net:6380,password=xc,ssl=True,abortConnect=False"), - ResourceID: to.Ptr("https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/apimservice1"), - UseFromLocation: to.Ptr("default"), - }, - }, &armapimanagement.CacheClientCreateOrUpdateOptions{IfMatch: 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.CacheContract = armapimanagement.CacheContract{ - // Name: to.Ptr("c1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/caches"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/caches/c1"), - // Properties: &armapimanagement.CacheContractProperties{ - // Description: to.Ptr("Redis cache instances in West India"), - // ConnectionString: to.Ptr("{{5f7fbca77a891a2200f3db38}}"), - // ResourceID: to.Ptr("https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/apimservice1"), - // UseFromLocation: to.Ptr("default"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateCache.json -func ExampleCacheClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCacheClient().Update(ctx, "rg1", "apimService1", "c1", "*", armapimanagement.CacheUpdateParameters{ - Properties: &armapimanagement.CacheUpdateProperties{ - UseFromLocation: to.Ptr("westindia"), - }, - }, 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.CacheContract = armapimanagement.CacheContract{ - // Name: to.Ptr("c1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/caches"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/caches/c1"), - // Properties: &armapimanagement.CacheContractProperties{ - // Description: to.Ptr("Redis cache instances in West India"), - // ConnectionString: to.Ptr("{{5f7fbca77a891a2200f3db38}}"), - // ResourceID: to.Ptr("https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/apimservice1"), - // UseFromLocation: to.Ptr("westindia"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteCache.json -func ExampleCacheClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewCacheClient().Delete(ctx, "rg1", "apimService1", "southindia", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/certificate_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/certificate_client.go index 03d47683c8a5..39fb9c5ee851 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/certificate_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/certificate_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type CertificateClient struct { } // NewCertificateClient creates a new instance of CertificateClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewCertificateClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CertificateClient, error) { @@ -47,7 +44,7 @@ func NewCertificateClient(subscriptionID string, credential azcore.TokenCredenti // CreateOrUpdate - Creates or updates the certificate being used for authentication with the backend. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. @@ -100,12 +97,12 @@ func (client *CertificateClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -127,7 +124,7 @@ func (client *CertificateClient) createOrUpdateHandleResponse(resp *http.Respons // Delete - Deletes specific certificate. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. @@ -156,7 +153,7 @@ func (client *CertificateClient) Delete(ctx context.Context, resourceGroupName s } // deleteCreateRequest creates the Delete request. -func (client *CertificateClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, ifMatch string, options *CertificateClientDeleteOptions) (*policy.Request, error) { +func (client *CertificateClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, ifMatch string, _ *CertificateClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -179,17 +176,17 @@ func (client *CertificateClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the certificate specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. @@ -217,7 +214,7 @@ func (client *CertificateClient) Get(ctx context.Context, resourceGroupName stri } // getCreateRequest creates the Get request. -func (client *CertificateClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, options *CertificateClientGetOptions) (*policy.Request, error) { +func (client *CertificateClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, _ *CertificateClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -240,7 +237,7 @@ func (client *CertificateClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -260,7 +257,7 @@ func (client *CertificateClient) getHandleResponse(resp *http.Response) (Certifi // GetEntityTag - Gets the entity state (Etag) version of the certificate specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. @@ -289,7 +286,7 @@ func (client *CertificateClient) GetEntityTag(ctx context.Context, resourceGroup } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *CertificateClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, options *CertificateClientGetEntityTagOptions) (*policy.Request, error) { +func (client *CertificateClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, _ *CertificateClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -312,7 +309,7 @@ func (client *CertificateClient) getEntityTagCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -329,7 +326,7 @@ func (client *CertificateClient) getEntityTagHandleResponse(resp *http.Response) // NewListByServicePager - Lists a collection of all certificates in the specified service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - CertificateClientListByServiceOptions contains the optional parameters for the CertificateClient.NewListByServicePager @@ -380,16 +377,16 @@ func (client *CertificateClient) listByServiceCreateRequest(ctx context.Context, if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.IsKeyVaultRefreshFailed != nil { reqQP.Set("isKeyVaultRefreshFailed", strconv.FormatBool(*options.IsKeyVaultRefreshFailed)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -407,7 +404,7 @@ func (client *CertificateClient) listByServiceHandleResponse(resp *http.Response // RefreshSecret - From KeyVault, Refresh the certificate being used for authentication with the backend. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. @@ -436,7 +433,7 @@ func (client *CertificateClient) RefreshSecret(ctx context.Context, resourceGrou } // refreshSecretCreateRequest creates the RefreshSecret request. -func (client *CertificateClient) refreshSecretCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, options *CertificateClientRefreshSecretOptions) (*policy.Request, error) { +func (client *CertificateClient) refreshSecretCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, _ *CertificateClientRefreshSecretOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -459,7 +456,7 @@ func (client *CertificateClient) refreshSecretCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/certificate_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/certificate_client_example_test.go deleted file mode 100644 index 43dda733c925..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/certificate_client_example_test.go +++ /dev/null @@ -1,300 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListCertificates.json -func ExampleCertificateClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCertificateClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.CertificateClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: nil, - IsKeyVaultRefreshFailed: 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.CertificateCollection = armapimanagement.CertificateCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.CertificateContract{ - // { - // Name: to.Ptr("templateCert1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/certificates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/kjoshiarmtemplateCert1"), - // Properties: &armapimanagement.CertificateContractProperties{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-23T17:03:41.000Z"); return t}()), - // Subject: to.Ptr("CN=mutual-authcert"), - // Thumbprint: to.Ptr("EBA************************48594A6"), - // }, - // }, - // { - // Name: to.Ptr("templateCertkv"), - // Type: to.Ptr("Microsoft.ApiManagement/service/certificates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/templateCertkv"), - // Properties: &armapimanagement.CertificateContractProperties{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2037-01-01T07:00:00.000Z"); return t}()), - // KeyVault: &armapimanagement.KeyVaultContractProperties{ - // IdentityClientID: to.Ptr("ceaa6b06-c00f-43ef-99ac-f53d1fe876a0"), - // SecretIdentifier: to.Ptr("https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert"), - // LastStatus: &armapimanagement.KeyVaultLastAccessStatusContractProperties{ - // Code: to.Ptr("Success"), - // TimeStampUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-22T00:24:53.319Z"); return t}()), - // }, - // }, - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("EA**********************9AD690"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadCertificate.json -func ExampleCertificateClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewCertificateClient().GetEntityTag(ctx, "rg1", "apimService1", "templateCert1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetCertificate.json -func ExampleCertificateClient_Get_apiManagementGetCertificate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCertificateClient().Get(ctx, "rg1", "apimService1", "templateCert1", 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.CertificateContract = armapimanagement.CertificateContract{ - // Name: to.Ptr("templateCert1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/certificates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/templateCert1"), - // Properties: &armapimanagement.CertificateContractProperties{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-23T17:03:41.000Z"); return t}()), - // Subject: to.Ptr("CN=mutual-authcert"), - // Thumbprint: to.Ptr("EBA**********************8594A6"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetCertificateWithKeyVault.json -func ExampleCertificateClient_Get_apiManagementGetCertificateWithKeyVault() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCertificateClient().Get(ctx, "rg1", "apimService1", "templateCertkv", 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.CertificateContract = armapimanagement.CertificateContract{ - // Name: to.Ptr("templateCertkv"), - // Type: to.Ptr("Microsoft.ApiManagement/service/certificates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/templateCertkv"), - // Properties: &armapimanagement.CertificateContractProperties{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2037-01-01T07:00:00.000Z"); return t}()), - // KeyVault: &armapimanagement.KeyVaultContractProperties{ - // IdentityClientID: to.Ptr("ceaa6b06-c00f-43ef-99ac-f53d1fe876a0"), - // SecretIdentifier: to.Ptr("https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert"), - // LastStatus: &armapimanagement.KeyVaultLastAccessStatusContractProperties{ - // Code: to.Ptr("Success"), - // TimeStampUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-22T00:24:53.319Z"); return t}()), - // }, - // }, - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("EA**********************9AD690"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateCertificate.json -func ExampleCertificateClient_CreateOrUpdate_apiManagementCreateCertificate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCertificateClient().CreateOrUpdate(ctx, "rg1", "apimService1", "tempcert", armapimanagement.CertificateCreateOrUpdateParameters{ - Properties: &armapimanagement.CertificateCreateOrUpdateProperties{ - Data: to.Ptr("****************Base 64 Encoded Certificate *******************************"), - Password: to.Ptr("****Certificate Password******"), - }, - }, &armapimanagement.CertificateClientCreateOrUpdateOptions{IfMatch: 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.CertificateContract = armapimanagement.CertificateContract{ - // Name: to.Ptr("tempcert"), - // Type: to.Ptr("Microsoft.ApiManagement/service/certificates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/tempcert"), - // Properties: &armapimanagement.CertificateContractProperties{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-17T21:55:07.000Z"); return t}()), - // Subject: to.Ptr("CN=contoso.com"), - // Thumbprint: to.Ptr("*******************3"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateCertificateWithKeyVault.json -func ExampleCertificateClient_CreateOrUpdate_apiManagementCreateCertificateWithKeyVault() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCertificateClient().CreateOrUpdate(ctx, "rg1", "apimService1", "templateCertkv", armapimanagement.CertificateCreateOrUpdateParameters{ - Properties: &armapimanagement.CertificateCreateOrUpdateProperties{ - KeyVault: &armapimanagement.KeyVaultContractCreateProperties{ - IdentityClientID: to.Ptr("ceaa6b06-c00f-43ef-99ac-f53d1fe876a0"), - SecretIdentifier: to.Ptr("https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert"), - }, - }, - }, &armapimanagement.CertificateClientCreateOrUpdateOptions{IfMatch: 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.CertificateContract = armapimanagement.CertificateContract{ - // Name: to.Ptr("templateCertkv"), - // Type: to.Ptr("Microsoft.ApiManagement/service/certificates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/templateCertkv"), - // Properties: &armapimanagement.CertificateContractProperties{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2037-01-01T07:00:00.000Z"); return t}()), - // KeyVault: &armapimanagement.KeyVaultContractProperties{ - // IdentityClientID: to.Ptr("ceaa6b06-c00f-43ef-99ac-f53d1fe876a0"), - // SecretIdentifier: to.Ptr("https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert"), - // LastStatus: &armapimanagement.KeyVaultLastAccessStatusContractProperties{ - // Code: to.Ptr("Success"), - // TimeStampUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-22T00:24:53.319Z"); return t}()), - // }, - // }, - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("EA**********************9AD690"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteCertificate.json -func ExampleCertificateClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewCertificateClient().Delete(ctx, "rg1", "apimService1", "tempcert", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementRefreshCertificate.json -func ExampleCertificateClient_RefreshSecret() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCertificateClient().RefreshSecret(ctx, "rg1", "apimService1", "templateCertkv", 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.CertificateContract = armapimanagement.CertificateContract{ - // Name: to.Ptr("templateCertkv"), - // Type: to.Ptr("Microsoft.ApiManagement/service/certificates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/templateCertkv"), - // Properties: &armapimanagement.CertificateContractProperties{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2037-01-01T07:00:00.000Z"); return t}()), - // KeyVault: &armapimanagement.KeyVaultContractProperties{ - // IdentityClientID: to.Ptr("ceaa6b06-c00f-43ef-99ac-f53d1fe876a0"), - // SecretIdentifier: to.Ptr("https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert"), - // LastStatus: &armapimanagement.KeyVaultLastAccessStatusContractProperties{ - // Code: to.Ptr("Success"), - // TimeStampUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-22T00:24:53.319Z"); return t}()), - // }, - // }, - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("EA**********************9AD690"), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/client.go b/sdk/resourcemanager/apimanagement/armapimanagement/client.go index e6f7690158f5..f671f6203b2f 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type Client struct { } // NewClient creates a new instance of Client with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { @@ -47,7 +44,7 @@ func NewClient(subscriptionID string, credential azcore.TokenCredential, options // and returns metrics for the connection, as well as errors encountered while trying to establish it. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - connectivityCheckRequestParams - Connectivity Check request parameters. @@ -75,7 +72,7 @@ func (client *Client) BeginPerformConnectivityCheckAsync(ctx context.Context, re // and returns metrics for the connection, as well as errors encountered while trying to establish it. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *Client) performConnectivityCheckAsync(ctx context.Context, resourceGroupName string, serviceName string, connectivityCheckRequestParams ConnectivityCheckRequest, options *ClientBeginPerformConnectivityCheckAsyncOptions) (*http.Response, error) { var err error const operationName = "Client.BeginPerformConnectivityCheckAsync" @@ -98,7 +95,7 @@ func (client *Client) performConnectivityCheckAsync(ctx context.Context, resourc } // performConnectivityCheckAsyncCreateRequest creates the PerformConnectivityCheckAsync request. -func (client *Client) performConnectivityCheckAsyncCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, connectivityCheckRequestParams ConnectivityCheckRequest, options *ClientBeginPerformConnectivityCheckAsyncOptions) (*policy.Request, error) { +func (client *Client) performConnectivityCheckAsyncCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, connectivityCheckRequestParams ConnectivityCheckRequest, _ *ClientBeginPerformConnectivityCheckAsyncOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -117,7 +114,7 @@ func (client *Client) performConnectivityCheckAsyncCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, connectivityCheckRequestParams); err != nil { diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/client_example_test.go deleted file mode 100644 index 46f6e79cbe9c..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/client_example_test.go +++ /dev/null @@ -1,154 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPerformConnectivityCheckHttpConnect.json -func ExampleClient_BeginPerformConnectivityCheckAsync_httpConnectivityCheck() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginPerformConnectivityCheckAsync(ctx, "rg1", "apimService1", armapimanagement.ConnectivityCheckRequest{ - Destination: &armapimanagement.ConnectivityCheckRequestDestination{ - Address: to.Ptr("https://microsoft.com"), - Port: to.Ptr[int64](3306), - }, - ProtocolConfiguration: &armapimanagement.ConnectivityCheckRequestProtocolConfiguration{ - HTTPConfiguration: &armapimanagement.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration{ - Method: to.Ptr(armapimanagement.MethodGET), - Headers: []*armapimanagement.HTTPHeader{ - { - Name: to.Ptr("Authorization"), - Value: to.Ptr("******"), - }}, - ValidStatusCodes: []*int64{ - to.Ptr[int64](200), - to.Ptr[int64](204)}, - }, - }, - Source: &armapimanagement.ConnectivityCheckRequestSource{ - Region: to.Ptr("northeurope"), - }, - Protocol: to.Ptr(armapimanagement.ConnectivityCheckProtocolHTTPS), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ConnectivityCheckResponse = armapimanagement.ConnectivityCheckResponse{ - // AvgLatencyInMs: to.Ptr[int64](260), - // ConnectionStatus: to.Ptr(armapimanagement.ConnectionStatus("Reachable")), - // Hops: []*armapimanagement.ConnectivityHop{ - // { - // Type: to.Ptr("Source"), - // Address: to.Ptr("20.82.216.48"), - // ID: to.Ptr("c60e2296-5ebc-48cc-80e8-7e6d2981e7b2"), - // Issues: []*armapimanagement.ConnectivityIssue{ - // }, - // NextHopIDs: []*string{ - // to.Ptr("26aa44e7-04f1-462f-aa5d-5951957b5650")}, - // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // }, - // { - // Type: to.Ptr("Internet"), - // Address: to.Ptr("40.113.200.201"), - // ID: to.Ptr("26aa44e7-04f1-462f-aa5d-5951957b5650"), - // Issues: []*armapimanagement.ConnectivityIssue{ - // }, - // NextHopIDs: []*string{ - // }, - // }}, - // MaxLatencyInMs: to.Ptr[int64](281), - // MinLatencyInMs: to.Ptr[int64](250), - // ProbesFailed: to.Ptr[int64](0), - // ProbesSent: to.Ptr[int64](3), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPerformConnectivityCheck.json -func ExampleClient_BeginPerformConnectivityCheckAsync_tcpConnectivityCheck() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginPerformConnectivityCheckAsync(ctx, "rg1", "apimService1", armapimanagement.ConnectivityCheckRequest{ - Destination: &armapimanagement.ConnectivityCheckRequestDestination{ - Address: to.Ptr("8.8.8.8"), - Port: to.Ptr[int64](53), - }, - PreferredIPVersion: to.Ptr(armapimanagement.PreferredIPVersionIPv4), - Source: &armapimanagement.ConnectivityCheckRequestSource{ - Region: to.Ptr("northeurope"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ConnectivityCheckResponse = armapimanagement.ConnectivityCheckResponse{ - // AvgLatencyInMs: to.Ptr[int64](1), - // ConnectionStatus: to.Ptr(armapimanagement.ConnectionStatusConnected), - // Hops: []*armapimanagement.ConnectivityHop{ - // { - // Type: to.Ptr("Source"), - // Address: to.Ptr("10.1.1.4"), - // ID: to.Ptr("7dbbe7aa-60ba-4650-831e-63d775d38e9e"), - // Issues: []*armapimanagement.ConnectivityIssue{ - // }, - // NextHopIDs: []*string{ - // to.Ptr("75c8d819-b208-4584-a311-1aa45ce753f9")}, - // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // }, - // { - // Type: to.Ptr("Internet"), - // Address: to.Ptr("8.8.8.8"), - // ID: to.Ptr("75c8d819-b208-4584-a311-1aa45ce753f9"), - // Issues: []*armapimanagement.ConnectivityIssue{ - // }, - // NextHopIDs: []*string{ - // }, - // }}, - // MaxLatencyInMs: to.Ptr[int64](4), - // MinLatencyInMs: to.Ptr[int64](1), - // ProbesFailed: to.Ptr[int64](0), - // ProbesSent: to.Ptr[int64](100), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/client_factory.go b/sdk/resourcemanager/apimanagement/armapimanagement/client_factory.go index 6bf5668c17e6..e36f169bb248 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/client_factory.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/client_factory.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -17,556 +14,1116 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewAPIClient creates a new instance of APIClient. func (c *ClientFactory) NewAPIClient() *APIClient { - subClient, _ := NewAPIClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIDiagnosticClient creates a new instance of APIDiagnosticClient. func (c *ClientFactory) NewAPIDiagnosticClient() *APIDiagnosticClient { - subClient, _ := NewAPIDiagnosticClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIDiagnosticClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIExportClient creates a new instance of APIExportClient. func (c *ClientFactory) NewAPIExportClient() *APIExportClient { - subClient, _ := NewAPIExportClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIExportClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewAPIGatewayClient creates a new instance of APIGatewayClient. +func (c *ClientFactory) NewAPIGatewayClient() *APIGatewayClient { + return &APIGatewayClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewAPIGatewayConfigConnectionClient creates a new instance of APIGatewayConfigConnectionClient. +func (c *ClientFactory) NewAPIGatewayConfigConnectionClient() *APIGatewayConfigConnectionClient { + return &APIGatewayConfigConnectionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIIssueAttachmentClient creates a new instance of APIIssueAttachmentClient. func (c *ClientFactory) NewAPIIssueAttachmentClient() *APIIssueAttachmentClient { - subClient, _ := NewAPIIssueAttachmentClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIIssueAttachmentClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIIssueClient creates a new instance of APIIssueClient. func (c *ClientFactory) NewAPIIssueClient() *APIIssueClient { - subClient, _ := NewAPIIssueClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIIssueClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIIssueCommentClient creates a new instance of APIIssueCommentClient. func (c *ClientFactory) NewAPIIssueCommentClient() *APIIssueCommentClient { - subClient, _ := NewAPIIssueCommentClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIIssueCommentClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIOperationClient creates a new instance of APIOperationClient. func (c *ClientFactory) NewAPIOperationClient() *APIOperationClient { - subClient, _ := NewAPIOperationClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIOperationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIOperationPolicyClient creates a new instance of APIOperationPolicyClient. func (c *ClientFactory) NewAPIOperationPolicyClient() *APIOperationPolicyClient { - subClient, _ := NewAPIOperationPolicyClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIOperationPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIPolicyClient creates a new instance of APIPolicyClient. func (c *ClientFactory) NewAPIPolicyClient() *APIPolicyClient { - subClient, _ := NewAPIPolicyClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIProductClient creates a new instance of APIProductClient. func (c *ClientFactory) NewAPIProductClient() *APIProductClient { - subClient, _ := NewAPIProductClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIProductClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIReleaseClient creates a new instance of APIReleaseClient. func (c *ClientFactory) NewAPIReleaseClient() *APIReleaseClient { - subClient, _ := NewAPIReleaseClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIReleaseClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIRevisionClient creates a new instance of APIRevisionClient. func (c *ClientFactory) NewAPIRevisionClient() *APIRevisionClient { - subClient, _ := NewAPIRevisionClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIRevisionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPISchemaClient creates a new instance of APISchemaClient. func (c *ClientFactory) NewAPISchemaClient() *APISchemaClient { - subClient, _ := NewAPISchemaClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APISchemaClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPITagDescriptionClient creates a new instance of APITagDescriptionClient. func (c *ClientFactory) NewAPITagDescriptionClient() *APITagDescriptionClient { - subClient, _ := NewAPITagDescriptionClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APITagDescriptionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIVersionSetClient creates a new instance of APIVersionSetClient. func (c *ClientFactory) NewAPIVersionSetClient() *APIVersionSetClient { - subClient, _ := NewAPIVersionSetClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIVersionSetClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIWikiClient creates a new instance of APIWikiClient. func (c *ClientFactory) NewAPIWikiClient() *APIWikiClient { - subClient, _ := NewAPIWikiClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIWikiClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAPIWikisClient creates a new instance of APIWikisClient. func (c *ClientFactory) NewAPIWikisClient() *APIWikisClient { - subClient, _ := NewAPIWikisClient(c.subscriptionID, c.credential, c.options) - return subClient + return &APIWikisClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewAllPoliciesClient creates a new instance of AllPoliciesClient. +func (c *ClientFactory) NewAllPoliciesClient() *AllPoliciesClient { + return &AllPoliciesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAuthorizationAccessPolicyClient creates a new instance of AuthorizationAccessPolicyClient. func (c *ClientFactory) NewAuthorizationAccessPolicyClient() *AuthorizationAccessPolicyClient { - subClient, _ := NewAuthorizationAccessPolicyClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AuthorizationAccessPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAuthorizationClient creates a new instance of AuthorizationClient. func (c *ClientFactory) NewAuthorizationClient() *AuthorizationClient { - subClient, _ := NewAuthorizationClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AuthorizationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAuthorizationLoginLinksClient creates a new instance of AuthorizationLoginLinksClient. func (c *ClientFactory) NewAuthorizationLoginLinksClient() *AuthorizationLoginLinksClient { - subClient, _ := NewAuthorizationLoginLinksClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AuthorizationLoginLinksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAuthorizationProviderClient creates a new instance of AuthorizationProviderClient. func (c *ClientFactory) NewAuthorizationProviderClient() *AuthorizationProviderClient { - subClient, _ := NewAuthorizationProviderClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AuthorizationProviderClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewAuthorizationServerClient creates a new instance of AuthorizationServerClient. func (c *ClientFactory) NewAuthorizationServerClient() *AuthorizationServerClient { - subClient, _ := NewAuthorizationServerClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AuthorizationServerClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewBackendClient creates a new instance of BackendClient. func (c *ClientFactory) NewBackendClient() *BackendClient { - subClient, _ := NewBackendClient(c.subscriptionID, c.credential, c.options) - return subClient + return &BackendClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewCacheClient creates a new instance of CacheClient. func (c *ClientFactory) NewCacheClient() *CacheClient { - subClient, _ := NewCacheClient(c.subscriptionID, c.credential, c.options) - return subClient + return &CacheClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewCertificateClient creates a new instance of CertificateClient. func (c *ClientFactory) NewCertificateClient() *CertificateClient { - subClient, _ := NewCertificateClient(c.subscriptionID, c.credential, c.options) - return subClient + return &CertificateClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) - return subClient + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewContentItemClient creates a new instance of ContentItemClient. func (c *ClientFactory) NewContentItemClient() *ContentItemClient { - subClient, _ := NewContentItemClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ContentItemClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewContentTypeClient creates a new instance of ContentTypeClient. func (c *ClientFactory) NewContentTypeClient() *ContentTypeClient { - subClient, _ := NewContentTypeClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ContentTypeClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDelegationSettingsClient creates a new instance of DelegationSettingsClient. func (c *ClientFactory) NewDelegationSettingsClient() *DelegationSettingsClient { - subClient, _ := NewDelegationSettingsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DelegationSettingsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDeletedServicesClient creates a new instance of DeletedServicesClient. func (c *ClientFactory) NewDeletedServicesClient() *DeletedServicesClient { - subClient, _ := NewDeletedServicesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DeletedServicesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDiagnosticClient creates a new instance of DiagnosticClient. func (c *ClientFactory) NewDiagnosticClient() *DiagnosticClient { - subClient, _ := NewDiagnosticClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DiagnosticClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDocumentationClient creates a new instance of DocumentationClient. func (c *ClientFactory) NewDocumentationClient() *DocumentationClient { - subClient, _ := NewDocumentationClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DocumentationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewEmailTemplateClient creates a new instance of EmailTemplateClient. func (c *ClientFactory) NewEmailTemplateClient() *EmailTemplateClient { - subClient, _ := NewEmailTemplateClient(c.subscriptionID, c.credential, c.options) - return subClient + return &EmailTemplateClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGatewayAPIClient creates a new instance of GatewayAPIClient. func (c *ClientFactory) NewGatewayAPIClient() *GatewayAPIClient { - subClient, _ := NewGatewayAPIClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GatewayAPIClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGatewayCertificateAuthorityClient creates a new instance of GatewayCertificateAuthorityClient. func (c *ClientFactory) NewGatewayCertificateAuthorityClient() *GatewayCertificateAuthorityClient { - subClient, _ := NewGatewayCertificateAuthorityClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GatewayCertificateAuthorityClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGatewayClient creates a new instance of GatewayClient. func (c *ClientFactory) NewGatewayClient() *GatewayClient { - subClient, _ := NewGatewayClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GatewayClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGatewayHostnameConfigurationClient creates a new instance of GatewayHostnameConfigurationClient. func (c *ClientFactory) NewGatewayHostnameConfigurationClient() *GatewayHostnameConfigurationClient { - subClient, _ := NewGatewayHostnameConfigurationClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GatewayHostnameConfigurationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewGatewaySKUsClient creates a new instance of GatewaySKUsClient. +func (c *ClientFactory) NewGatewaySKUsClient() *GatewaySKUsClient { + return &GatewaySKUsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGlobalSchemaClient creates a new instance of GlobalSchemaClient. func (c *ClientFactory) NewGlobalSchemaClient() *GlobalSchemaClient { - subClient, _ := NewGlobalSchemaClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GlobalSchemaClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGraphQLAPIResolverClient creates a new instance of GraphQLAPIResolverClient. func (c *ClientFactory) NewGraphQLAPIResolverClient() *GraphQLAPIResolverClient { - subClient, _ := NewGraphQLAPIResolverClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GraphQLAPIResolverClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGraphQLAPIResolverPolicyClient creates a new instance of GraphQLAPIResolverPolicyClient. func (c *ClientFactory) NewGraphQLAPIResolverPolicyClient() *GraphQLAPIResolverPolicyClient { - subClient, _ := NewGraphQLAPIResolverPolicyClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GraphQLAPIResolverPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGroupClient creates a new instance of GroupClient. func (c *ClientFactory) NewGroupClient() *GroupClient { - subClient, _ := NewGroupClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GroupClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewGroupUserClient creates a new instance of GroupUserClient. func (c *ClientFactory) NewGroupUserClient() *GroupUserClient { - subClient, _ := NewGroupUserClient(c.subscriptionID, c.credential, c.options) - return subClient + return &GroupUserClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewIdentityProviderClient creates a new instance of IdentityProviderClient. func (c *ClientFactory) NewIdentityProviderClient() *IdentityProviderClient { - subClient, _ := NewIdentityProviderClient(c.subscriptionID, c.credential, c.options) - return subClient + return &IdentityProviderClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewIssueClient creates a new instance of IssueClient. func (c *ClientFactory) NewIssueClient() *IssueClient { - subClient, _ := NewIssueClient(c.subscriptionID, c.credential, c.options) - return subClient + return &IssueClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewLoggerClient creates a new instance of LoggerClient. func (c *ClientFactory) NewLoggerClient() *LoggerClient { - subClient, _ := NewLoggerClient(c.subscriptionID, c.credential, c.options) - return subClient + return &LoggerClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewNamedValueClient creates a new instance of NamedValueClient. func (c *ClientFactory) NewNamedValueClient() *NamedValueClient { - subClient, _ := NewNamedValueClient(c.subscriptionID, c.credential, c.options) - return subClient + return &NamedValueClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewNetworkStatusClient creates a new instance of NetworkStatusClient. func (c *ClientFactory) NewNetworkStatusClient() *NetworkStatusClient { - subClient, _ := NewNetworkStatusClient(c.subscriptionID, c.credential, c.options) - return subClient + return &NetworkStatusClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewNotificationClient creates a new instance of NotificationClient. func (c *ClientFactory) NewNotificationClient() *NotificationClient { - subClient, _ := NewNotificationClient(c.subscriptionID, c.credential, c.options) - return subClient + return &NotificationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewNotificationRecipientEmailClient creates a new instance of NotificationRecipientEmailClient. func (c *ClientFactory) NewNotificationRecipientEmailClient() *NotificationRecipientEmailClient { - subClient, _ := NewNotificationRecipientEmailClient(c.subscriptionID, c.credential, c.options) - return subClient + return &NotificationRecipientEmailClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewNotificationRecipientUserClient creates a new instance of NotificationRecipientUserClient. func (c *ClientFactory) NewNotificationRecipientUserClient() *NotificationRecipientUserClient { - subClient, _ := NewNotificationRecipientUserClient(c.subscriptionID, c.credential, c.options) - return subClient + return &NotificationRecipientUserClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOpenIDConnectProviderClient creates a new instance of OpenIDConnectProviderClient. func (c *ClientFactory) NewOpenIDConnectProviderClient() *OpenIDConnectProviderClient { - subClient, _ := NewOpenIDConnectProviderClient(c.subscriptionID, c.credential, c.options) - return subClient + return &OpenIDConnectProviderClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationClient creates a new instance of OperationClient. func (c *ClientFactory) NewOperationClient() *OperationClient { - subClient, _ := NewOperationClient(c.subscriptionID, c.credential, c.options) - return subClient + return &OperationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationStatusClient creates a new instance of OperationStatusClient. +func (c *ClientFactory) NewOperationStatusClient() *OperationStatusClient { + return &OperationStatusClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } +} + +// NewOperationsResultsClient creates a new instance of OperationsResultsClient. +func (c *ClientFactory) NewOperationsResultsClient() *OperationsResultsClient { + return &OperationsResultsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOutboundNetworkDependenciesEndpointsClient creates a new instance of OutboundNetworkDependenciesEndpointsClient. func (c *ClientFactory) NewOutboundNetworkDependenciesEndpointsClient() *OutboundNetworkDependenciesEndpointsClient { - subClient, _ := NewOutboundNetworkDependenciesEndpointsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &OutboundNetworkDependenciesEndpointsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPolicyClient creates a new instance of PolicyClient. func (c *ClientFactory) NewPolicyClient() *PolicyClient { - subClient, _ := NewPolicyClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPolicyDescriptionClient creates a new instance of PolicyDescriptionClient. func (c *ClientFactory) NewPolicyDescriptionClient() *PolicyDescriptionClient { - subClient, _ := NewPolicyDescriptionClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PolicyDescriptionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPolicyFragmentClient creates a new instance of PolicyFragmentClient. func (c *ClientFactory) NewPolicyFragmentClient() *PolicyFragmentClient { - subClient, _ := NewPolicyFragmentClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PolicyFragmentClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewPolicyRestrictionClient creates a new instance of PolicyRestrictionClient. +func (c *ClientFactory) NewPolicyRestrictionClient() *PolicyRestrictionClient { + return &PolicyRestrictionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewPolicyRestrictionValidationsClient creates a new instance of PolicyRestrictionValidationsClient. +func (c *ClientFactory) NewPolicyRestrictionValidationsClient() *PolicyRestrictionValidationsClient { + return &PolicyRestrictionValidationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPortalConfigClient creates a new instance of PortalConfigClient. func (c *ClientFactory) NewPortalConfigClient() *PortalConfigClient { - subClient, _ := NewPortalConfigClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PortalConfigClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPortalRevisionClient creates a new instance of PortalRevisionClient. func (c *ClientFactory) NewPortalRevisionClient() *PortalRevisionClient { - subClient, _ := NewPortalRevisionClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PortalRevisionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPortalSettingsClient creates a new instance of PortalSettingsClient. func (c *ClientFactory) NewPortalSettingsClient() *PortalSettingsClient { - subClient, _ := NewPortalSettingsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PortalSettingsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPrivateEndpointConnectionClient creates a new instance of PrivateEndpointConnectionClient. func (c *ClientFactory) NewPrivateEndpointConnectionClient() *PrivateEndpointConnectionClient { - subClient, _ := NewPrivateEndpointConnectionClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PrivateEndpointConnectionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProductAPIClient creates a new instance of ProductAPIClient. func (c *ClientFactory) NewProductAPIClient() *ProductAPIClient { - subClient, _ := NewProductAPIClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProductAPIClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewProductAPILinkClient creates a new instance of ProductAPILinkClient. +func (c *ClientFactory) NewProductAPILinkClient() *ProductAPILinkClient { + return &ProductAPILinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProductClient creates a new instance of ProductClient. func (c *ClientFactory) NewProductClient() *ProductClient { - subClient, _ := NewProductClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProductClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProductGroupClient creates a new instance of ProductGroupClient. func (c *ClientFactory) NewProductGroupClient() *ProductGroupClient { - subClient, _ := NewProductGroupClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProductGroupClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewProductGroupLinkClient creates a new instance of ProductGroupLinkClient. +func (c *ClientFactory) NewProductGroupLinkClient() *ProductGroupLinkClient { + return &ProductGroupLinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProductPolicyClient creates a new instance of ProductPolicyClient. func (c *ClientFactory) NewProductPolicyClient() *ProductPolicyClient { - subClient, _ := NewProductPolicyClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProductPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProductSubscriptionsClient creates a new instance of ProductSubscriptionsClient. func (c *ClientFactory) NewProductSubscriptionsClient() *ProductSubscriptionsClient { - subClient, _ := NewProductSubscriptionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProductSubscriptionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProductWikiClient creates a new instance of ProductWikiClient. func (c *ClientFactory) NewProductWikiClient() *ProductWikiClient { - subClient, _ := NewProductWikiClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProductWikiClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProductWikisClient creates a new instance of ProductWikisClient. func (c *ClientFactory) NewProductWikisClient() *ProductWikisClient { - subClient, _ := NewProductWikisClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProductWikisClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewQuotaByCounterKeysClient creates a new instance of QuotaByCounterKeysClient. func (c *ClientFactory) NewQuotaByCounterKeysClient() *QuotaByCounterKeysClient { - subClient, _ := NewQuotaByCounterKeysClient(c.subscriptionID, c.credential, c.options) - return subClient + return &QuotaByCounterKeysClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewQuotaByPeriodKeysClient creates a new instance of QuotaByPeriodKeysClient. func (c *ClientFactory) NewQuotaByPeriodKeysClient() *QuotaByPeriodKeysClient { - subClient, _ := NewQuotaByPeriodKeysClient(c.subscriptionID, c.credential, c.options) - return subClient + return &QuotaByPeriodKeysClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewRegionClient creates a new instance of RegionClient. func (c *ClientFactory) NewRegionClient() *RegionClient { - subClient, _ := NewRegionClient(c.subscriptionID, c.credential, c.options) - return subClient + return &RegionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewReportsClient creates a new instance of ReportsClient. func (c *ClientFactory) NewReportsClient() *ReportsClient { - subClient, _ := NewReportsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ReportsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewSKUsClient creates a new instance of SKUsClient. func (c *ClientFactory) NewSKUsClient() *SKUsClient { - subClient, _ := NewSKUsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SKUsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewServiceClient creates a new instance of ServiceClient. func (c *ClientFactory) NewServiceClient() *ServiceClient { - subClient, _ := NewServiceClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ServiceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewServiceSKUsClient creates a new instance of ServiceSKUsClient. func (c *ClientFactory) NewServiceSKUsClient() *ServiceSKUsClient { - subClient, _ := NewServiceSKUsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ServiceSKUsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewSignInSettingsClient creates a new instance of SignInSettingsClient. func (c *ClientFactory) NewSignInSettingsClient() *SignInSettingsClient { - subClient, _ := NewSignInSettingsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SignInSettingsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewSignUpSettingsClient creates a new instance of SignUpSettingsClient. func (c *ClientFactory) NewSignUpSettingsClient() *SignUpSettingsClient { - subClient, _ := NewSignUpSettingsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SignUpSettingsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewSubscriptionClient creates a new instance of SubscriptionClient. func (c *ClientFactory) NewSubscriptionClient() *SubscriptionClient { - subClient, _ := NewSubscriptionClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SubscriptionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewTagAPILinkClient creates a new instance of TagAPILinkClient. +func (c *ClientFactory) NewTagAPILinkClient() *TagAPILinkClient { + return &TagAPILinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTagClient creates a new instance of TagClient. func (c *ClientFactory) NewTagClient() *TagClient { - subClient, _ := NewTagClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TagClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewTagOperationLinkClient creates a new instance of TagOperationLinkClient. +func (c *ClientFactory) NewTagOperationLinkClient() *TagOperationLinkClient { + return &TagOperationLinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewTagProductLinkClient creates a new instance of TagProductLinkClient. +func (c *ClientFactory) NewTagProductLinkClient() *TagProductLinkClient { + return &TagProductLinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTagResourceClient creates a new instance of TagResourceClient. func (c *ClientFactory) NewTagResourceClient() *TagResourceClient { - subClient, _ := NewTagResourceClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TagResourceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTenantAccessClient creates a new instance of TenantAccessClient. func (c *ClientFactory) NewTenantAccessClient() *TenantAccessClient { - subClient, _ := NewTenantAccessClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TenantAccessClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTenantAccessGitClient creates a new instance of TenantAccessGitClient. func (c *ClientFactory) NewTenantAccessGitClient() *TenantAccessGitClient { - subClient, _ := NewTenantAccessGitClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TenantAccessGitClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTenantConfigurationClient creates a new instance of TenantConfigurationClient. func (c *ClientFactory) NewTenantConfigurationClient() *TenantConfigurationClient { - subClient, _ := NewTenantConfigurationClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TenantConfigurationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTenantSettingsClient creates a new instance of TenantSettingsClient. func (c *ClientFactory) NewTenantSettingsClient() *TenantSettingsClient { - subClient, _ := NewTenantSettingsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TenantSettingsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewUserClient creates a new instance of UserClient. func (c *ClientFactory) NewUserClient() *UserClient { - subClient, _ := NewUserClient(c.subscriptionID, c.credential, c.options) - return subClient + return &UserClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewUserConfirmationPasswordClient creates a new instance of UserConfirmationPasswordClient. func (c *ClientFactory) NewUserConfirmationPasswordClient() *UserConfirmationPasswordClient { - subClient, _ := NewUserConfirmationPasswordClient(c.subscriptionID, c.credential, c.options) - return subClient + return &UserConfirmationPasswordClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewUserGroupClient creates a new instance of UserGroupClient. func (c *ClientFactory) NewUserGroupClient() *UserGroupClient { - subClient, _ := NewUserGroupClient(c.subscriptionID, c.credential, c.options) - return subClient + return &UserGroupClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewUserIdentitiesClient creates a new instance of UserIdentitiesClient. func (c *ClientFactory) NewUserIdentitiesClient() *UserIdentitiesClient { - subClient, _ := NewUserIdentitiesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &UserIdentitiesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewUserSubscriptionClient creates a new instance of UserSubscriptionClient. func (c *ClientFactory) NewUserSubscriptionClient() *UserSubscriptionClient { - subClient, _ := NewUserSubscriptionClient(c.subscriptionID, c.credential, c.options) - return subClient + return &UserSubscriptionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPIClient creates a new instance of WorkspaceAPIClient. +func (c *ClientFactory) NewWorkspaceAPIClient() *WorkspaceAPIClient { + return &WorkspaceAPIClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPIDiagnosticClient creates a new instance of WorkspaceAPIDiagnosticClient. +func (c *ClientFactory) NewWorkspaceAPIDiagnosticClient() *WorkspaceAPIDiagnosticClient { + return &WorkspaceAPIDiagnosticClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPIExportClient creates a new instance of WorkspaceAPIExportClient. +func (c *ClientFactory) NewWorkspaceAPIExportClient() *WorkspaceAPIExportClient { + return &WorkspaceAPIExportClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPIOperationClient creates a new instance of WorkspaceAPIOperationClient. +func (c *ClientFactory) NewWorkspaceAPIOperationClient() *WorkspaceAPIOperationClient { + return &WorkspaceAPIOperationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPIOperationPolicyClient creates a new instance of WorkspaceAPIOperationPolicyClient. +func (c *ClientFactory) NewWorkspaceAPIOperationPolicyClient() *WorkspaceAPIOperationPolicyClient { + return &WorkspaceAPIOperationPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPIPolicyClient creates a new instance of WorkspaceAPIPolicyClient. +func (c *ClientFactory) NewWorkspaceAPIPolicyClient() *WorkspaceAPIPolicyClient { + return &WorkspaceAPIPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPIReleaseClient creates a new instance of WorkspaceAPIReleaseClient. +func (c *ClientFactory) NewWorkspaceAPIReleaseClient() *WorkspaceAPIReleaseClient { + return &WorkspaceAPIReleaseClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPIRevisionClient creates a new instance of WorkspaceAPIRevisionClient. +func (c *ClientFactory) NewWorkspaceAPIRevisionClient() *WorkspaceAPIRevisionClient { + return &WorkspaceAPIRevisionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPISchemaClient creates a new instance of WorkspaceAPISchemaClient. +func (c *ClientFactory) NewWorkspaceAPISchemaClient() *WorkspaceAPISchemaClient { + return &WorkspaceAPISchemaClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceAPIVersionSetClient creates a new instance of WorkspaceAPIVersionSetClient. +func (c *ClientFactory) NewWorkspaceAPIVersionSetClient() *WorkspaceAPIVersionSetClient { + return &WorkspaceAPIVersionSetClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceBackendClient creates a new instance of WorkspaceBackendClient. +func (c *ClientFactory) NewWorkspaceBackendClient() *WorkspaceBackendClient { + return &WorkspaceBackendClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceCertificateClient creates a new instance of WorkspaceCertificateClient. +func (c *ClientFactory) NewWorkspaceCertificateClient() *WorkspaceCertificateClient { + return &WorkspaceCertificateClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceClient creates a new instance of WorkspaceClient. +func (c *ClientFactory) NewWorkspaceClient() *WorkspaceClient { + return &WorkspaceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceDiagnosticClient creates a new instance of WorkspaceDiagnosticClient. +func (c *ClientFactory) NewWorkspaceDiagnosticClient() *WorkspaceDiagnosticClient { + return &WorkspaceDiagnosticClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceGlobalSchemaClient creates a new instance of WorkspaceGlobalSchemaClient. +func (c *ClientFactory) NewWorkspaceGlobalSchemaClient() *WorkspaceGlobalSchemaClient { + return &WorkspaceGlobalSchemaClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceGroupClient creates a new instance of WorkspaceGroupClient. +func (c *ClientFactory) NewWorkspaceGroupClient() *WorkspaceGroupClient { + return &WorkspaceGroupClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceGroupUserClient creates a new instance of WorkspaceGroupUserClient. +func (c *ClientFactory) NewWorkspaceGroupUserClient() *WorkspaceGroupUserClient { + return &WorkspaceGroupUserClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceLinkClient creates a new instance of WorkspaceLinkClient. +func (c *ClientFactory) NewWorkspaceLinkClient() *WorkspaceLinkClient { + return &WorkspaceLinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceLinksClient creates a new instance of WorkspaceLinksClient. +func (c *ClientFactory) NewWorkspaceLinksClient() *WorkspaceLinksClient { + return &WorkspaceLinksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceLoggerClient creates a new instance of WorkspaceLoggerClient. +func (c *ClientFactory) NewWorkspaceLoggerClient() *WorkspaceLoggerClient { + return &WorkspaceLoggerClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceNamedValueClient creates a new instance of WorkspaceNamedValueClient. +func (c *ClientFactory) NewWorkspaceNamedValueClient() *WorkspaceNamedValueClient { + return &WorkspaceNamedValueClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceNotificationClient creates a new instance of WorkspaceNotificationClient. +func (c *ClientFactory) NewWorkspaceNotificationClient() *WorkspaceNotificationClient { + return &WorkspaceNotificationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceNotificationRecipientEmailClient creates a new instance of WorkspaceNotificationRecipientEmailClient. +func (c *ClientFactory) NewWorkspaceNotificationRecipientEmailClient() *WorkspaceNotificationRecipientEmailClient { + return &WorkspaceNotificationRecipientEmailClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceNotificationRecipientUserClient creates a new instance of WorkspaceNotificationRecipientUserClient. +func (c *ClientFactory) NewWorkspaceNotificationRecipientUserClient() *WorkspaceNotificationRecipientUserClient { + return &WorkspaceNotificationRecipientUserClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspacePolicyClient creates a new instance of WorkspacePolicyClient. +func (c *ClientFactory) NewWorkspacePolicyClient() *WorkspacePolicyClient { + return &WorkspacePolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspacePolicyFragmentClient creates a new instance of WorkspacePolicyFragmentClient. +func (c *ClientFactory) NewWorkspacePolicyFragmentClient() *WorkspacePolicyFragmentClient { + return &WorkspacePolicyFragmentClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceProductAPILinkClient creates a new instance of WorkspaceProductAPILinkClient. +func (c *ClientFactory) NewWorkspaceProductAPILinkClient() *WorkspaceProductAPILinkClient { + return &WorkspaceProductAPILinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceProductClient creates a new instance of WorkspaceProductClient. +func (c *ClientFactory) NewWorkspaceProductClient() *WorkspaceProductClient { + return &WorkspaceProductClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceProductGroupLinkClient creates a new instance of WorkspaceProductGroupLinkClient. +func (c *ClientFactory) NewWorkspaceProductGroupLinkClient() *WorkspaceProductGroupLinkClient { + return &WorkspaceProductGroupLinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceProductPolicyClient creates a new instance of WorkspaceProductPolicyClient. +func (c *ClientFactory) NewWorkspaceProductPolicyClient() *WorkspaceProductPolicyClient { + return &WorkspaceProductPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceSubscriptionClient creates a new instance of WorkspaceSubscriptionClient. +func (c *ClientFactory) NewWorkspaceSubscriptionClient() *WorkspaceSubscriptionClient { + return &WorkspaceSubscriptionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceTagAPILinkClient creates a new instance of WorkspaceTagAPILinkClient. +func (c *ClientFactory) NewWorkspaceTagAPILinkClient() *WorkspaceTagAPILinkClient { + return &WorkspaceTagAPILinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceTagClient creates a new instance of WorkspaceTagClient. +func (c *ClientFactory) NewWorkspaceTagClient() *WorkspaceTagClient { + return &WorkspaceTagClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceTagOperationLinkClient creates a new instance of WorkspaceTagOperationLinkClient. +func (c *ClientFactory) NewWorkspaceTagOperationLinkClient() *WorkspaceTagOperationLinkClient { + return &WorkspaceTagOperationLinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkspaceTagProductLinkClient creates a new instance of WorkspaceTagProductLinkClient. +func (c *ClientFactory) NewWorkspaceTagProductLinkClient() *WorkspaceTagProductLinkClient { + return &WorkspaceTagProductLinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/constants.go b/sdk/resourcemanager/apimanagement/armapimanagement/constants.go index bc34052de457..c9df36c07a0c 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/constants.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/constants.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -10,9 +7,30 @@ package armapimanagement const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement" - moduleVersion = "v2.1.0" + moduleVersion = "v3.0.0" +) + +// APIGatewaySKUType - Name of the Sku. +type APIGatewaySKUType string + +const ( + // APIGatewaySKUTypeStandard - Standard SKU of the API gateway. + APIGatewaySKUTypeStandard APIGatewaySKUType = "Standard" + // APIGatewaySKUTypeWorkspaceGatewayPremium - Premium SKU of the API gateway to be used in Workspaces. + APIGatewaySKUTypeWorkspaceGatewayPremium APIGatewaySKUType = "WorkspaceGatewayPremium" + // APIGatewaySKUTypeWorkspaceGatewayStandard - Standard SKU of the API gateway to be used in Workspaces. + APIGatewaySKUTypeWorkspaceGatewayStandard APIGatewaySKUType = "WorkspaceGatewayStandard" ) +// PossibleAPIGatewaySKUTypeValues returns the possible values for the APIGatewaySKUType const type. +func PossibleAPIGatewaySKUTypeValues() []APIGatewaySKUType { + return []APIGatewaySKUType{ + APIGatewaySKUTypeStandard, + APIGatewaySKUTypeWorkspaceGatewayPremium, + APIGatewaySKUTypeWorkspaceGatewayStandard, + } +} + // APIManagementSKUCapacityScaleType - The scale type applicable to the sku. type APIManagementSKUCapacityScaleType string @@ -68,7 +86,9 @@ type APIType string const ( APITypeGraphql APIType = "graphql" + APITypeGrpc APIType = "grpc" APITypeHTTP APIType = "http" + APITypeOData APIType = "odata" APITypeSoap APIType = "soap" APITypeWebsocket APIType = "websocket" ) @@ -77,7 +97,9 @@ const ( func PossibleAPITypeValues() []APIType { return []APIType{ APITypeGraphql, + APITypeGrpc, APITypeHTTP, + APITypeOData, APITypeSoap, APITypeWebsocket, } @@ -295,6 +317,24 @@ func PossibleBackendProtocolValues() []BackendProtocol { } } +// BackendType - Type of the backend. A backend can be either Single or Pool. +type BackendType string + +const ( + // BackendTypePool - supports pool backend + BackendTypePool BackendType = "Pool" + // BackendTypeSingle - supports single backend + BackendTypeSingle BackendType = "Single" +) + +// PossibleBackendTypeValues returns the possible values for the BackendType const type. +func PossibleBackendTypeValues() []BackendType { + return []BackendType{ + BackendTypePool, + BackendTypeSingle, + } +} + type BearerTokenSendingMethod string const ( @@ -489,12 +529,20 @@ func PossibleConnectivityStatusTypeValues() []ConnectivityStatusType { } } -// ContentFormat - Format of the Content in which the API is getting imported. +// ContentFormat - Format of the Content in which the API is getting imported. New formats can be added in the future type ContentFormat string const ( // ContentFormatGraphqlLink - The GraphQL API endpoint hosted on a publicly accessible internet address. ContentFormatGraphqlLink ContentFormat = "graphql-link" + // ContentFormatGrpc - The contents are inline and Content Type is a gRPC protobuf file. + ContentFormatGrpc ContentFormat = "grpc" + // ContentFormatGrpcLink - The gRPC protobuf file is hosted on a publicly accessible internet address. + ContentFormatGrpcLink ContentFormat = "grpc-link" + // ContentFormatOData - The contents are inline and Content Type is a OData XML Document. + ContentFormatOData ContentFormat = "odata" + // ContentFormatODataLink - The OData metadata document hosted on a publicly accessible internet address. + ContentFormatODataLink ContentFormat = "odata-link" // ContentFormatOpenapi - The contents are inline and Content Type is a OpenAPI 3.0 YAML Document. ContentFormatOpenapi ContentFormat = "openapi" // ContentFormatOpenapiJSON - The contents are inline and Content Type is a OpenAPI 3.0 JSON Document. @@ -521,6 +569,10 @@ const ( func PossibleContentFormatValues() []ContentFormat { return []ContentFormat{ ContentFormatGraphqlLink, + ContentFormatGrpc, + ContentFormatGrpcLink, + ContentFormatOData, + ContentFormatODataLink, ContentFormatOpenapi, ContentFormatOpenapiJSON, ContentFormatOpenapiJSONLink, @@ -572,6 +624,24 @@ func PossibleDataMaskingModeValues() []DataMaskingMode { } } +// DeveloperPortalStatus - Status of developer portal in this API Management service. +type DeveloperPortalStatus string + +const ( + // DeveloperPortalStatusDisabled - Developer Portal is disabled for the service. + DeveloperPortalStatusDisabled DeveloperPortalStatus = "Disabled" + // DeveloperPortalStatusEnabled - Developer Portal is enabled for the service. + DeveloperPortalStatusEnabled DeveloperPortalStatus = "Enabled" +) + +// PossibleDeveloperPortalStatusValues returns the possible values for the DeveloperPortalStatus const type. +func PossibleDeveloperPortalStatusValues() []DeveloperPortalStatus { + return []DeveloperPortalStatus{ + DeveloperPortalStatusDisabled, + DeveloperPortalStatusEnabled, + } +} + type ExportAPI string const ( @@ -636,6 +706,42 @@ func PossibleExportResultFormatValues() []ExportResultFormat { } } +// GatewayListDebugCredentialsContractPurpose - Purpose of debug credential. +type GatewayListDebugCredentialsContractPurpose string + +const ( + // GatewayListDebugCredentialsContractPurposeTracing - The tracing purpose. + GatewayListDebugCredentialsContractPurposeTracing GatewayListDebugCredentialsContractPurpose = "tracing" +) + +// PossibleGatewayListDebugCredentialsContractPurposeValues returns the possible values for the GatewayListDebugCredentialsContractPurpose const type. +func PossibleGatewayListDebugCredentialsContractPurposeValues() []GatewayListDebugCredentialsContractPurpose { + return []GatewayListDebugCredentialsContractPurpose{ + GatewayListDebugCredentialsContractPurposeTracing, + } +} + +// GatewaySKUCapacityScaleType - The scale type applicable to the sku. +type GatewaySKUCapacityScaleType string + +const ( + // GatewaySKUCapacityScaleTypeAutomatic - Supported scale type automatic. + GatewaySKUCapacityScaleTypeAutomatic GatewaySKUCapacityScaleType = "Automatic" + // GatewaySKUCapacityScaleTypeManual - Supported scale type manual. + GatewaySKUCapacityScaleTypeManual GatewaySKUCapacityScaleType = "Manual" + // GatewaySKUCapacityScaleTypeNone - Scaling not supported. + GatewaySKUCapacityScaleTypeNone GatewaySKUCapacityScaleType = "None" +) + +// PossibleGatewaySKUCapacityScaleTypeValues returns the possible values for the GatewaySKUCapacityScaleType const type. +func PossibleGatewaySKUCapacityScaleTypeValues() []GatewaySKUCapacityScaleType { + return []GatewaySKUCapacityScaleType{ + GatewaySKUCapacityScaleTypeAutomatic, + GatewaySKUCapacityScaleTypeManual, + GatewaySKUCapacityScaleTypeNone, + } +} + type GrantType string const ( @@ -702,16 +808,18 @@ func PossibleHTTPCorrelationProtocolValues() []HTTPCorrelationProtocol { type HostnameType string const ( - HostnameTypeDeveloperPortal HostnameType = "DeveloperPortal" - HostnameTypeManagement HostnameType = "Management" - HostnameTypePortal HostnameType = "Portal" - HostnameTypeProxy HostnameType = "Proxy" - HostnameTypeScm HostnameType = "Scm" + HostnameTypeConfigurationAPI HostnameType = "ConfigurationApi" + HostnameTypeDeveloperPortal HostnameType = "DeveloperPortal" + HostnameTypeManagement HostnameType = "Management" + HostnameTypePortal HostnameType = "Portal" + HostnameTypeProxy HostnameType = "Proxy" + HostnameTypeScm HostnameType = "Scm" ) // PossibleHostnameTypeValues returns the possible values for the HostnameType const type. func PossibleHostnameTypeValues() []HostnameType { return []HostnameType{ + HostnameTypeConfigurationAPI, HostnameTypeDeveloperPortal, HostnameTypeManagement, HostnameTypePortal, @@ -795,6 +903,63 @@ func PossibleKeyTypeValues() []KeyType { } } +type KeyVaultRefreshState string + +const ( + // KeyVaultRefreshStateFalse - Entities for which KeyVault refresh succeeded + KeyVaultRefreshStateFalse KeyVaultRefreshState = "false" + // KeyVaultRefreshStateTrue - Entities for which KeyVault refresh failed. + KeyVaultRefreshStateTrue KeyVaultRefreshState = "true" +) + +// PossibleKeyVaultRefreshStateValues returns the possible values for the KeyVaultRefreshState const type. +func PossibleKeyVaultRefreshStateValues() []KeyVaultRefreshState { + return []KeyVaultRefreshState{ + KeyVaultRefreshStateFalse, + KeyVaultRefreshStateTrue, + } +} + +// LegacyAPIState - Indication whether or not the legacy Configuration API (v1) should be exposed on the API Management service. +// Value is optional but must be 'Enabled' or 'Disabled'. If 'Disabled', legacy Configuration +// API (v1) will not be available for self-hosted gateways. Default value is 'Enabled' +type LegacyAPIState string + +const ( + // LegacyAPIStateDisabled - Legacy Configuration API (v1) is disabled for the service and self-hosted gateways can not connect + // to it. + LegacyAPIStateDisabled LegacyAPIState = "Disabled" + // LegacyAPIStateEnabled - Legacy Configuration API (v1) is enabled for the service and self-hosted gateways can connect to + // it. + LegacyAPIStateEnabled LegacyAPIState = "Enabled" +) + +// PossibleLegacyAPIStateValues returns the possible values for the LegacyAPIState const type. +func PossibleLegacyAPIStateValues() []LegacyAPIState { + return []LegacyAPIState{ + LegacyAPIStateDisabled, + LegacyAPIStateEnabled, + } +} + +// LegacyPortalStatus - Status of legacy portal in the API Management service. +type LegacyPortalStatus string + +const ( + // LegacyPortalStatusDisabled - Legacy Portal is disabled for the service. + LegacyPortalStatusDisabled LegacyPortalStatus = "Disabled" + // LegacyPortalStatusEnabled - Legacy Portal is enabled for the service. + LegacyPortalStatusEnabled LegacyPortalStatus = "Enabled" +) + +// PossibleLegacyPortalStatusValues returns the possible values for the LegacyPortalStatus const type. +func PossibleLegacyPortalStatusValues() []LegacyPortalStatus { + return []LegacyPortalStatus{ + LegacyPortalStatusDisabled, + LegacyPortalStatusEnabled, + } +} + // LoggerType - Logger type. type LoggerType string @@ -832,6 +997,26 @@ func PossibleMethodValues() []Method { } } +// MigrateToStv2Mode - Mode of Migration to stv2. Default is PreserveIp. +type MigrateToStv2Mode string + +const ( + // MigrateToStv2ModeNewIP - Migrate API Management service to stv2 from stv1. This will have no downtime as the service configuration + // will be migrated to new infrastructure, but the IP address will changed. + MigrateToStv2ModeNewIP MigrateToStv2Mode = "NewIP" + // MigrateToStv2ModePreserveIP - Migrate API Management service to stv2 from stv1, by reserving the IP Address of the service. + // This will have a downtime of upto 15 minutes, while the IP address is getting migrate to new infrastructure. + MigrateToStv2ModePreserveIP MigrateToStv2Mode = "PreserveIp" +) + +// PossibleMigrateToStv2ModeValues returns the possible values for the MigrateToStv2Mode const type. +func PossibleMigrateToStv2ModeValues() []MigrateToStv2Mode { + return []MigrateToStv2Mode{ + MigrateToStv2ModeNewIP, + MigrateToStv2ModePreserveIP, + } +} + // NameAvailabilityReason - Invalid indicates the name provided does not match the resource provider’s naming requirements // (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in use // and is therefore unavailable. @@ -972,6 +1157,8 @@ const ( PlatformVersionStv1 PlatformVersion = "stv1" // PlatformVersionStv2 - Platform running the service on Single Tenant V2 platform. PlatformVersionStv2 PlatformVersion = "stv2" + // PlatformVersionStv21 - Platform running the service on Single Tenant V2 platform on newer Hardware. + PlatformVersionStv21 PlatformVersion = "stv2.1" // PlatformVersionUndetermined - Platform version cannot be determined, as compute platform is not deployed. PlatformVersionUndetermined PlatformVersion = "undetermined" ) @@ -982,10 +1169,32 @@ func PossiblePlatformVersionValues() []PlatformVersion { PlatformVersionMtv1, PlatformVersionStv1, PlatformVersionStv2, + PlatformVersionStv21, PlatformVersionUndetermined, } } +// PolicyComplianceState - Policy Restriction Compliance State +type PolicyComplianceState string + +const ( + // PolicyComplianceStateCompliant - The scope in restriction is in compliance. + PolicyComplianceStateCompliant PolicyComplianceState = "Compliant" + // PolicyComplianceStateNonCompliant - The scope in restriction is out of compliance. + PolicyComplianceStateNonCompliant PolicyComplianceState = "NonCompliant" + // PolicyComplianceStatePending - The policy restriction compliance state has not yet been determined. + PolicyComplianceStatePending PolicyComplianceState = "Pending" +) + +// PossiblePolicyComplianceStateValues returns the possible values for the PolicyComplianceState const type. +func PossiblePolicyComplianceStateValues() []PolicyComplianceState { + return []PolicyComplianceState{ + PolicyComplianceStateCompliant, + PolicyComplianceStateNonCompliant, + PolicyComplianceStatePending, + } +} + // PolicyContentFormat - Format of the policyContent. type PolicyContentFormat string @@ -1058,6 +1267,24 @@ func PossiblePolicyIDNameValues() []PolicyIDName { } } +// PolicyRestrictionRequireBase - Indicates if base policy should be enforced for the policy document. +type PolicyRestrictionRequireBase string + +const ( + // PolicyRestrictionRequireBaseFalse - The policy does not require to have base policy + PolicyRestrictionRequireBaseFalse PolicyRestrictionRequireBase = "false" + // PolicyRestrictionRequireBaseTrue - The policy is required to have base policy + PolicyRestrictionRequireBaseTrue PolicyRestrictionRequireBase = "true" +) + +// PossiblePolicyRestrictionRequireBaseValues returns the possible values for the PolicyRestrictionRequireBase const type. +func PossiblePolicyRestrictionRequireBaseValues() []PolicyRestrictionRequireBase { + return []PolicyRestrictionRequireBase{ + PolicyRestrictionRequireBaseFalse, + PolicyRestrictionRequireBaseTrue, + } +} + type PolicyScopeContract string const ( @@ -1258,6 +1485,8 @@ type SKUType string const ( // SKUTypeBasic - Basic SKU of Api Management. SKUTypeBasic SKUType = "Basic" + // SKUTypeBasicV2 - BasicV2 SKU of Api Management. + SKUTypeBasicV2 SKUType = "BasicV2" // SKUTypeConsumption - Consumption SKU of Api Management. SKUTypeConsumption SKUType = "Consumption" // SKUTypeDeveloper - Developer SKU of Api Management. @@ -1268,17 +1497,21 @@ const ( SKUTypePremium SKUType = "Premium" // SKUTypeStandard - Standard SKU of Api Management. SKUTypeStandard SKUType = "Standard" + // SKUTypeStandardV2 - StandardV2 SKU of Api Management. + SKUTypeStandardV2 SKUType = "StandardV2" ) // PossibleSKUTypeValues returns the possible values for the SKUType const type. func PossibleSKUTypeValues() []SKUType { return []SKUType{ SKUTypeBasic, + SKUTypeBasicV2, SKUTypeConsumption, SKUTypeDeveloper, SKUTypeIsolated, SKUTypePremium, SKUTypeStandard, + SKUTypeStandardV2, } } @@ -1348,12 +1581,16 @@ func PossibleSeverityValues() []Severity { // * http creates a REST API // * soap creates a SOAP pass-through API // * websocket creates websocket API -// * graphql creates GraphQL API. +// * graphql creates GraphQL API. New types can be added in the future. type SoapAPIType string const ( + // SoapAPITypeGRPC - Imports the API having a gRPC front end. + SoapAPITypeGRPC SoapAPIType = "grpc" // SoapAPITypeGraphQL - Imports the API having a GraphQL front end. SoapAPITypeGraphQL SoapAPIType = "graphql" + // SoapAPITypeOData - Imports the API having a OData front end. + SoapAPITypeOData SoapAPIType = "odata" // SoapAPITypeSoapPassThrough - Imports the SOAP API having a SOAP front end. SoapAPITypeSoapPassThrough SoapAPIType = "soap" // SoapAPITypeSoapToRest - Imports a SOAP API having a RESTful front end. @@ -1365,7 +1602,9 @@ const ( // PossibleSoapAPITypeValues returns the possible values for the SoapAPIType const type. func PossibleSoapAPITypeValues() []SoapAPIType { return []SoapAPIType{ + SoapAPITypeGRPC, SoapAPITypeGraphQL, + SoapAPITypeOData, SoapAPITypeSoapPassThrough, SoapAPITypeSoapToRest, SoapAPITypeWebSocket, @@ -1554,19 +1793,16 @@ func PossibleVersioningSchemeValues() []VersioningScheme { } } -// VirtualNetworkType - The type of VPN in which API Management service needs to be configured in. None (Default Value) means -// the API Management service is not part of any Virtual Network, External means the API Management -// deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management -// deployment is setup inside a Virtual Network having an Intranet Facing Endpoint -// only. +// VirtualNetworkType - The type of VPN in which API Management gateway needs to be configured in. type VirtualNetworkType string const ( - // VirtualNetworkTypeExternal - The service is part of Virtual Network and it is accessible from Internet. + // VirtualNetworkTypeExternal - The API Management gateway is part of Virtual Network and it is accessible from Internet. VirtualNetworkTypeExternal VirtualNetworkType = "External" - // VirtualNetworkTypeInternal - The service is part of Virtual Network and it is only accessible from within the virtual network. + // VirtualNetworkTypeInternal - The API Management gateway is part of Virtual Network and it is only accessible from within + // the virtual network. VirtualNetworkTypeInternal VirtualNetworkType = "Internal" - // VirtualNetworkTypeNone - The service is not part of any Virtual Network. + // VirtualNetworkTypeNone - The API Management gateway is not part of any Virtual Network. VirtualNetworkTypeNone VirtualNetworkType = "None" ) diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/contentitem_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/contentitem_client.go index 718072bd3d4e..27f6638cf3c7 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/contentitem_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/contentitem_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type ContentItemClient struct { } // NewContentItemClient creates a new instance of ContentItemClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewContentItemClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContentItemClient, error) { @@ -46,7 +43,7 @@ func NewContentItemClient(subscriptionID string, credential azcore.TokenCredenti // CreateOrUpdate - Creates a new developer portal's content item specified by the provided content type. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - contentTypeID - Content type identifier. @@ -104,12 +101,12 @@ func (client *ContentItemClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -131,7 +128,7 @@ func (client *ContentItemClient) createOrUpdateHandleResponse(resp *http.Respons // Delete - Removes the specified developer portal's content item. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - contentTypeID - Content type identifier. @@ -161,7 +158,7 @@ func (client *ContentItemClient) Delete(ctx context.Context, resourceGroupName s } // deleteCreateRequest creates the Delete request. -func (client *ContentItemClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string, options *ContentItemClientDeleteOptions) (*policy.Request, error) { +func (client *ContentItemClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string, _ *ContentItemClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -188,17 +185,17 @@ func (client *ContentItemClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Returns the developer portal's content item specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - contentTypeID - Content type identifier. @@ -227,7 +224,7 @@ func (client *ContentItemClient) Get(ctx context.Context, resourceGroupName stri } // getCreateRequest creates the Get request. -func (client *ContentItemClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, options *ContentItemClientGetOptions) (*policy.Request, error) { +func (client *ContentItemClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, _ *ContentItemClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -254,7 +251,7 @@ func (client *ContentItemClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -274,7 +271,7 @@ func (client *ContentItemClient) getHandleResponse(resp *http.Response) (Content // GetEntityTag - Returns the entity state (ETag) version of the developer portal's content item specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - contentTypeID - Content type identifier. @@ -304,7 +301,7 @@ func (client *ContentItemClient) GetEntityTag(ctx context.Context, resourceGroup } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *ContentItemClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, options *ContentItemClientGetEntityTagOptions) (*policy.Request, error) { +func (client *ContentItemClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, _ *ContentItemClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -331,7 +328,7 @@ func (client *ContentItemClient) getEntityTagCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -348,7 +345,7 @@ func (client *ContentItemClient) getEntityTagHandleResponse(resp *http.Response) // NewListByServicePager - Lists developer portal's content items specified by the provided content type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - contentTypeID - Content type identifier. @@ -378,7 +375,7 @@ func (client *ContentItemClient) NewListByServicePager(resourceGroupName string, } // listByServiceCreateRequest creates the ListByService request. -func (client *ContentItemClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, options *ContentItemClientListByServiceOptions) (*policy.Request, error) { +func (client *ContentItemClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, _ *ContentItemClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -401,7 +398,7 @@ func (client *ContentItemClient) listByServiceCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/contentitem_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/contentitem_client_example_test.go deleted file mode 100644 index 34bcacaab9ff..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/contentitem_client_example_test.go +++ /dev/null @@ -1,172 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListContentTypeContentItems.json -func ExampleContentItemClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewContentItemClient().NewListByServicePager("rg1", "apimService1", "page", 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.ContentItemCollection = armapimanagement.ContentItemCollection{ - // Value: []*armapimanagement.ContentItemContract{ - // { - // Name: to.Ptr("4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8"), - // Type: to.Ptr("Microsoft.ApiManagement/service/contentTypes/contentItems"), - // ID: to.Ptr("/contentTypes/page/contentItems/4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8"), - // Properties: map[string]any{ - // "en_us": map[string]any{ - // "description": "Short story about the company.", - // "documentId": "contentTypes/document/contentItems/4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8", - // "keywords": "company, about", - // "permalink": "/about", - // "title": "About", - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadContentTypeContentItem.json -func ExampleContentItemClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewContentItemClient().GetEntityTag(ctx, "rg1", "apimService1", "page", "4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetContentTypeContentItem.json -func ExampleContentItemClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContentItemClient().Get(ctx, "rg1", "apimService1", "page", "4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8", 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.ContentItemContract = armapimanagement.ContentItemContract{ - // Name: to.Ptr("4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8"), - // Type: to.Ptr("Microsoft.ApiManagement/service/contentTypes/contentItems"), - // ID: to.Ptr("/contentTypes/page/contentItems/4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8"), - // Properties: map[string]any{ - // "en_us": map[string]any{ - // "description": "Short story about the company.", - // "documentId": "contentTypes/document/contentItems/4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8", - // "keywords": "company, about", - // "permalink": "/about", - // "title": "About", - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateContentTypeContentItem.json -func ExampleContentItemClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContentItemClient().CreateOrUpdate(ctx, "rg1", "apimService1", "page", "4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8", armapimanagement.ContentItemContract{ - Properties: map[string]any{ - "en_us": map[string]any{ - "description": "Short story about the company.", - "documentId": "contentTypes/document/contentItems/4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8", - "keywords": "company, about", - "permalink": "/about", - "title": "About", - }, - }, - }, &armapimanagement.ContentItemClientCreateOrUpdateOptions{IfMatch: 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.ContentItemContract = armapimanagement.ContentItemContract{ - // Name: to.Ptr("4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8"), - // Type: to.Ptr("Microsoft.ApiManagement/service/contentTypes/contentItems"), - // ID: to.Ptr("/contentTypes/page/contentItems/4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8"), - // Properties: map[string]any{ - // "en_us": map[string]any{ - // "description": "Short story about the company.", - // "documentId": "contentTypes/document/contentItems/4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8", - // "keywords": "company, about", - // "permalink": "/about", - // "title": "About", - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteContentTypeContentItem.json -func ExampleContentItemClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewContentItemClient().Delete(ctx, "rg1", "apimService1", "page", "4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/contenttype_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/contenttype_client.go index 25c1d3d6b6d7..dad4e34a24f9 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/contenttype_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/contenttype_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type ContentTypeClient struct { } // NewContentTypeClient creates a new instance of ContentTypeClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewContentTypeClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContentTypeClient, error) { @@ -48,7 +45,7 @@ func NewContentTypeClient(subscriptionID string, credential azcore.TokenCredenti // prefix. Built-in content types can't be modified. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - contentTypeID - Content type identifier. @@ -101,12 +98,12 @@ func (client *ContentTypeClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -130,7 +127,7 @@ func (client *ContentTypeClient) createOrUpdateHandleResponse(resp *http.Respons // c- prefix) can't be removed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - contentTypeID - Content type identifier. @@ -159,7 +156,7 @@ func (client *ContentTypeClient) Delete(ctx context.Context, resourceGroupName s } // deleteCreateRequest creates the Delete request. -func (client *ContentTypeClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string, options *ContentTypeClientDeleteOptions) (*policy.Request, error) { +func (client *ContentTypeClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string, _ *ContentTypeClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -182,10 +179,10 @@ func (client *ContentTypeClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } @@ -193,7 +190,7 @@ func (client *ContentTypeClient) deleteCreateRequest(ctx context.Context, resour // rules, and constraints. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - contentTypeID - Content type identifier. @@ -221,7 +218,7 @@ func (client *ContentTypeClient) Get(ctx context.Context, resourceGroupName stri } // getCreateRequest creates the Get request. -func (client *ContentTypeClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, options *ContentTypeClientGetOptions) (*policy.Request, error) { +func (client *ContentTypeClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, _ *ContentTypeClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -244,7 +241,7 @@ func (client *ContentTypeClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -265,7 +262,7 @@ func (client *ContentTypeClient) getHandleResponse(resp *http.Response) (Content // NewListByServicePager - Lists the developer portal's content types. Content types describe content items' properties, validation // rules, and constraints. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - ContentTypeClientListByServiceOptions contains the optional parameters for the ContentTypeClient.NewListByServicePager @@ -294,7 +291,7 @@ func (client *ContentTypeClient) NewListByServicePager(resourceGroupName string, } // listByServiceCreateRequest creates the ListByService request. -func (client *ContentTypeClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ContentTypeClientListByServiceOptions) (*policy.Request, error) { +func (client *ContentTypeClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *ContentTypeClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -313,7 +310,7 @@ func (client *ContentTypeClient) listByServiceCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/contenttype_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/contenttype_client_example_test.go deleted file mode 100644 index 39afa9dcbe8a..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/contenttype_client_example_test.go +++ /dev/null @@ -1,320 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListContentTypes.json -func ExampleContentTypeClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewContentTypeClient().NewListByServicePager("rg1", "apimService1", 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.ContentTypeCollection = armapimanagement.ContentTypeCollection{ - // Value: []*armapimanagement.ContentTypeContract{ - // { - // Name: to.Ptr("page"), - // Type: to.Ptr("Microsoft.ApiManagement/service/contentTypes"), - // ID: to.Ptr("/contentTypes/page"), - // Properties: &armapimanagement.ContentTypeContractProperties{ - // Name: to.Ptr("Page"), - // Schema: map[string]any{ - // "additionalProperties": false, - // "properties":map[string]any{ - // "en_us":map[string]any{ - // "type": "object", - // "additionalProperties": false, - // "properties":map[string]any{ - // "description":map[string]any{ - // "type": "string", - // "description": "Page description. This property gets included in SEO attributes.", - // "indexed": true, - // "title": "Description", - // }, - // "documentId":map[string]any{ - // "type": "string", - // "description": "Reference to page content document.", - // "title": "Document ID", - // }, - // "keywords":map[string]any{ - // "type": "string", - // "description": "Page keywords. This property gets included in SEO attributes.", - // "indexed": true, - // "title": "Keywords", - // }, - // "permalink":map[string]any{ - // "type": "string", - // "description": "Page permalink, e.g. '/about'.", - // "indexed": true, - // "title": "Permalink", - // }, - // "title":map[string]any{ - // "type": "string", - // "description": "Page title. This property gets included in SEO attributes.", - // "indexed": true, - // "title": "Title", - // }, - // }, - // "required":[]any{ - // "title", - // "permalink", - // "documentId", - // }, - // }, - // }, - // }, - // Description: to.Ptr("A regular page"), - // Version: to.Ptr("1.0.0"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetContentType.json -func ExampleContentTypeClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContentTypeClient().Get(ctx, "rg1", "apimService1", "page", 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.ContentTypeContract = armapimanagement.ContentTypeContract{ - // Name: to.Ptr("page"), - // Type: to.Ptr("Microsoft.ApiManagement/service/contentTypes"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/contentTypes/page"), - // Properties: &armapimanagement.ContentTypeContractProperties{ - // Name: to.Ptr("Page"), - // Schema: map[string]any{ - // "additionalProperties": false, - // "properties":map[string]any{ - // "en_us":map[string]any{ - // "type": "object", - // "additionalProperties": false, - // "properties":map[string]any{ - // "description":map[string]any{ - // "type": "string", - // "description": "Page description. This property gets included in SEO attributes.", - // "indexed": true, - // "title": "Description", - // }, - // "documentId":map[string]any{ - // "type": "string", - // "description": "Reference to page content document.", - // "title": "Document ID", - // }, - // "keywords":map[string]any{ - // "type": "string", - // "description": "Page keywords. This property gets included in SEO attributes.", - // "indexed": true, - // "title": "Keywords", - // }, - // "permalink":map[string]any{ - // "type": "string", - // "description": "Page permalink, e.g. '/about'.", - // "indexed": true, - // "title": "Permalink", - // }, - // "title":map[string]any{ - // "type": "string", - // "description": "Page title. This property gets included in SEO attributes.", - // "indexed": true, - // "title": "Title", - // }, - // }, - // "required":[]any{ - // "title", - // "permalink", - // "documentId", - // }, - // }, - // }, - // }, - // Description: to.Ptr("A regular page"), - // Version: to.Ptr("1.0.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateContentType.json -func ExampleContentTypeClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContentTypeClient().CreateOrUpdate(ctx, "rg1", "apimService1", "page", armapimanagement.ContentTypeContract{ - Properties: &armapimanagement.ContentTypeContractProperties{ - Name: to.Ptr("Page"), - Schema: map[string]any{ - "additionalProperties": false, - "properties": map[string]any{ - "en_us": map[string]any{ - "type": "object", - "additionalProperties": false, - "properties": map[string]any{ - "description": map[string]any{ - "type": "string", - "description": "Page description. This property gets included in SEO attributes.", - "indexed": true, - "title": "Description", - }, - "documentId": map[string]any{ - "type": "string", - "description": "Reference to page content document.", - "title": "Document ID", - }, - "keywords": map[string]any{ - "type": "string", - "description": "Page keywords. This property gets included in SEO attributes.", - "indexed": true, - "title": "Keywords", - }, - "permalink": map[string]any{ - "type": "string", - "description": "Page permalink, e.g. '/about'.", - "indexed": true, - "title": "Permalink", - }, - "title": map[string]any{ - "type": "string", - "description": "Page title. This property gets included in SEO attributes.", - "indexed": true, - "title": "Title", - }, - }, - "required": []any{ - "title", - "permalink", - "documentId", - }, - }, - }, - }, - Description: to.Ptr("A regular page"), - Version: to.Ptr("1.0.0"), - }, - }, &armapimanagement.ContentTypeClientCreateOrUpdateOptions{IfMatch: 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.ContentTypeContract = armapimanagement.ContentTypeContract{ - // Name: to.Ptr("page"), - // Type: to.Ptr("Microsoft.ApiManagement/service/contentTypes"), - // ID: to.Ptr("/contentTypes/page"), - // Properties: &armapimanagement.ContentTypeContractProperties{ - // Name: to.Ptr("Page"), - // Schema: map[string]any{ - // "additionalProperties": false, - // "properties":map[string]any{ - // "en_us":map[string]any{ - // "type": "object", - // "additionalProperties": false, - // "properties":map[string]any{ - // "description":map[string]any{ - // "type": "string", - // "description": "Page description. This property gets included in SEO attributes.", - // "indexed": true, - // "title": "Description", - // }, - // "documentId":map[string]any{ - // "type": "string", - // "description": "Reference to page content document.", - // "title": "Document ID", - // }, - // "keywords":map[string]any{ - // "type": "string", - // "description": "Page keywords. This property gets included in SEO attributes.", - // "indexed": true, - // "title": "Keywords", - // }, - // "permalink":map[string]any{ - // "type": "string", - // "description": "Page permalink, e.g. '/about'.", - // "indexed": true, - // "title": "Permalink", - // }, - // "title":map[string]any{ - // "type": "string", - // "description": "Page title. This property gets included in SEO attributes.", - // "indexed": true, - // "title": "Title", - // }, - // }, - // "required":[]any{ - // "title", - // "permalink", - // "documentId", - // }, - // }, - // }, - // }, - // Description: to.Ptr("A regular page"), - // Version: to.Ptr("1.0.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteContentType.json -func ExampleContentTypeClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewContentTypeClient().Delete(ctx, "rg1", "apimService1", "page", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/delegationsettings_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/delegationsettings_client.go index f0a949adfbdb..9c1a057e625d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/delegationsettings_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/delegationsettings_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type DelegationSettingsClient struct { } // NewDelegationSettingsClient creates a new instance of DelegationSettingsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewDelegationSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DelegationSettingsClient, error) { @@ -46,7 +43,7 @@ func NewDelegationSettingsClient(subscriptionID string, credential azcore.TokenC // CreateOrUpdate - Create or Update Delegation settings. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - parameters - Create or update parameters. @@ -94,12 +91,12 @@ func (client *DelegationSettingsClient) createOrUpdateCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -118,7 +115,7 @@ func (client *DelegationSettingsClient) createOrUpdateHandleResponse(resp *http. // Get - Get Delegation Settings for the Portal. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - DelegationSettingsClientGetOptions contains the optional parameters for the DelegationSettingsClient.Get method. @@ -145,7 +142,7 @@ func (client *DelegationSettingsClient) Get(ctx context.Context, resourceGroupNa } // getCreateRequest creates the Get request. -func (client *DelegationSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DelegationSettingsClientGetOptions) (*policy.Request, error) { +func (client *DelegationSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *DelegationSettingsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -164,7 +161,7 @@ func (client *DelegationSettingsClient) getCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -184,7 +181,7 @@ func (client *DelegationSettingsClient) getHandleResponse(resp *http.Response) ( // GetEntityTag - Gets the entity state (Etag) version of the DelegationSettings. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - DelegationSettingsClientGetEntityTagOptions contains the optional parameters for the DelegationSettingsClient.GetEntityTag @@ -212,7 +209,7 @@ func (client *DelegationSettingsClient) GetEntityTag(ctx context.Context, resour } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *DelegationSettingsClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DelegationSettingsClientGetEntityTagOptions) (*policy.Request, error) { +func (client *DelegationSettingsClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *DelegationSettingsClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -231,7 +228,7 @@ func (client *DelegationSettingsClient) getEntityTagCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -249,7 +246,7 @@ func (client *DelegationSettingsClient) getEntityTagHandleResponse(resp *http.Re // ListSecrets - Gets the secret validation key of the DelegationSettings. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - DelegationSettingsClientListSecretsOptions contains the optional parameters for the DelegationSettingsClient.ListSecrets @@ -277,7 +274,7 @@ func (client *DelegationSettingsClient) ListSecrets(ctx context.Context, resourc } // listSecretsCreateRequest creates the ListSecrets request. -func (client *DelegationSettingsClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DelegationSettingsClientListSecretsOptions) (*policy.Request, error) { +func (client *DelegationSettingsClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *DelegationSettingsClientListSecretsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -296,7 +293,7 @@ func (client *DelegationSettingsClient) listSecretsCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -314,7 +311,7 @@ func (client *DelegationSettingsClient) listSecretsHandleResponse(resp *http.Res // Update - Update Delegation settings. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or @@ -344,7 +341,7 @@ func (client *DelegationSettingsClient) Update(ctx context.Context, resourceGrou } // updateCreateRequest creates the Update request. -func (client *DelegationSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalDelegationSettings, options *DelegationSettingsClientUpdateOptions) (*policy.Request, error) { +func (client *DelegationSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalDelegationSettings, _ *DelegationSettingsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -363,10 +360,10 @@ func (client *DelegationSettingsClient) updateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/delegationsettings_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/delegationsettings_client_example_test.go deleted file mode 100644 index 7aa1eecb2cb8..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/delegationsettings_client_example_test.go +++ /dev/null @@ -1,166 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadDelegationSettings.json -func ExampleDelegationSettingsClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDelegationSettingsClient().GetEntityTag(ctx, "rg1", "apimService1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsGetDelegation.json -func ExampleDelegationSettingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDelegationSettingsClient().Get(ctx, "rg1", "apimService1", 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.PortalDelegationSettings = armapimanagement.PortalDelegationSettings{ - // Name: to.Ptr("delegation"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalsettings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalsettings/delegation"), - // Properties: &armapimanagement.PortalDelegationSettingsProperties{ - // Subscriptions: &armapimanagement.SubscriptionsDelegationSettingsProperties{ - // Enabled: to.Ptr(true), - // }, - // URL: to.Ptr("http://contoso.com/delegation"), - // UserRegistration: &armapimanagement.RegistrationDelegationSettingsProperties{ - // Enabled: to.Ptr(true), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsUpdateDelegation.json -func ExampleDelegationSettingsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDelegationSettingsClient().Update(ctx, "rg1", "apimService1", "*", armapimanagement.PortalDelegationSettings{ - Properties: &armapimanagement.PortalDelegationSettingsProperties{ - Subscriptions: &armapimanagement.SubscriptionsDelegationSettingsProperties{ - Enabled: to.Ptr(true), - }, - URL: to.Ptr("http://contoso.com/delegation"), - UserRegistration: &armapimanagement.RegistrationDelegationSettingsProperties{ - Enabled: to.Ptr(true), - }, - ValidationKey: to.Ptr(""), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsPutDelegation.json -func ExampleDelegationSettingsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDelegationSettingsClient().CreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.PortalDelegationSettings{ - Properties: &armapimanagement.PortalDelegationSettingsProperties{ - Subscriptions: &armapimanagement.SubscriptionsDelegationSettingsProperties{ - Enabled: to.Ptr(true), - }, - URL: to.Ptr("http://contoso.com/delegation"), - UserRegistration: &armapimanagement.RegistrationDelegationSettingsProperties{ - Enabled: to.Ptr(true), - }, - ValidationKey: to.Ptr(""), - }, - }, &armapimanagement.DelegationSettingsClientCreateOrUpdateOptions{IfMatch: to.Ptr("*")}) - 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.PortalDelegationSettings = armapimanagement.PortalDelegationSettings{ - // Name: to.Ptr("delegation"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalsettings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalsettings/delegation"), - // Properties: &armapimanagement.PortalDelegationSettingsProperties{ - // Subscriptions: &armapimanagement.SubscriptionsDelegationSettingsProperties{ - // Enabled: to.Ptr(true), - // }, - // URL: to.Ptr("http://contoso.com/delegation"), - // UserRegistration: &armapimanagement.RegistrationDelegationSettingsProperties{ - // Enabled: to.Ptr(true), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSecretsPortalSettingsValidationKey.json -func ExampleDelegationSettingsClient_ListSecrets() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDelegationSettingsClient().ListSecrets(ctx, "rg1", "apimService1", 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.PortalSettingValidationKeyContract = armapimanagement.PortalSettingValidationKeyContract{ - // ValidationKey: to.Ptr(""), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/deletedservices_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/deletedservices_client.go index 81f41804a076..2c2ba1366a1a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/deletedservices_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/deletedservices_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type DeletedServicesClient struct { } // NewDeletedServicesClient creates a new instance of DeletedServicesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewDeletedServicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeletedServicesClient, error) { @@ -46,7 +43,7 @@ func NewDeletedServicesClient(subscriptionID string, credential azcore.TokenCred // GetByName - Get soft-deleted Api Management Service by name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - serviceName - The name of the API Management service. // - location - The location of the deleted API Management service. // - options - DeletedServicesClientGetByNameOptions contains the optional parameters for the DeletedServicesClient.GetByName @@ -74,7 +71,7 @@ func (client *DeletedServicesClient) GetByName(ctx context.Context, serviceName } // getByNameCreateRequest creates the GetByName request. -func (client *DeletedServicesClient) getByNameCreateRequest(ctx context.Context, serviceName string, location string, options *DeletedServicesClientGetByNameOptions) (*policy.Request, error) { +func (client *DeletedServicesClient) getByNameCreateRequest(ctx context.Context, serviceName string, location string, _ *DeletedServicesClientGetByNameOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}" if serviceName == "" { return nil, errors.New("parameter serviceName cannot be empty") @@ -93,7 +90,7 @@ func (client *DeletedServicesClient) getByNameCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -110,7 +107,7 @@ func (client *DeletedServicesClient) getByNameHandleResponse(resp *http.Response // NewListBySubscriptionPager - Lists all soft-deleted services available for undelete for the given subscription. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - options - DeletedServicesClientListBySubscriptionOptions contains the optional parameters for the DeletedServicesClient.NewListBySubscriptionPager // method. func (client *DeletedServicesClient) NewListBySubscriptionPager(options *DeletedServicesClientListBySubscriptionOptions) *runtime.Pager[DeletedServicesClientListBySubscriptionResponse] { @@ -137,7 +134,7 @@ func (client *DeletedServicesClient) NewListBySubscriptionPager(options *Deleted } // listBySubscriptionCreateRequest creates the ListBySubscription request. -func (client *DeletedServicesClient) listBySubscriptionCreateRequest(ctx context.Context, options *DeletedServicesClientListBySubscriptionOptions) (*policy.Request, error) { +func (client *DeletedServicesClient) listBySubscriptionCreateRequest(ctx context.Context, _ *DeletedServicesClientListBySubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -148,7 +145,7 @@ func (client *DeletedServicesClient) listBySubscriptionCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -166,7 +163,7 @@ func (client *DeletedServicesClient) listBySubscriptionHandleResponse(resp *http // BeginPurge - Purges Api Management Service (deletes it with no option to undelete). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - serviceName - The name of the API Management service. // - location - The location of the deleted API Management service. // - options - DeletedServicesClientBeginPurgeOptions contains the optional parameters for the DeletedServicesClient.BeginPurge @@ -192,7 +189,7 @@ func (client *DeletedServicesClient) BeginPurge(ctx context.Context, serviceName // Purge - Purges Api Management Service (deletes it with no option to undelete). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *DeletedServicesClient) purge(ctx context.Context, serviceName string, location string, options *DeletedServicesClientBeginPurgeOptions) (*http.Response, error) { var err error const operationName = "DeletedServicesClient.BeginPurge" @@ -215,7 +212,7 @@ func (client *DeletedServicesClient) purge(ctx context.Context, serviceName stri } // purgeCreateRequest creates the Purge request. -func (client *DeletedServicesClient) purgeCreateRequest(ctx context.Context, serviceName string, location string, options *DeletedServicesClientBeginPurgeOptions) (*policy.Request, error) { +func (client *DeletedServicesClient) purgeCreateRequest(ctx context.Context, serviceName string, location string, _ *DeletedServicesClientBeginPurgeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}" if serviceName == "" { return nil, errors.New("parameter serviceName cannot be empty") @@ -234,7 +231,7 @@ func (client *DeletedServicesClient) purgeCreateRequest(ctx context.Context, ser return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/deletedservices_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/deletedservices_client_example_test.go deleted file mode 100644 index a4ca394bd97f..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/deletedservices_client_example_test.go +++ /dev/null @@ -1,120 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletedServicesListBySubscription.json -func ExampleDeletedServicesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDeletedServicesClient().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.DeletedServicesCollection = armapimanagement.DeletedServicesCollection{ - // Value: []*armapimanagement.DeletedServiceContract{ - // { - // Name: to.Ptr("apimService3"), - // Type: to.Ptr("Microsoft.ApiManagement/deletedservices"), - // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.ApiManagement/locations/westus/deletedservices/apimService3"), - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.DeletedServiceContractProperties{ - // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-27T15:33:55.542Z"); return t}()), - // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-27T15:33:55.542Z"); return t}()), - // ServiceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService3"), - // }, - // }, - // { - // Name: to.Ptr("apimService"), - // Type: to.Ptr("Microsoft.ApiManagement/deletedservices"), - // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.ApiManagement/locations/westus2/deletedservices/apimService"), - // Location: to.Ptr("West US 2"), - // Properties: &armapimanagement.DeletedServiceContractProperties{ - // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-27T15:33:55.542Z"); return t}()), - // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-27T15:33:55.542Z"); return t}()), - // ServiceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetDeletedServiceByName.json -func ExampleDeletedServicesClient_GetByName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeletedServicesClient().GetByName(ctx, "apimService3", "westus", 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.DeletedServiceContract = armapimanagement.DeletedServiceContract{ - // Name: to.Ptr("apimService3"), - // Type: to.Ptr("Microsoft.ApiManagement/deletedservices"), - // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.ApiManagement/locations/westus/deletedservices/apimService3"), - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.DeletedServiceContractProperties{ - // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-27T15:33:55.542Z"); return t}()), - // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-27T15:33:55.542Z"); return t}()), - // ServiceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService3"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletedServicesPurge.json -func ExampleDeletedServicesClient_BeginPurge() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeletedServicesClient().BeginPurge(ctx, "apimService3", "westus", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/diagnostic_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/diagnostic_client.go index 9a5590533246..628c60f138f2 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/diagnostic_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/diagnostic_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type DiagnosticClient struct { } // NewDiagnosticClient creates a new instance of DiagnosticClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewDiagnosticClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DiagnosticClient, error) { @@ -47,7 +44,7 @@ func NewDiagnosticClient(subscriptionID string, credential azcore.TokenCredentia // CreateOrUpdate - Creates a new Diagnostic or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. @@ -100,12 +97,12 @@ func (client *DiagnosticClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -127,7 +124,7 @@ func (client *DiagnosticClient) createOrUpdateHandleResponse(resp *http.Response // Delete - Deletes the specified Diagnostic. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. @@ -156,7 +153,7 @@ func (client *DiagnosticClient) Delete(ctx context.Context, resourceGroupName st } // deleteCreateRequest creates the Delete request. -func (client *DiagnosticClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string, options *DiagnosticClientDeleteOptions) (*policy.Request, error) { +func (client *DiagnosticClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string, _ *DiagnosticClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -179,17 +176,17 @@ func (client *DiagnosticClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the Diagnostic specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. @@ -217,7 +214,7 @@ func (client *DiagnosticClient) Get(ctx context.Context, resourceGroupName strin } // getCreateRequest creates the Get request. -func (client *DiagnosticClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, options *DiagnosticClientGetOptions) (*policy.Request, error) { +func (client *DiagnosticClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, _ *DiagnosticClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -240,7 +237,7 @@ func (client *DiagnosticClient) getCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -260,7 +257,7 @@ func (client *DiagnosticClient) getHandleResponse(resp *http.Response) (Diagnost // GetEntityTag - Gets the entity state (Etag) version of the Diagnostic specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. @@ -288,7 +285,7 @@ func (client *DiagnosticClient) GetEntityTag(ctx context.Context, resourceGroupN } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *DiagnosticClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, options *DiagnosticClientGetEntityTagOptions) (*policy.Request, error) { +func (client *DiagnosticClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, _ *DiagnosticClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -311,7 +308,7 @@ func (client *DiagnosticClient) getEntityTagCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -328,7 +325,7 @@ func (client *DiagnosticClient) getEntityTagHandleResponse(resp *http.Response) // NewListByServicePager - Lists all diagnostics of the API Management service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - DiagnosticClientListByServiceOptions contains the optional parameters for the DiagnosticClient.NewListByServicePager @@ -379,13 +376,13 @@ func (client *DiagnosticClient) listByServiceCreateRequest(ctx context.Context, if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -403,7 +400,7 @@ func (client *DiagnosticClient) listByServiceHandleResponse(resp *http.Response) // Update - Updates the details of the Diagnostic specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. @@ -434,7 +431,7 @@ func (client *DiagnosticClient) Update(ctx context.Context, resourceGroupName st } // updateCreateRequest creates the Update request. -func (client *DiagnosticClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string, parameters DiagnosticContract, options *DiagnosticClientUpdateOptions) (*policy.Request, error) { +func (client *DiagnosticClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string, parameters DiagnosticContract, _ *DiagnosticClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -457,10 +454,10 @@ func (client *DiagnosticClient) updateCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/diagnostic_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/diagnostic_client_example_test.go deleted file mode 100644 index 42c26be8cb1b..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/diagnostic_client_example_test.go +++ /dev/null @@ -1,427 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListDiagnostics.json -func ExampleDiagnosticClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDiagnosticClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.DiagnosticClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.DiagnosticCollection = armapimanagement.DiagnosticCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.DiagnosticContract{ - // { - // Name: to.Ptr("applicationinsights"), - // Type: to.Ptr("Microsoft.ApiManagement/service/diagnostics"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/diagnostics/applicationinsights"), - // Properties: &armapimanagement.DiagnosticContractProperties{ - // AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - // Backend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](0), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](0), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // Frontend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](0), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](0), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // HTTPCorrelationProtocol: to.Ptr(armapimanagement.HTTPCorrelationProtocolLegacy), - // LogClientIP: to.Ptr(true), - // LoggerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/aisamplingtest"), - // Sampling: &armapimanagement.SamplingSettings{ - // Percentage: to.Ptr[float64](100), - // SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - // }, - // Verbosity: to.Ptr(armapimanagement.VerbosityInformation), - // }, - // }, - // { - // Name: to.Ptr("azuremonitor"), - // Type: to.Ptr("Microsoft.ApiManagement/service/diagnostics"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/diagnostics/azuremonitor"), - // Properties: &armapimanagement.DiagnosticContractProperties{ - // LogClientIP: to.Ptr(true), - // LoggerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/azuremonitor"), - // Sampling: &armapimanagement.SamplingSettings{ - // Percentage: to.Ptr[float64](100), - // SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadDiagnostic.json -func ExampleDiagnosticClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDiagnosticClient().GetEntityTag(ctx, "rg1", "apimService1", "applicationinsights", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetDiagnostic.json -func ExampleDiagnosticClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDiagnosticClient().Get(ctx, "rg1", "apimService1", "applicationinsights", 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.DiagnosticContract = armapimanagement.DiagnosticContract{ - // Name: to.Ptr("applicationinsights"), - // Type: to.Ptr("Microsoft.ApiManagement/service/diagnostics"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/diagnostics/applicationinsights"), - // Properties: &armapimanagement.DiagnosticContractProperties{ - // AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - // Backend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // Frontend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](100), - // }, - // Headers: []*string{ - // }, - // }, - // }, - // HTTPCorrelationProtocol: to.Ptr(armapimanagement.HTTPCorrelationProtocolLegacy), - // LogClientIP: to.Ptr(true), - // LoggerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/aisamplingtest"), - // Sampling: &armapimanagement.SamplingSettings{ - // Percentage: to.Ptr[float64](100), - // SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateDiagnostic.json -func ExampleDiagnosticClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDiagnosticClient().CreateOrUpdate(ctx, "rg1", "apimService1", "applicationinsights", armapimanagement.DiagnosticContract{ - Properties: &armapimanagement.DiagnosticContractProperties{ - AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - Backend: &armapimanagement.PipelineDiagnosticSettings{ - Response: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - Request: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - }, - Frontend: &armapimanagement.PipelineDiagnosticSettings{ - Response: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - Request: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - }, - LoggerID: to.Ptr("/loggers/azuremonitor"), - Sampling: &armapimanagement.SamplingSettings{ - Percentage: to.Ptr[float64](50), - SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - }, - }, - }, &armapimanagement.DiagnosticClientCreateOrUpdateOptions{IfMatch: 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.DiagnosticContract = armapimanagement.DiagnosticContract{ - // Name: to.Ptr("applicationinsights"), - // Type: to.Ptr("Microsoft.ApiManagement/service/diagnostics"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/diagnostics/applicationinsights"), - // Properties: &armapimanagement.DiagnosticContractProperties{ - // AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - // Backend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // }, - // Frontend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // }, - // LoggerID: to.Ptr("/loggers/applicationinsights"), - // Sampling: &armapimanagement.SamplingSettings{ - // Percentage: to.Ptr[float64](50), - // SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateDiagnostic.json -func ExampleDiagnosticClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDiagnosticClient().Update(ctx, "rg1", "apimService1", "applicationinsights", "*", armapimanagement.DiagnosticContract{ - Properties: &armapimanagement.DiagnosticContractProperties{ - AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - Backend: &armapimanagement.PipelineDiagnosticSettings{ - Response: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - Request: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - }, - Frontend: &armapimanagement.PipelineDiagnosticSettings{ - Response: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - Request: &armapimanagement.HTTPMessageDiagnostic{ - Body: &armapimanagement.BodyDiagnosticSettings{ - Bytes: to.Ptr[int32](512), - }, - Headers: []*string{ - to.Ptr("Content-type")}, - }, - }, - LoggerID: to.Ptr("/loggers/applicationinsights"), - Sampling: &armapimanagement.SamplingSettings{ - Percentage: to.Ptr[float64](50), - SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - }, - }, - }, 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.DiagnosticContract = armapimanagement.DiagnosticContract{ - // Name: to.Ptr("applicationinsights"), - // Type: to.Ptr("Microsoft.ApiManagement/service/diagnostics"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/diagnostics/applicationinsights"), - // Properties: &armapimanagement.DiagnosticContractProperties{ - // AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors), - // Backend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // }, - // Frontend: &armapimanagement.PipelineDiagnosticSettings{ - // Response: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // Request: &armapimanagement.HTTPMessageDiagnostic{ - // Body: &armapimanagement.BodyDiagnosticSettings{ - // Bytes: to.Ptr[int32](512), - // }, - // Headers: []*string{ - // to.Ptr("Content-type")}, - // }, - // }, - // HTTPCorrelationProtocol: to.Ptr(armapimanagement.HTTPCorrelationProtocolLegacy), - // LogClientIP: to.Ptr(true), - // LoggerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/aisamplingtest"), - // Sampling: &armapimanagement.SamplingSettings{ - // Percentage: to.Ptr[float64](50), - // SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteDiagnostic.json -func ExampleDiagnosticClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDiagnosticClient().Delete(ctx, "rg1", "apimService1", "applicationinsights", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/documentation_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/documentation_client.go index d0cfcac227ff..a5d37863600d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/documentation_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/documentation_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type DocumentationClient struct { } // NewDocumentationClient creates a new instance of DocumentationClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewDocumentationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DocumentationClient, error) { @@ -47,7 +44,7 @@ func NewDocumentationClient(subscriptionID string, credential azcore.TokenCreden // CreateOrUpdate - Creates a new Documentation or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - documentationID - Documentation identifier. Must be unique in the current API Management service instance. @@ -100,12 +97,12 @@ func (client *DocumentationClient) createOrUpdateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -127,7 +124,7 @@ func (client *DocumentationClient) createOrUpdateHandleResponse(resp *http.Respo // Delete - Deletes the specified Documentation from an API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - documentationID - Documentation identifier. Must be unique in the current API Management service instance. @@ -156,7 +153,7 @@ func (client *DocumentationClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *DocumentationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, documentationID string, ifMatch string, options *DocumentationClientDeleteOptions) (*policy.Request, error) { +func (client *DocumentationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, documentationID string, ifMatch string, _ *DocumentationClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -179,17 +176,17 @@ func (client *DocumentationClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the Documentation specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - documentationID - Documentation identifier. Must be unique in the current API Management service instance. @@ -217,7 +214,7 @@ func (client *DocumentationClient) Get(ctx context.Context, resourceGroupName st } // getCreateRequest creates the Get request. -func (client *DocumentationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, documentationID string, options *DocumentationClientGetOptions) (*policy.Request, error) { +func (client *DocumentationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, documentationID string, _ *DocumentationClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -240,7 +237,7 @@ func (client *DocumentationClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -260,7 +257,7 @@ func (client *DocumentationClient) getHandleResponse(resp *http.Response) (Docum // GetEntityTag - Gets the entity state (Etag) version of the Documentation by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - documentationID - Documentation identifier. Must be unique in the current API Management service instance. @@ -289,7 +286,7 @@ func (client *DocumentationClient) GetEntityTag(ctx context.Context, resourceGro } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *DocumentationClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, documentationID string, options *DocumentationClientGetEntityTagOptions) (*policy.Request, error) { +func (client *DocumentationClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, documentationID string, _ *DocumentationClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -312,7 +309,7 @@ func (client *DocumentationClient) getEntityTagCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -329,7 +326,7 @@ func (client *DocumentationClient) getEntityTagHandleResponse(resp *http.Respons // NewListByServicePager - Lists all Documentations of the API Management service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - DocumentationClientListByServiceOptions contains the optional parameters for the DocumentationClient.NewListByServicePager @@ -380,13 +377,13 @@ func (client *DocumentationClient) listByServiceCreateRequest(ctx context.Contex if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -404,7 +401,7 @@ func (client *DocumentationClient) listByServiceHandleResponse(resp *http.Respon // Update - Updates the details of the Documentation for an API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - documentationID - Documentation identifier. Must be unique in the current API Management service instance. @@ -435,7 +432,7 @@ func (client *DocumentationClient) Update(ctx context.Context, resourceGroupName } // updateCreateRequest creates the Update request. -func (client *DocumentationClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, documentationID string, ifMatch string, parameters DocumentationUpdateContract, options *DocumentationClientUpdateOptions) (*policy.Request, error) { +func (client *DocumentationClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, documentationID string, ifMatch string, parameters DocumentationUpdateContract, _ *DocumentationClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -458,10 +455,10 @@ func (client *DocumentationClient) updateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/documentation_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/documentation_client_example_test.go deleted file mode 100644 index 90f17a25f87b..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/documentation_client_example_test.go +++ /dev/null @@ -1,208 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListDocumentations.json -func ExampleDocumentationClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDocumentationClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.DocumentationClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.DocumentationCollection = armapimanagement.DocumentationCollection{ - // Value: []*armapimanagement.DocumentationContract{ - // { - // Name: to.Ptr("test"), - // Type: to.Ptr("Microsoft.ApiManagement/service/documentations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/documentations/test"), - // Properties: &armapimanagement.DocumentationContractProperties{ - // Content: to.Ptr("Test content "), - // Title: to.Ptr("test"), - // }, - // }, - // { - // Name: to.Ptr("test2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/documentations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/documentations/test2"), - // Properties: &armapimanagement.DocumentationContractProperties{ - // Content: to.Ptr("Test content "), - // Title: to.Ptr("test"), - // }, - // }, - // { - // Name: to.Ptr("test3"), - // Type: to.Ptr("Microsoft.ApiManagement/service/documentations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/documentations/test3"), - // Properties: &armapimanagement.DocumentationContractProperties{ - // Content: to.Ptr("Test content "), - // Title: to.Ptr("test"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadDocumentation.json -func ExampleDocumentationClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDocumentationClient().GetEntityTag(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetDocumentation.json -func ExampleDocumentationClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDocumentationClient().Get(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", 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.DocumentationContract = armapimanagement.DocumentationContract{ - // Name: to.Ptr("57d1f7558aa04f15146d9d8a"), - // Type: to.Ptr("Microsoft.ApiManagement/service/documentations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/documentations/57d1f7558aa04f15146d9d8a"), - // Properties: &armapimanagement.DocumentationContractProperties{ - // Content: to.Ptr("content"), - // Title: to.Ptr("Title"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateDocumentation.json -func ExampleDocumentationClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDocumentationClient().CreateOrUpdate(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", armapimanagement.DocumentationContract{ - Properties: &armapimanagement.DocumentationContractProperties{ - Content: to.Ptr("content"), - Title: to.Ptr("Title"), - }, - }, &armapimanagement.DocumentationClientCreateOrUpdateOptions{IfMatch: 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.DocumentationContract = armapimanagement.DocumentationContract{ - // Name: to.Ptr("57d1f7558aa04f15146d9d8a"), - // Type: to.Ptr("Microsoft.ApiManagement/service/documentations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/documentations/57d1f7558aa04f15146d9d8a"), - // Properties: &armapimanagement.DocumentationContractProperties{ - // Content: to.Ptr("content"), - // Title: to.Ptr("Title"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateDocumentation.json -func ExampleDocumentationClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDocumentationClient().Update(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "", armapimanagement.DocumentationUpdateContract{ - Properties: &armapimanagement.DocumentationContractProperties{ - Content: to.Ptr("content updated"), - Title: to.Ptr("Title updated"), - }, - }, 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.DocumentationContract = armapimanagement.DocumentationContract{ - // Name: to.Ptr("57d1f7558aa04f15146d9d8a"), - // Type: to.Ptr("Microsoft.ApiManagement/service/documentations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/documentations/57d1f7558aa04f15146d9d8a"), - // Properties: &armapimanagement.DocumentationContractProperties{ - // Content: to.Ptr("content updated"), - // Title: to.Ptr("Title updated"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteDocumentation.json -func ExampleDocumentationClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDocumentationClient().Delete(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/emailtemplate_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/emailtemplate_client.go index c072054429f0..e1566adeb9e0 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/emailtemplate_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/emailtemplate_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type EmailTemplateClient struct { } // NewEmailTemplateClient creates a new instance of EmailTemplateClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewEmailTemplateClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EmailTemplateClient, error) { @@ -47,7 +44,7 @@ func NewEmailTemplateClient(subscriptionID string, credential azcore.TokenCreden // CreateOrUpdate - Updates an Email Template. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - templateName - Email Template Name Identifier. @@ -100,12 +97,12 @@ func (client *EmailTemplateClient) createOrUpdateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -124,7 +121,7 @@ func (client *EmailTemplateClient) createOrUpdateHandleResponse(resp *http.Respo // Delete - Reset the Email Template to default template provided by the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - templateName - Email Template Name Identifier. @@ -153,7 +150,7 @@ func (client *EmailTemplateClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *EmailTemplateClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, options *EmailTemplateClientDeleteOptions) (*policy.Request, error) { +func (client *EmailTemplateClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, _ *EmailTemplateClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -176,17 +173,17 @@ func (client *EmailTemplateClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the email template specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - templateName - Email Template Name Identifier. @@ -214,7 +211,7 @@ func (client *EmailTemplateClient) Get(ctx context.Context, resourceGroupName st } // getCreateRequest creates the Get request. -func (client *EmailTemplateClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, options *EmailTemplateClientGetOptions) (*policy.Request, error) { +func (client *EmailTemplateClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, _ *EmailTemplateClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -237,7 +234,7 @@ func (client *EmailTemplateClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -257,7 +254,7 @@ func (client *EmailTemplateClient) getHandleResponse(resp *http.Response) (Email // GetEntityTag - Gets the entity state (Etag) version of the email template specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - templateName - Email Template Name Identifier. @@ -286,7 +283,7 @@ func (client *EmailTemplateClient) GetEntityTag(ctx context.Context, resourceGro } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *EmailTemplateClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, options *EmailTemplateClientGetEntityTagOptions) (*policy.Request, error) { +func (client *EmailTemplateClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, _ *EmailTemplateClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -309,7 +306,7 @@ func (client *EmailTemplateClient) getEntityTagCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -326,7 +323,7 @@ func (client *EmailTemplateClient) getEntityTagHandleResponse(resp *http.Respons // NewListByServicePager - Gets all email templates // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - EmailTemplateClientListByServiceOptions contains the optional parameters for the EmailTemplateClient.NewListByServicePager @@ -377,13 +374,13 @@ func (client *EmailTemplateClient) listByServiceCreateRequest(ctx context.Contex if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -401,7 +398,7 @@ func (client *EmailTemplateClient) listByServiceHandleResponse(resp *http.Respon // Update - Updates API Management email template // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - templateName - Email Template Name Identifier. @@ -432,7 +429,7 @@ func (client *EmailTemplateClient) Update(ctx context.Context, resourceGroupName } // updateCreateRequest creates the Update request. -func (client *EmailTemplateClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, parameters EmailTemplateUpdateParameters, options *EmailTemplateClientUpdateOptions) (*policy.Request, error) { +func (client *EmailTemplateClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, parameters EmailTemplateUpdateParameters, _ *EmailTemplateClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -455,10 +452,10 @@ func (client *EmailTemplateClient) updateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/emailtemplate_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/emailtemplate_client_example_test.go deleted file mode 100644 index 4b56a4336f96..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/emailtemplate_client_example_test.go +++ /dev/null @@ -1,302 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTemplates.json -func ExampleEmailTemplateClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewEmailTemplateClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.EmailTemplateClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.EmailTemplateCollection = armapimanagement.EmailTemplateCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.EmailTemplateContract{ - // { - // Name: to.Ptr("ApplicationApprovedNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/templates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/templates/ApplicationApprovedNotificationMessage"), - // Properties: &armapimanagement.EmailTemplateContractProperties{ - // Description: to.Ptr("Developers who submitted their application for publication in the application gallery on the developer portal receive this email after their submission is approved."), - // Body: to.Ptr("\r\n\r\n \r\n \r\n

Dear $DevFirstName $DevLastName,

\r\n

\r\n We are happy to let you know that your request to publish the $AppName application in the application gallery has been approved. Your application has been published and can be viewed here.\r\n

\r\n

Best,

\r\n

The $OrganizationName API Team

\r\n \r\n"), - // IsDefault: to.Ptr(true), - // Parameters: []*armapimanagement.EmailTemplateParametersContractProperties{ - // { - // Name: to.Ptr("AppId"), - // Title: to.Ptr("Application id"), - // }, - // { - // Name: to.Ptr("AppName"), - // Title: to.Ptr("Application name"), - // }, - // { - // Name: to.Ptr("DevFirstName"), - // Title: to.Ptr("Developer first name"), - // }, - // { - // Name: to.Ptr("DevLastName"), - // Title: to.Ptr("Developer last name"), - // }, - // { - // Name: to.Ptr("OrganizationName"), - // Title: to.Ptr("Organization name"), - // }, - // { - // Name: to.Ptr("DevPortalUrl"), - // Title: to.Ptr("Developer portal URL"), - // }}, - // Subject: to.Ptr("Your application $AppName is published in the application gallery"), - // Title: to.Ptr("Application gallery submission approved"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadEmailTemplate.json -func ExampleEmailTemplateClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewEmailTemplateClient().GetEntityTag(ctx, "rg1", "apimService1", armapimanagement.TemplateNameNewIssueNotificationMessage, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTemplate.json -func ExampleEmailTemplateClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewEmailTemplateClient().Get(ctx, "rg1", "apimService1", armapimanagement.TemplateNameNewIssueNotificationMessage, 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.EmailTemplateContract = armapimanagement.EmailTemplateContract{ - // Name: to.Ptr("NewIssueNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/templates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/templates/NewIssueNotificationMessage"), - // Properties: &armapimanagement.EmailTemplateContractProperties{ - // Description: to.Ptr("This email is sent to developers after they create a new topic on the Issues page of the developer portal."), - // Body: to.Ptr("\r\n\r\n \r\n \r\n

Dear $DevFirstName $DevLastName,

\r\n

Thank you for contacting us. Our API team will review your issue and get back to you soon.

\r\n

\r\n Click this link to view or edit your request.\r\n

\r\n

Best,

\r\n

The $OrganizationName API Team

\r\n \r\n"), - // IsDefault: to.Ptr(true), - // Parameters: []*armapimanagement.EmailTemplateParametersContractProperties{ - // { - // Name: to.Ptr("DevFirstName"), - // Title: to.Ptr("Developer first name"), - // }, - // { - // Name: to.Ptr("DevLastName"), - // Title: to.Ptr("Developer last name"), - // }, - // { - // Name: to.Ptr("IssueId"), - // Title: to.Ptr("Issue id"), - // }, - // { - // Name: to.Ptr("IssueName"), - // Title: to.Ptr("Issue name"), - // }, - // { - // Name: to.Ptr("OrganizationName"), - // Title: to.Ptr("Organization name"), - // }, - // { - // Name: to.Ptr("DevPortalUrl"), - // Title: to.Ptr("Developer portal URL"), - // }}, - // Subject: to.Ptr("Your request $IssueName was received"), - // Title: to.Ptr("New issue received"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateTemplate.json -func ExampleEmailTemplateClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewEmailTemplateClient().CreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.TemplateNameNewIssueNotificationMessage, armapimanagement.EmailTemplateUpdateParameters{ - Properties: &armapimanagement.EmailTemplateUpdateParameterProperties{ - Subject: to.Ptr("Your request for $IssueName was successfully received."), - }, - }, &armapimanagement.EmailTemplateClientCreateOrUpdateOptions{IfMatch: 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.EmailTemplateContract = armapimanagement.EmailTemplateContract{ - // Name: to.Ptr("NewIssueNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/templates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/templates/NewIssueNotificationMessage"), - // Properties: &armapimanagement.EmailTemplateContractProperties{ - // Description: to.Ptr("This email is sent to developers after they create a new topic on the Issues page of the developer portal."), - // Body: to.Ptr("\r\n\r\n \r\n \r\n

Dear $DevFirstName $DevLastName,

\r\n

Thank you for contacting us. Our API team will review your issue and get back to you soon.

\r\n

\r\n Click this link to view or edit your request.\r\n

\r\n

Best,

\r\n

The $OrganizationName API Team

\r\n \r\n"), - // IsDefault: to.Ptr(false), - // Parameters: []*armapimanagement.EmailTemplateParametersContractProperties{ - // { - // Name: to.Ptr("DevFirstName"), - // Title: to.Ptr("Developer first name"), - // }, - // { - // Name: to.Ptr("DevLastName"), - // Title: to.Ptr("Developer last name"), - // }, - // { - // Name: to.Ptr("IssueId"), - // Title: to.Ptr("Issue id"), - // }, - // { - // Name: to.Ptr("IssueName"), - // Title: to.Ptr("Issue name"), - // }, - // { - // Name: to.Ptr("OrganizationName"), - // Title: to.Ptr("Organization name"), - // }, - // { - // Name: to.Ptr("DevPortalUrl"), - // Title: to.Ptr("Developer portal URL"), - // }}, - // Subject: to.Ptr("Your request for $IssueName was successfully received."), - // Title: to.Ptr("New issue received"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateTemplate.json -func ExampleEmailTemplateClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewEmailTemplateClient().Update(ctx, "rg1", "apimService1", armapimanagement.TemplateNameNewIssueNotificationMessage, "*", armapimanagement.EmailTemplateUpdateParameters{ - Properties: &armapimanagement.EmailTemplateUpdateParameterProperties{ - Body: to.Ptr("\r\n\r\n \r\n \r\n

Dear $DevFirstName $DevLastName,

\r\n

\r\n We are happy to let you know that your request to publish the $AppName application in the gallery has been approved. Your application has been published and can be viewed here.\r\n

\r\n

Best,

\r\n

The $OrganizationName API Team

\r\n \r\n"), - Subject: to.Ptr("Your request $IssueName was received"), - }, - }, 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.EmailTemplateContract = armapimanagement.EmailTemplateContract{ - // Name: to.Ptr("NewIssueNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/templates"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/templates/NewIssueNotificationMessage"), - // Properties: &armapimanagement.EmailTemplateContractProperties{ - // Description: to.Ptr("This email is sent to developers after they create a new topic on the Issues page of the developer portal."), - // Body: to.Ptr("\r\n\r\n \r\n \r\n

Dear $DevFirstName $DevLastName,

\r\n

Thank you for contacting us. Our API team will review your issue and get back to you soon.

\r\n

\r\n Click this link to view or edit your request.\r\n

\r\n

Best,

\r\n

The $OrganizationName API Team

\r\n \r\n"), - // IsDefault: to.Ptr(true), - // Parameters: []*armapimanagement.EmailTemplateParametersContractProperties{ - // { - // Name: to.Ptr("DevFirstName"), - // Title: to.Ptr("Developer first name"), - // }, - // { - // Name: to.Ptr("DevLastName"), - // Title: to.Ptr("Developer last name"), - // }, - // { - // Name: to.Ptr("IssueId"), - // Title: to.Ptr("Issue id"), - // }, - // { - // Name: to.Ptr("IssueName"), - // Title: to.Ptr("Issue name"), - // }, - // { - // Name: to.Ptr("OrganizationName"), - // Title: to.Ptr("Organization name"), - // }, - // { - // Name: to.Ptr("DevPortalUrl"), - // Title: to.Ptr("Developer portal URL"), - // }}, - // Subject: to.Ptr("Your request $IssueName was received"), - // Title: to.Ptr("New issue received"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteTemplate.json -func ExampleEmailTemplateClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewEmailTemplateClient().Delete(ctx, "rg1", "apimService1", armapimanagement.TemplateNameNewIssueNotificationMessage, "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/allpolicies_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/allpolicies_server.go new file mode 100644 index 000000000000..8ee6980dbd54 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/allpolicies_server.go @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// AllPoliciesServer is a fake server for instances of the armapimanagement.AllPoliciesClient type. +type AllPoliciesServer struct { + // NewListByServicePager is the fake for method AllPoliciesClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, options *armapimanagement.AllPoliciesClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.AllPoliciesClientListByServiceResponse]) +} + +// NewAllPoliciesServerTransport creates a new instance of AllPoliciesServerTransport with the provided implementation. +// The returned AllPoliciesServerTransport instance is connected to an instance of armapimanagement.AllPoliciesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAllPoliciesServerTransport(srv *AllPoliciesServer) *AllPoliciesServerTransport { + return &AllPoliciesServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.AllPoliciesClientListByServiceResponse]](), + } +} + +// AllPoliciesServerTransport connects instances of armapimanagement.AllPoliciesClient to instances of AllPoliciesServer. +// Don't use this type directly, use NewAllPoliciesServerTransport instead. +type AllPoliciesServerTransport struct { + srv *AllPoliciesServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.AllPoliciesClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for AllPoliciesServerTransport. +func (a *AllPoliciesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return a.dispatchToMethodFake(req, method) +} + +func (a *AllPoliciesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if allPoliciesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = allPoliciesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AllPoliciesClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (a *AllPoliciesServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := a.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/allPolicies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, nil) + newListByServicePager = &resp + a.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.AllPoliciesClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + a.newListByServicePager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to AllPoliciesServerTransport +var allPoliciesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/api_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/api_server.go index b5af30e34c1d..0205dd0e1178 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/api_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/api_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -26,12 +23,12 @@ import ( // APIServer is a fake server for instances of the armapimanagement.APIClient type. type APIServer struct { // BeginCreateOrUpdate is the fake for method APIClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, apiID string, parameters armapimanagement.APICreateOrUpdateParameter, options *armapimanagement.APIClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.APIClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - // Delete is the fake for method APIClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *armapimanagement.APIClientDeleteOptions) (resp azfake.Responder[armapimanagement.APIClientDeleteResponse], errResp azfake.ErrorResponder) + // BeginDelete is the fake for method APIClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *armapimanagement.APIClientBeginDeleteOptions) (resp azfake.PollerResponder[armapimanagement.APIClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method APIClient.Get // HTTP status codes to indicate success: http.StatusOK @@ -61,6 +58,7 @@ func NewAPIServerTransport(srv *APIServer) *APIServerTransport { return &APIServerTransport{ srv: srv, beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.APIClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armapimanagement.APIClientDeleteResponse]](), newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.APIClientListByServiceResponse]](), newListByTagsPager: newTracker[azfake.PagerResponder[armapimanagement.APIClientListByTagsResponse]](), } @@ -71,6 +69,7 @@ func NewAPIServerTransport(srv *APIServer) *APIServerTransport { type APIServerTransport struct { srv *APIServer beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.APIClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armapimanagement.APIClientDeleteResponse]] newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.APIClientListByServiceResponse]] newListByTagsPager *tracker[azfake.PagerResponder[armapimanagement.APIClientListByTagsResponse]] } @@ -83,33 +82,52 @@ func (a *APIServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIClient.BeginCreateOrUpdate": - resp, err = a.dispatchBeginCreateOrUpdate(req) - case "APIClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIClient.Get": - resp, err = a.dispatchGet(req) - case "APIClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - case "APIClient.NewListByTagsPager": - resp, err = a.dispatchNewListByTagsPager(req) - case "APIClient.Update": - resp, err = a.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIClient.BeginCreateOrUpdate": + res.resp, res.err = a.dispatchBeginCreateOrUpdate(req) + case "APIClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "APIClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + case "APIClient.NewListByTagsPager": + res.resp, res.err = a.dispatchNewListByTagsPager(req) + case "APIClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -160,9 +178,9 @@ func (a *APIServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*ht return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { a.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { a.beginCreateOrUpdate.remove(req) @@ -171,55 +189,66 @@ func (a *APIServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*ht return resp, nil } -func (a *APIServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if a.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) +func (a *APIServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } - qp := req.URL.Query() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) - if err != nil { - return nil, err - } - apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) - if err != nil { - return nil, err - } - deleteRevisionsUnescaped, err := url.QueryUnescape(qp.Get("deleteRevisions")) - if err != nil { - return nil, err + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + deleteRevisionsUnescaped, err := url.QueryUnescape(qp.Get("deleteRevisions")) + if err != nil { + return nil, err + } + deleteRevisionsParam, err := parseOptional(deleteRevisionsUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armapimanagement.APIClientBeginDeleteOptions + if deleteRevisionsParam != nil { + options = &armapimanagement.APIClientBeginDeleteOptions{ + DeleteRevisions: deleteRevisionsParam, + } + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, serviceNameParam, apiIDParam, getHeaderValue(req.Header, "If-Match"), options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) } - deleteRevisionsParam, err := parseOptional(deleteRevisionsUnescaped, strconv.ParseBool) + + resp, err := server.PollerResponderNext(beginDelete, req) if err != nil { return nil, err } - var options *armapimanagement.APIClientDeleteOptions - if deleteRevisionsParam != nil { - options = &armapimanagement.APIClientDeleteOptions{ - DeleteRevisions: deleteRevisionsParam, - } - } - respr, errRespr := a.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, apiIDParam, getHeaderValue(req.Header, "If-Match"), options) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) } + return resp, nil } @@ -536,3 +565,9 @@ func (a *APIServerTransport) dispatchUpdate(req *http.Request) (*http.Response, } return resp, nil } + +// set this to conditionally intercept incoming requests to APIServerTransport +var apiServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apidiagnostic_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apidiagnostic_server.go index b24825744d6a..b940f2c78882 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apidiagnostic_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apidiagnostic_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (a *APIDiagnosticServerTransport) Do(req *http.Request) (*http.Response, er return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIDiagnosticClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIDiagnosticClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIDiagnosticClient.Get": - resp, err = a.dispatchGet(req) - case "APIDiagnosticClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIDiagnosticClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - case "APIDiagnosticClient.Update": - resp, err = a.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIDiagnosticServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiDiagnosticServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiDiagnosticServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIDiagnosticClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIDiagnosticClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIDiagnosticClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIDiagnosticClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIDiagnosticClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + case "APIDiagnosticClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIDiagnosticServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -420,3 +436,9 @@ func (a *APIDiagnosticServerTransport) dispatchUpdate(req *http.Request) (*http. } return resp, nil } + +// set this to conditionally intercept incoming requests to APIDiagnosticServerTransport +var apiDiagnosticServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiexport_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiexport_server.go index efe480364e98..7692dcd9c157 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiexport_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiexport_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (a *APIExportServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIExportClient.Get": - resp, err = a.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIExportServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiExportServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiExportServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIExportClient.Get": + res.resp, res.err = a.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIExportServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -123,3 +139,9 @@ func (a *APIExportServerTransport) dispatchGet(req *http.Request) (*http.Respons } return resp, nil } + +// set this to conditionally intercept incoming requests to APIExportServerTransport +var apiExportServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apigateway_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apigateway_server.go new file mode 100644 index 000000000000..5b7c8edf3b23 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apigateway_server.go @@ -0,0 +1,375 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// APIGatewayServer is a fake server for instances of the armapimanagement.APIGatewayClient type. +type APIGatewayServer struct { + // BeginCreateOrUpdate is the fake for method APIGatewayClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, gatewayName string, parameters armapimanagement.GatewayResource, options *armapimanagement.APIGatewayClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.APIGatewayClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method APIGatewayClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, gatewayName string, options *armapimanagement.APIGatewayClientBeginDeleteOptions) (resp azfake.PollerResponder[armapimanagement.APIGatewayClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method APIGatewayClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, gatewayName string, options *armapimanagement.APIGatewayClientGetOptions) (resp azfake.Responder[armapimanagement.APIGatewayClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method APIGatewayClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armapimanagement.APIGatewayClientListOptions) (resp azfake.PagerResponder[armapimanagement.APIGatewayClientListResponse]) + + // NewListByResourceGroupPager is the fake for method APIGatewayClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armapimanagement.APIGatewayClientListByResourceGroupOptions) (resp azfake.PagerResponder[armapimanagement.APIGatewayClientListByResourceGroupResponse]) + + // BeginUpdate is the fake for method APIGatewayClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, gatewayName string, parameters armapimanagement.GatewayUpdateParameters, options *armapimanagement.APIGatewayClientBeginUpdateOptions) (resp azfake.PollerResponder[armapimanagement.APIGatewayClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewAPIGatewayServerTransport creates a new instance of APIGatewayServerTransport with the provided implementation. +// The returned APIGatewayServerTransport instance is connected to an instance of armapimanagement.APIGatewayClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAPIGatewayServerTransport(srv *APIGatewayServer) *APIGatewayServerTransport { + return &APIGatewayServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.APIGatewayClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armapimanagement.APIGatewayClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armapimanagement.APIGatewayClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armapimanagement.APIGatewayClientListByResourceGroupResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armapimanagement.APIGatewayClientUpdateResponse]](), + } +} + +// APIGatewayServerTransport connects instances of armapimanagement.APIGatewayClient to instances of APIGatewayServer. +// Don't use this type directly, use NewAPIGatewayServerTransport instead. +type APIGatewayServerTransport struct { + srv *APIGatewayServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.APIGatewayClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armapimanagement.APIGatewayClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armapimanagement.APIGatewayClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armapimanagement.APIGatewayClientListByResourceGroupResponse]] + beginUpdate *tracker[azfake.PollerResponder[armapimanagement.APIGatewayClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for APIGatewayServerTransport. +func (a *APIGatewayServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return a.dispatchToMethodFake(req, method) +} + +func (a *APIGatewayServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if apiGatewayServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiGatewayServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIGatewayClient.BeginCreateOrUpdate": + res.resp, res.err = a.dispatchBeginCreateOrUpdate(req) + case "APIGatewayClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "APIGatewayClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIGatewayClient.NewListPager": + res.resp, res.err = a.dispatchNewListPager(req) + case "APIGatewayClient.NewListByResourceGroupPager": + res.resp, res.err = a.dispatchNewListByResourceGroupPager(req) + case "APIGatewayClient.BeginUpdate": + res.resp, res.err = a.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (a *APIGatewayServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := a.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.GatewayResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + gatewayNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, gatewayNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + a.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + a.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + a.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (a *APIGatewayServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + gatewayNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, gatewayNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *APIGatewayServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + gatewayNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, gatewayNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GatewayResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *APIGatewayServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := a.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := a.srv.NewListPager(nil) + newListPager = &resp + a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armapimanagement.APIGatewayClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + a.newListPager.remove(req) + } + return resp, nil +} + +func (a *APIGatewayServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := a.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + a.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armapimanagement.APIGatewayClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + a.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (a *APIGatewayServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := a.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.GatewayUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + gatewayNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginUpdate(req.Context(), resourceGroupNameParam, gatewayNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + a.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + a.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to APIGatewayServerTransport +var apiGatewayServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apigatewayconfigconnection_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apigatewayconfigconnection_server.go new file mode 100644 index 000000000000..0969bb073ff1 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apigatewayconfigconnection_server.go @@ -0,0 +1,294 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// APIGatewayConfigConnectionServer is a fake server for instances of the armapimanagement.APIGatewayConfigConnectionClient type. +type APIGatewayConfigConnectionServer struct { + // BeginCreateOrUpdate is the fake for method APIGatewayConfigConnectionClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, parameters armapimanagement.GatewayConfigConnectionResource, options *armapimanagement.APIGatewayConfigConnectionClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.APIGatewayConfigConnectionClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method APIGatewayConfigConnectionClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, ifMatch string, options *armapimanagement.APIGatewayConfigConnectionClientBeginDeleteOptions) (resp azfake.PollerResponder[armapimanagement.APIGatewayConfigConnectionClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method APIGatewayConfigConnectionClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, gatewayName string, configConnectionName string, options *armapimanagement.APIGatewayConfigConnectionClientGetOptions) (resp azfake.Responder[armapimanagement.APIGatewayConfigConnectionClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByGatewayPager is the fake for method APIGatewayConfigConnectionClient.NewListByGatewayPager + // HTTP status codes to indicate success: http.StatusOK + NewListByGatewayPager func(resourceGroupName string, gatewayName string, options *armapimanagement.APIGatewayConfigConnectionClientListByGatewayOptions) (resp azfake.PagerResponder[armapimanagement.APIGatewayConfigConnectionClientListByGatewayResponse]) +} + +// NewAPIGatewayConfigConnectionServerTransport creates a new instance of APIGatewayConfigConnectionServerTransport with the provided implementation. +// The returned APIGatewayConfigConnectionServerTransport instance is connected to an instance of armapimanagement.APIGatewayConfigConnectionClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAPIGatewayConfigConnectionServerTransport(srv *APIGatewayConfigConnectionServer) *APIGatewayConfigConnectionServerTransport { + return &APIGatewayConfigConnectionServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.APIGatewayConfigConnectionClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armapimanagement.APIGatewayConfigConnectionClientDeleteResponse]](), + newListByGatewayPager: newTracker[azfake.PagerResponder[armapimanagement.APIGatewayConfigConnectionClientListByGatewayResponse]](), + } +} + +// APIGatewayConfigConnectionServerTransport connects instances of armapimanagement.APIGatewayConfigConnectionClient to instances of APIGatewayConfigConnectionServer. +// Don't use this type directly, use NewAPIGatewayConfigConnectionServerTransport instead. +type APIGatewayConfigConnectionServerTransport struct { + srv *APIGatewayConfigConnectionServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.APIGatewayConfigConnectionClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armapimanagement.APIGatewayConfigConnectionClientDeleteResponse]] + newListByGatewayPager *tracker[azfake.PagerResponder[armapimanagement.APIGatewayConfigConnectionClientListByGatewayResponse]] +} + +// Do implements the policy.Transporter interface for APIGatewayConfigConnectionServerTransport. +func (a *APIGatewayConfigConnectionServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return a.dispatchToMethodFake(req, method) +} + +func (a *APIGatewayConfigConnectionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if apiGatewayConfigConnectionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiGatewayConfigConnectionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIGatewayConfigConnectionClient.BeginCreateOrUpdate": + res.resp, res.err = a.dispatchBeginCreateOrUpdate(req) + case "APIGatewayConfigConnectionClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "APIGatewayConfigConnectionClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIGatewayConfigConnectionClient.NewListByGatewayPager": + res.resp, res.err = a.dispatchNewListByGatewayPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (a *APIGatewayConfigConnectionServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := a.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/configConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.GatewayConfigConnectionResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + gatewayNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayName")]) + if err != nil { + return nil, err + } + configConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("configConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, gatewayNameParam, configConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + a.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + a.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + a.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (a *APIGatewayConfigConnectionServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/configConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + gatewayNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayName")]) + if err != nil { + return nil, err + } + configConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("configConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, gatewayNameParam, configConnectionNameParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *APIGatewayConfigConnectionServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/configConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + gatewayNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayName")]) + if err != nil { + return nil, err + } + configConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("configConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, gatewayNameParam, configConnectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GatewayConfigConnectionResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *APIGatewayConfigConnectionServerTransport) dispatchNewListByGatewayPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByGatewayPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByGatewayPager not implemented")} + } + newListByGatewayPager := a.newListByGatewayPager.get(req) + if newListByGatewayPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/configConnections` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + gatewayNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByGatewayPager(resourceGroupNameParam, gatewayNameParam, nil) + newListByGatewayPager = &resp + a.newListByGatewayPager.add(req, newListByGatewayPager) + server.PagerResponderInjectNextLinks(newListByGatewayPager, req, func(page *armapimanagement.APIGatewayConfigConnectionClientListByGatewayResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByGatewayPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByGatewayPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByGatewayPager) { + a.newListByGatewayPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to APIGatewayConfigConnectionServerTransport +var apiGatewayConfigConnectionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissue_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissue_server.go index 67f41fca5797..489bd4df27be 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissue_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissue_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (a *APIIssueServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIIssueClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIIssueClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIIssueClient.Get": - resp, err = a.dispatchGet(req) - case "APIIssueClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIIssueClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - case "APIIssueClient.Update": - resp, err = a.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIIssueServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiIssueServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiIssueServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIIssueClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIIssueClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIIssueClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIIssueClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIIssueClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + case "APIIssueClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIIssueServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -444,3 +460,9 @@ func (a *APIIssueServerTransport) dispatchUpdate(req *http.Request) (*http.Respo } return resp, nil } + +// set this to conditionally intercept incoming requests to APIIssueServerTransport +var apiIssueServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissueattachment_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissueattachment_server.go index 889923f8be2a..eee117704825 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissueattachment_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissueattachment_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -71,29 +68,48 @@ func (a *APIIssueAttachmentServerTransport) Do(req *http.Request) (*http.Respons return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIIssueAttachmentClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIIssueAttachmentClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIIssueAttachmentClient.Get": - resp, err = a.dispatchGet(req) - case "APIIssueAttachmentClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIIssueAttachmentClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIIssueAttachmentServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiIssueAttachmentServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiIssueAttachmentServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIIssueAttachmentClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIIssueAttachmentClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIIssueAttachmentClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIIssueAttachmentClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIIssueAttachmentClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIIssueAttachmentServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -386,3 +402,9 @@ func (a *APIIssueAttachmentServerTransport) dispatchNewListByServicePager(req *h } return resp, nil } + +// set this to conditionally intercept incoming requests to APIIssueAttachmentServerTransport +var apiIssueAttachmentServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissuecomment_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissuecomment_server.go index 7eb58b2f4b33..57924d4fcdb1 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissuecomment_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiissuecomment_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -71,29 +68,48 @@ func (a *APIIssueCommentServerTransport) Do(req *http.Request) (*http.Response, return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIIssueCommentClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIIssueCommentClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIIssueCommentClient.Get": - resp, err = a.dispatchGet(req) - case "APIIssueCommentClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIIssueCommentClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIIssueCommentServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiIssueCommentServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiIssueCommentServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIIssueCommentClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIIssueCommentClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIIssueCommentClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIIssueCommentClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIIssueCommentClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIIssueCommentServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -386,3 +402,9 @@ func (a *APIIssueCommentServerTransport) dispatchNewListByServicePager(req *http } return resp, nil } + +// set this to conditionally intercept incoming requests to APIIssueCommentServerTransport +var apiIssueCommentServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apioperation_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apioperation_server.go index b2fc7ebd39bc..9869e0b1b0e3 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apioperation_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apioperation_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (a *APIOperationServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIOperationClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIOperationClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIOperationClient.Get": - resp, err = a.dispatchGet(req) - case "APIOperationClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIOperationClient.NewListByAPIPager": - resp, err = a.dispatchNewListByAPIPager(req) - case "APIOperationClient.Update": - resp, err = a.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIOperationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiOperationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiOperationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIOperationClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIOperationClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIOperationClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIOperationClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIOperationClient.NewListByAPIPager": + res.resp, res.err = a.dispatchNewListByAPIPager(req) + case "APIOperationClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIOperationServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -426,3 +442,9 @@ func (a *APIOperationServerTransport) dispatchUpdate(req *http.Request) (*http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to APIOperationServerTransport +var apiOperationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apioperationpolicy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apioperationpolicy_server.go index e9d128783ad6..4d9b8986f4d5 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apioperationpolicy_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apioperationpolicy_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -65,29 +62,48 @@ func (a *APIOperationPolicyServerTransport) Do(req *http.Request) (*http.Respons return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIOperationPolicyClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIOperationPolicyClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIOperationPolicyClient.Get": - resp, err = a.dispatchGet(req) - case "APIOperationPolicyClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIOperationPolicyClient.ListByOperation": - resp, err = a.dispatchListByOperation(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIOperationPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiOperationPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiOperationPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIOperationPolicyClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIOperationPolicyClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIOperationPolicyClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIOperationPolicyClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIOperationPolicyClient.ListByOperation": + res.resp, res.err = a.dispatchListByOperation(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIOperationPolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -366,3 +382,9 @@ func (a *APIOperationPolicyServerTransport) dispatchListByOperation(req *http.Re } return resp, nil } + +// set this to conditionally intercept incoming requests to APIOperationPolicyServerTransport +var apiOperationPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apipolicy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apipolicy_server.go index 15c266acacd8..ead757cf3be0 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apipolicy_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apipolicy_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -65,29 +62,48 @@ func (a *APIPolicyServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIPolicyClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIPolicyClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIPolicyClient.Get": - resp, err = a.dispatchGet(req) - case "APIPolicyClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIPolicyClient.ListByAPI": - resp, err = a.dispatchListByAPI(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIPolicyClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIPolicyClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIPolicyClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIPolicyClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIPolicyClient.ListByAPI": + res.resp, res.err = a.dispatchListByAPI(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIPolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -346,3 +362,9 @@ func (a *APIPolicyServerTransport) dispatchListByAPI(req *http.Request) (*http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to APIPolicyServerTransport +var apiPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiproduct_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiproduct_server.go index df582952a096..5b42d9ea84fb 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiproduct_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiproduct_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -54,21 +51,40 @@ func (a *APIProductServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIProductClient.NewListByApisPager": - resp, err = a.dispatchNewListByApisPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIProductServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiProductServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiProductServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIProductClient.NewListByApisPager": + res.resp, res.err = a.dispatchNewListByApisPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIProductServerTransport) dispatchNewListByApisPager(req *http.Request) (*http.Response, error) { @@ -157,3 +173,9 @@ func (a *APIProductServerTransport) dispatchNewListByApisPager(req *http.Request } return resp, nil } + +// set this to conditionally intercept incoming requests to APIProductServerTransport +var apiProductServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apirelease_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apirelease_server.go index 181af776fe0d..e65e91c31393 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apirelease_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apirelease_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (a *APIReleaseServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIReleaseClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIReleaseClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIReleaseClient.Get": - resp, err = a.dispatchGet(req) - case "APIReleaseClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIReleaseClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - case "APIReleaseClient.Update": - resp, err = a.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIReleaseServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiReleaseServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiReleaseServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIReleaseClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIReleaseClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIReleaseClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIReleaseClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIReleaseClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + case "APIReleaseClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIReleaseServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -420,3 +436,9 @@ func (a *APIReleaseServerTransport) dispatchUpdate(req *http.Request) (*http.Res } return resp, nil } + +// set this to conditionally intercept incoming requests to APIReleaseServerTransport +var apiReleaseServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apirevision_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apirevision_server.go index a7dd7f27a43b..a96211477775 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apirevision_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apirevision_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -54,21 +51,40 @@ func (a *APIRevisionServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIRevisionClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIRevisionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiRevisionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiRevisionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIRevisionClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIRevisionServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { @@ -157,3 +173,9 @@ func (a *APIRevisionServerTransport) dispatchNewListByServicePager(req *http.Req } return resp, nil } + +// set this to conditionally intercept incoming requests to APIRevisionServerTransport +var apiRevisionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apischema_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apischema_server.go index c0e1ef9bfab2..a31ef0d4d2fa 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apischema_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apischema_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -26,7 +23,7 @@ import ( // APISchemaServer is a fake server for instances of the armapimanagement.APISchemaClient type. type APISchemaServer struct { // BeginCreateOrUpdate is the fake for method APISchemaClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, parameters armapimanagement.SchemaContract, options *armapimanagement.APISchemaClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.APISchemaClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method APISchemaClient.Delete @@ -73,29 +70,48 @@ func (a *APISchemaServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APISchemaClient.BeginCreateOrUpdate": - resp, err = a.dispatchBeginCreateOrUpdate(req) - case "APISchemaClient.Delete": - resp, err = a.dispatchDelete(req) - case "APISchemaClient.Get": - resp, err = a.dispatchGet(req) - case "APISchemaClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APISchemaClient.NewListByAPIPager": - resp, err = a.dispatchNewListByAPIPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APISchemaServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiSchemaServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiSchemaServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APISchemaClient.BeginCreateOrUpdate": + res.resp, res.err = a.dispatchBeginCreateOrUpdate(req) + case "APISchemaClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APISchemaClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APISchemaClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APISchemaClient.NewListByAPIPager": + res.resp, res.err = a.dispatchNewListByAPIPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APISchemaServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -150,9 +166,9 @@ func (a *APISchemaServerTransport) dispatchBeginCreateOrUpdate(req *http.Request return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { a.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { a.beginCreateOrUpdate.remove(req) @@ -391,3 +407,9 @@ func (a *APISchemaServerTransport) dispatchNewListByAPIPager(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to APISchemaServerTransport +var apiSchemaServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apitagdescription_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apitagdescription_server.go index 1954ca9d278e..88f1776ae653 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apitagdescription_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apitagdescription_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -71,29 +68,48 @@ func (a *APITagDescriptionServerTransport) Do(req *http.Request) (*http.Response return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APITagDescriptionClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APITagDescriptionClient.Delete": - resp, err = a.dispatchDelete(req) - case "APITagDescriptionClient.Get": - resp, err = a.dispatchGet(req) - case "APITagDescriptionClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APITagDescriptionClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APITagDescriptionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiTagDescriptionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiTagDescriptionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APITagDescriptionClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APITagDescriptionClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APITagDescriptionClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APITagDescriptionClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APITagDescriptionClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APITagDescriptionServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -366,3 +382,9 @@ func (a *APITagDescriptionServerTransport) dispatchNewListByServicePager(req *ht } return resp, nil } + +// set this to conditionally intercept incoming requests to APITagDescriptionServerTransport +var apiTagDescriptionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiversionset_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiversionset_server.go index d0a7ea09afa5..2602b1bd29a0 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiversionset_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiversionset_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (a *APIVersionSetServerTransport) Do(req *http.Request) (*http.Response, er return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIVersionSetClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIVersionSetClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIVersionSetClient.Get": - resp, err = a.dispatchGet(req) - case "APIVersionSetClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIVersionSetClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - case "APIVersionSetClient.Update": - resp, err = a.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIVersionSetServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiVersionSetServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiVersionSetServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIVersionSetClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIVersionSetClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIVersionSetClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIVersionSetClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIVersionSetClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + case "APIVersionSetClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIVersionSetServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -396,3 +412,9 @@ func (a *APIVersionSetServerTransport) dispatchUpdate(req *http.Request) (*http. } return resp, nil } + +// set this to conditionally intercept incoming requests to APIVersionSetServerTransport +var apiVersionSetServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiwiki_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiwiki_server.go index 4c0d1abc7b4f..f072fa185eff 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiwiki_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiwiki_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -65,29 +62,48 @@ func (a *APIWikiServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIWikiClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIWikiClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIWikiClient.Get": - resp, err = a.dispatchGet(req) - case "APIWikiClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "APIWikiClient.Update": - resp, err = a.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIWikiServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiWikiServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiWikiServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIWikiClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIWikiClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIWikiClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIWikiClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "APIWikiClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIWikiServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -301,3 +317,9 @@ func (a *APIWikiServerTransport) dispatchUpdate(req *http.Request) (*http.Respon } return resp, nil } + +// set this to conditionally intercept incoming requests to APIWikiServerTransport +var apiWikiServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiwikis_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiwikis_server.go index 264b55ebc789..cc27e4618b48 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiwikis_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/apiwikis_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -54,21 +51,40 @@ func (a *APIWikisServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIWikisClient.NewListPager": - resp, err = a.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIWikisServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiWikisServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiWikisServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIWikisClient.NewListPager": + res.resp, res.err = a.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIWikisServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -157,3 +173,9 @@ func (a *APIWikisServerTransport) dispatchNewListPager(req *http.Request) (*http } return resp, nil } + +// set this to conditionally intercept incoming requests to APIWikisServerTransport +var apiWikisServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorization_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorization_server.go index a4bb12267d1f..cd00c4d47d38 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorization_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorization_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -71,29 +68,48 @@ func (a *AuthorizationServerTransport) Do(req *http.Request) (*http.Response, er return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AuthorizationClient.ConfirmConsentCode": - resp, err = a.dispatchConfirmConsentCode(req) - case "AuthorizationClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "AuthorizationClient.Delete": - resp, err = a.dispatchDelete(req) - case "AuthorizationClient.Get": - resp, err = a.dispatchGet(req) - case "AuthorizationClient.NewListByAuthorizationProviderPager": - resp, err = a.dispatchNewListByAuthorizationProviderPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AuthorizationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if authorizationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = authorizationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AuthorizationClient.ConfirmConsentCode": + res.resp, res.err = a.dispatchConfirmConsentCode(req) + case "AuthorizationClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "AuthorizationClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "AuthorizationClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AuthorizationClient.NewListByAuthorizationProviderPager": + res.resp, res.err = a.dispatchNewListByAuthorizationProviderPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AuthorizationServerTransport) dispatchConfirmConsentCode(req *http.Request) (*http.Response, error) { @@ -370,3 +386,9 @@ func (a *AuthorizationServerTransport) dispatchNewListByAuthorizationProviderPag } return resp, nil } + +// set this to conditionally intercept incoming requests to AuthorizationServerTransport +var authorizationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationaccesspolicy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationaccesspolicy_server.go index b75d138199ab..e0c66af9952e 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationaccesspolicy_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationaccesspolicy_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -67,27 +64,46 @@ func (a *AuthorizationAccessPolicyServerTransport) Do(req *http.Request) (*http. return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AuthorizationAccessPolicyClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "AuthorizationAccessPolicyClient.Delete": - resp, err = a.dispatchDelete(req) - case "AuthorizationAccessPolicyClient.Get": - resp, err = a.dispatchGet(req) - case "AuthorizationAccessPolicyClient.NewListByAuthorizationPager": - resp, err = a.dispatchNewListByAuthorizationPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AuthorizationAccessPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if authorizationAccessPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = authorizationAccessPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AuthorizationAccessPolicyClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "AuthorizationAccessPolicyClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "AuthorizationAccessPolicyClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AuthorizationAccessPolicyClient.NewListByAuthorizationPager": + res.resp, res.err = a.dispatchNewListByAuthorizationPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AuthorizationAccessPolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -332,3 +348,9 @@ func (a *AuthorizationAccessPolicyServerTransport) dispatchNewListByAuthorizatio } return resp, nil } + +// set this to conditionally intercept incoming requests to AuthorizationAccessPolicyServerTransport +var authorizationAccessPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationloginlinks_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationloginlinks_server.go index f010709cf1a1..1bd2effb7090 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationloginlinks_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationloginlinks_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (a *AuthorizationLoginLinksServerTransport) Do(req *http.Request) (*http.Re return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AuthorizationLoginLinksClient.Post": - resp, err = a.dispatchPost(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AuthorizationLoginLinksServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if authorizationLoginLinksServerTransportInterceptor != nil { + res.resp, res.err, intercepted = authorizationLoginLinksServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AuthorizationLoginLinksClient.Post": + res.resp, res.err = a.dispatchPost(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AuthorizationLoginLinksServerTransport) dispatchPost(req *http.Request) (*http.Response, error) { @@ -113,3 +129,9 @@ func (a *AuthorizationLoginLinksServerTransport) dispatchPost(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to AuthorizationLoginLinksServerTransport +var authorizationLoginLinksServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationprovider_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationprovider_server.go index 3b797cde8ce7..b48e3fe65997 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationprovider_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationprovider_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -67,27 +64,46 @@ func (a *AuthorizationProviderServerTransport) Do(req *http.Request) (*http.Resp return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AuthorizationProviderClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "AuthorizationProviderClient.Delete": - resp, err = a.dispatchDelete(req) - case "AuthorizationProviderClient.Get": - resp, err = a.dispatchGet(req) - case "AuthorizationProviderClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AuthorizationProviderServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if authorizationProviderServerTransportInterceptor != nil { + res.resp, res.err, intercepted = authorizationProviderServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AuthorizationProviderClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "AuthorizationProviderClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "AuthorizationProviderClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AuthorizationProviderClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AuthorizationProviderServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -300,3 +316,9 @@ func (a *AuthorizationProviderServerTransport) dispatchNewListByServicePager(req } return resp, nil } + +// set this to conditionally intercept incoming requests to AuthorizationProviderServerTransport +var authorizationProviderServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationserver_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationserver_server.go index 302976f2ca0a..e0da759c786e 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationserver_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/authorizationserver_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -79,33 +76,52 @@ func (a *AuthorizationServerServerTransport) Do(req *http.Request) (*http.Respon return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AuthorizationServerClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "AuthorizationServerClient.Delete": - resp, err = a.dispatchDelete(req) - case "AuthorizationServerClient.Get": - resp, err = a.dispatchGet(req) - case "AuthorizationServerClient.GetEntityTag": - resp, err = a.dispatchGetEntityTag(req) - case "AuthorizationServerClient.NewListByServicePager": - resp, err = a.dispatchNewListByServicePager(req) - case "AuthorizationServerClient.ListSecrets": - resp, err = a.dispatchListSecrets(req) - case "AuthorizationServerClient.Update": - resp, err = a.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AuthorizationServerServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if authorizationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = authorizationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AuthorizationServerClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "AuthorizationServerClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "AuthorizationServerClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AuthorizationServerClient.GetEntityTag": + res.resp, res.err = a.dispatchGetEntityTag(req) + case "AuthorizationServerClient.NewListByServicePager": + res.resp, res.err = a.dispatchNewListByServicePager(req) + case "AuthorizationServerClient.ListSecrets": + res.resp, res.err = a.dispatchListSecrets(req) + case "AuthorizationServerClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AuthorizationServerServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -442,3 +458,9 @@ func (a *AuthorizationServerServerTransport) dispatchUpdate(req *http.Request) ( } return resp, nil } + +// set this to conditionally intercept incoming requests to AuthorizationServerServerTransport +var authorizationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/backend_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/backend_server.go index 31cd98660c47..217f5a218560 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/backend_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/backend_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "reflect" @@ -80,33 +77,52 @@ func (b *BackendServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return b.dispatchToMethodFake(req, method) +} - switch method { - case "BackendClient.CreateOrUpdate": - resp, err = b.dispatchCreateOrUpdate(req) - case "BackendClient.Delete": - resp, err = b.dispatchDelete(req) - case "BackendClient.Get": - resp, err = b.dispatchGet(req) - case "BackendClient.GetEntityTag": - resp, err = b.dispatchGetEntityTag(req) - case "BackendClient.NewListByServicePager": - resp, err = b.dispatchNewListByServicePager(req) - case "BackendClient.Reconnect": - resp, err = b.dispatchReconnect(req) - case "BackendClient.Update": - resp, err = b.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (b *BackendServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if backendServerTransportInterceptor != nil { + res.resp, res.err, intercepted = backendServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BackendClient.CreateOrUpdate": + res.resp, res.err = b.dispatchCreateOrUpdate(req) + case "BackendClient.Delete": + res.resp, res.err = b.dispatchDelete(req) + case "BackendClient.Get": + res.resp, res.err = b.dispatchGet(req) + case "BackendClient.GetEntityTag": + res.resp, res.err = b.dispatchGetEntityTag(req) + case "BackendClient.NewListByServicePager": + res.resp, res.err = b.dispatchNewListByServicePager(req) + case "BackendClient.Reconnect": + res.resp, res.err = b.dispatchReconnect(req) + case "BackendClient.Update": + res.resp, res.err = b.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (b *BackendServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -450,3 +466,9 @@ func (b *BackendServerTransport) dispatchUpdate(req *http.Request) (*http.Respon } return resp, nil } + +// set this to conditionally intercept incoming requests to BackendServerTransport +var backendServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/cache_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/cache_server.go index 98f793ea9a65..93c122b29455 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/cache_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/cache_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (c *CacheServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "CacheClient.CreateOrUpdate": - resp, err = c.dispatchCreateOrUpdate(req) - case "CacheClient.Delete": - resp, err = c.dispatchDelete(req) - case "CacheClient.Get": - resp, err = c.dispatchGet(req) - case "CacheClient.GetEntityTag": - resp, err = c.dispatchGetEntityTag(req) - case "CacheClient.NewListByServicePager": - resp, err = c.dispatchNewListByServicePager(req) - case "CacheClient.Update": - resp, err = c.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *CacheServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if cacheServerTransportInterceptor != nil { + res.resp, res.err, intercepted = cacheServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "CacheClient.CreateOrUpdate": + res.resp, res.err = c.dispatchCreateOrUpdate(req) + case "CacheClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "CacheClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "CacheClient.GetEntityTag": + res.resp, res.err = c.dispatchGetEntityTag(req) + case "CacheClient.NewListByServicePager": + res.resp, res.err = c.dispatchNewListByServicePager(req) + case "CacheClient.Update": + res.resp, res.err = c.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (c *CacheServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -390,3 +406,9 @@ func (c *CacheServerTransport) dispatchUpdate(req *http.Request) (*http.Response } return resp, nil } + +// set this to conditionally intercept incoming requests to CacheServerTransport +var cacheServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/certificate_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/certificate_server.go index 936def55e16d..c7b165cb7f73 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/certificate_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/certificate_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (c *CertificateServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "CertificateClient.CreateOrUpdate": - resp, err = c.dispatchCreateOrUpdate(req) - case "CertificateClient.Delete": - resp, err = c.dispatchDelete(req) - case "CertificateClient.Get": - resp, err = c.dispatchGet(req) - case "CertificateClient.GetEntityTag": - resp, err = c.dispatchGetEntityTag(req) - case "CertificateClient.NewListByServicePager": - resp, err = c.dispatchNewListByServicePager(req) - case "CertificateClient.RefreshSecret": - resp, err = c.dispatchRefreshSecret(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *CertificateServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if certificateServerTransportInterceptor != nil { + res.resp, res.err, intercepted = certificateServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "CertificateClient.CreateOrUpdate": + res.resp, res.err = c.dispatchCreateOrUpdate(req) + case "CertificateClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "CertificateClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "CertificateClient.GetEntityTag": + res.resp, res.err = c.dispatchGetEntityTag(req) + case "CertificateClient.NewListByServicePager": + res.resp, res.err = c.dispatchNewListByServicePager(req) + case "CertificateClient.RefreshSecret": + res.resp, res.err = c.dispatchRefreshSecret(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (c *CertificateServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -401,3 +417,9 @@ func (c *CertificateServerTransport) dispatchRefreshSecret(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to CertificateServerTransport +var certificateServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/contentitem_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/contentitem_server.go index 3b2a4c7e4b9d..2cb234d6cb65 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/contentitem_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/contentitem_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -70,29 +67,48 @@ func (c *ContentItemServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "ContentItemClient.CreateOrUpdate": - resp, err = c.dispatchCreateOrUpdate(req) - case "ContentItemClient.Delete": - resp, err = c.dispatchDelete(req) - case "ContentItemClient.Get": - resp, err = c.dispatchGet(req) - case "ContentItemClient.GetEntityTag": - resp, err = c.dispatchGetEntityTag(req) - case "ContentItemClient.NewListByServicePager": - resp, err = c.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *ContentItemServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if contentItemServerTransportInterceptor != nil { + res.resp, res.err, intercepted = contentItemServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ContentItemClient.CreateOrUpdate": + res.resp, res.err = c.dispatchCreateOrUpdate(req) + case "ContentItemClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "ContentItemClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "ContentItemClient.GetEntityTag": + res.resp, res.err = c.dispatchGetEntityTag(req) + case "ContentItemClient.NewListByServicePager": + res.resp, res.err = c.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (c *ContentItemServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -323,3 +339,9 @@ func (c *ContentItemServerTransport) dispatchNewListByServicePager(req *http.Req } return resp, nil } + +// set this to conditionally intercept incoming requests to ContentItemServerTransport +var contentItemServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/contenttype_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/contenttype_server.go index 988124b99dee..e98a0d963aa1 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/contenttype_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/contenttype_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -66,27 +63,46 @@ func (c *ContentTypeServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "ContentTypeClient.CreateOrUpdate": - resp, err = c.dispatchCreateOrUpdate(req) - case "ContentTypeClient.Delete": - resp, err = c.dispatchDelete(req) - case "ContentTypeClient.Get": - resp, err = c.dispatchGet(req) - case "ContentTypeClient.NewListByServicePager": - resp, err = c.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *ContentTypeServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if contentTypeServerTransportInterceptor != nil { + res.resp, res.err, intercepted = contentTypeServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ContentTypeClient.CreateOrUpdate": + res.resp, res.err = c.dispatchCreateOrUpdate(req) + case "ContentTypeClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "ContentTypeClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "ContentTypeClient.NewListByServicePager": + res.resp, res.err = c.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (c *ContentTypeServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -257,3 +273,9 @@ func (c *ContentTypeServerTransport) dispatchNewListByServicePager(req *http.Req } return resp, nil } + +// set this to conditionally intercept incoming requests to ContentTypeServerTransport +var contentTypeServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/delegationsettings_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/delegationsettings_server.go index 729cfbc6297a..3ff73f026a8e 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/delegationsettings_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/delegationsettings_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -65,29 +62,48 @@ func (d *DelegationSettingsServerTransport) Do(req *http.Request) (*http.Respons return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return d.dispatchToMethodFake(req, method) +} - switch method { - case "DelegationSettingsClient.CreateOrUpdate": - resp, err = d.dispatchCreateOrUpdate(req) - case "DelegationSettingsClient.Get": - resp, err = d.dispatchGet(req) - case "DelegationSettingsClient.GetEntityTag": - resp, err = d.dispatchGetEntityTag(req) - case "DelegationSettingsClient.ListSecrets": - resp, err = d.dispatchListSecrets(req) - case "DelegationSettingsClient.Update": - resp, err = d.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (d *DelegationSettingsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if delegationSettingsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = delegationSettingsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DelegationSettingsClient.CreateOrUpdate": + res.resp, res.err = d.dispatchCreateOrUpdate(req) + case "DelegationSettingsClient.Get": + res.resp, res.err = d.dispatchGet(req) + case "DelegationSettingsClient.GetEntityTag": + res.resp, res.err = d.dispatchGetEntityTag(req) + case "DelegationSettingsClient.ListSecrets": + res.resp, res.err = d.dispatchListSecrets(req) + case "DelegationSettingsClient.Update": + res.resp, res.err = d.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (d *DelegationSettingsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -275,3 +291,9 @@ func (d *DelegationSettingsServerTransport) dispatchUpdate(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to DelegationSettingsServerTransport +var delegationSettingsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/deletedservices_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/deletedservices_server.go index 84879a9b3f5e..718722774350 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/deletedservices_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/deletedservices_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -64,25 +61,44 @@ func (d *DeletedServicesServerTransport) Do(req *http.Request) (*http.Response, return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return d.dispatchToMethodFake(req, method) +} - switch method { - case "DeletedServicesClient.GetByName": - resp, err = d.dispatchGetByName(req) - case "DeletedServicesClient.NewListBySubscriptionPager": - resp, err = d.dispatchNewListBySubscriptionPager(req) - case "DeletedServicesClient.BeginPurge": - resp, err = d.dispatchBeginPurge(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (d *DeletedServicesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if deletedServicesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = deletedServicesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DeletedServicesClient.GetByName": + res.resp, res.err = d.dispatchGetByName(req) + case "DeletedServicesClient.NewListBySubscriptionPager": + res.resp, res.err = d.dispatchNewListBySubscriptionPager(req) + case "DeletedServicesClient.BeginPurge": + res.resp, res.err = d.dispatchBeginPurge(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (d *DeletedServicesServerTransport) dispatchGetByName(req *http.Request) (*http.Response, error) { @@ -194,3 +210,9 @@ func (d *DeletedServicesServerTransport) dispatchBeginPurge(req *http.Request) ( return resp, nil } + +// set this to conditionally intercept incoming requests to DeletedServicesServerTransport +var deletedServicesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/diagnostic_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/diagnostic_server.go index 9d0ca7019916..309d8364a8b2 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/diagnostic_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/diagnostic_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (d *DiagnosticServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return d.dispatchToMethodFake(req, method) +} - switch method { - case "DiagnosticClient.CreateOrUpdate": - resp, err = d.dispatchCreateOrUpdate(req) - case "DiagnosticClient.Delete": - resp, err = d.dispatchDelete(req) - case "DiagnosticClient.Get": - resp, err = d.dispatchGet(req) - case "DiagnosticClient.GetEntityTag": - resp, err = d.dispatchGetEntityTag(req) - case "DiagnosticClient.NewListByServicePager": - resp, err = d.dispatchNewListByServicePager(req) - case "DiagnosticClient.Update": - resp, err = d.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (d *DiagnosticServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if diagnosticServerTransportInterceptor != nil { + res.resp, res.err, intercepted = diagnosticServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DiagnosticClient.CreateOrUpdate": + res.resp, res.err = d.dispatchCreateOrUpdate(req) + case "DiagnosticClient.Delete": + res.resp, res.err = d.dispatchDelete(req) + case "DiagnosticClient.Get": + res.resp, res.err = d.dispatchGet(req) + case "DiagnosticClient.GetEntityTag": + res.resp, res.err = d.dispatchGetEntityTag(req) + case "DiagnosticClient.NewListByServicePager": + res.resp, res.err = d.dispatchNewListByServicePager(req) + case "DiagnosticClient.Update": + res.resp, res.err = d.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (d *DiagnosticServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -396,3 +412,9 @@ func (d *DiagnosticServerTransport) dispatchUpdate(req *http.Request) (*http.Res } return resp, nil } + +// set this to conditionally intercept incoming requests to DiagnosticServerTransport +var diagnosticServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/documentation_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/documentation_server.go index 0d99b02a5a6c..f43c83c1f96d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/documentation_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/documentation_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (d *DocumentationServerTransport) Do(req *http.Request) (*http.Response, er return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return d.dispatchToMethodFake(req, method) +} - switch method { - case "DocumentationClient.CreateOrUpdate": - resp, err = d.dispatchCreateOrUpdate(req) - case "DocumentationClient.Delete": - resp, err = d.dispatchDelete(req) - case "DocumentationClient.Get": - resp, err = d.dispatchGet(req) - case "DocumentationClient.GetEntityTag": - resp, err = d.dispatchGetEntityTag(req) - case "DocumentationClient.NewListByServicePager": - resp, err = d.dispatchNewListByServicePager(req) - case "DocumentationClient.Update": - resp, err = d.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (d *DocumentationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if documentationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = documentationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DocumentationClient.CreateOrUpdate": + res.resp, res.err = d.dispatchCreateOrUpdate(req) + case "DocumentationClient.Delete": + res.resp, res.err = d.dispatchDelete(req) + case "DocumentationClient.Get": + res.resp, res.err = d.dispatchGet(req) + case "DocumentationClient.GetEntityTag": + res.resp, res.err = d.dispatchGetEntityTag(req) + case "DocumentationClient.NewListByServicePager": + res.resp, res.err = d.dispatchNewListByServicePager(req) + case "DocumentationClient.Update": + res.resp, res.err = d.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (d *DocumentationServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -396,3 +412,9 @@ func (d *DocumentationServerTransport) dispatchUpdate(req *http.Request) (*http. } return resp, nil } + +// set this to conditionally intercept incoming requests to DocumentationServerTransport +var documentationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/emailtemplate_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/emailtemplate_server.go index eb651f8d7a4b..b96f5b4e9b3a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/emailtemplate_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/emailtemplate_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (e *EmailTemplateServerTransport) Do(req *http.Request) (*http.Response, er return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return e.dispatchToMethodFake(req, method) +} - switch method { - case "EmailTemplateClient.CreateOrUpdate": - resp, err = e.dispatchCreateOrUpdate(req) - case "EmailTemplateClient.Delete": - resp, err = e.dispatchDelete(req) - case "EmailTemplateClient.Get": - resp, err = e.dispatchGet(req) - case "EmailTemplateClient.GetEntityTag": - resp, err = e.dispatchGetEntityTag(req) - case "EmailTemplateClient.NewListByServicePager": - resp, err = e.dispatchNewListByServicePager(req) - case "EmailTemplateClient.Update": - resp, err = e.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (e *EmailTemplateServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if emailTemplateServerTransportInterceptor != nil { + res.resp, res.err, intercepted = emailTemplateServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "EmailTemplateClient.CreateOrUpdate": + res.resp, res.err = e.dispatchCreateOrUpdate(req) + case "EmailTemplateClient.Delete": + res.resp, res.err = e.dispatchDelete(req) + case "EmailTemplateClient.Get": + res.resp, res.err = e.dispatchGet(req) + case "EmailTemplateClient.GetEntityTag": + res.resp, res.err = e.dispatchGetEntityTag(req) + case "EmailTemplateClient.NewListByServicePager": + res.resp, res.err = e.dispatchNewListByServicePager(req) + case "EmailTemplateClient.Update": + res.resp, res.err = e.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (e *EmailTemplateServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -423,3 +439,9 @@ func (e *EmailTemplateServerTransport) dispatchUpdate(req *http.Request) (*http. } return resp, nil } + +// set this to conditionally intercept incoming requests to EmailTemplateServerTransport +var emailTemplateServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/gateway_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gateway_server.go index 254bcdb1d2fa..e72a835fe070 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/gateway_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gateway_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -45,14 +42,26 @@ type GatewayServer struct { // HTTP status codes to indicate success: http.StatusOK GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *armapimanagement.GatewayClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.GatewayClientGetEntityTagResponse], errResp azfake.ErrorResponder) + // InvalidateDebugCredentials is the fake for method GatewayClient.InvalidateDebugCredentials + // HTTP status codes to indicate success: http.StatusNoContent + InvalidateDebugCredentials func(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *armapimanagement.GatewayClientInvalidateDebugCredentialsOptions) (resp azfake.Responder[armapimanagement.GatewayClientInvalidateDebugCredentialsResponse], errResp azfake.ErrorResponder) + // NewListByServicePager is the fake for method GatewayClient.NewListByServicePager // HTTP status codes to indicate success: http.StatusOK NewListByServicePager func(resourceGroupName string, serviceName string, options *armapimanagement.GatewayClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.GatewayClientListByServiceResponse]) + // ListDebugCredentials is the fake for method GatewayClient.ListDebugCredentials + // HTTP status codes to indicate success: http.StatusOK + ListDebugCredentials func(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters armapimanagement.GatewayListDebugCredentialsContract, options *armapimanagement.GatewayClientListDebugCredentialsOptions) (resp azfake.Responder[armapimanagement.GatewayClientListDebugCredentialsResponse], errResp azfake.ErrorResponder) + // ListKeys is the fake for method GatewayClient.ListKeys // HTTP status codes to indicate success: http.StatusOK ListKeys func(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *armapimanagement.GatewayClientListKeysOptions) (resp azfake.Responder[armapimanagement.GatewayClientListKeysResponse], errResp azfake.ErrorResponder) + // ListTrace is the fake for method GatewayClient.ListTrace + // HTTP status codes to indicate success: http.StatusOK + ListTrace func(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters armapimanagement.GatewayListTraceContract, options *armapimanagement.GatewayClientListTraceOptions) (resp azfake.Responder[armapimanagement.GatewayClientListTraceResponse], errResp azfake.ErrorResponder) + // RegenerateKey is the fake for method GatewayClient.RegenerateKey // HTTP status codes to indicate success: http.StatusNoContent RegenerateKey func(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters armapimanagement.GatewayKeyRegenerationRequestContract, options *armapimanagement.GatewayClientRegenerateKeyOptions) (resp azfake.Responder[armapimanagement.GatewayClientRegenerateKeyResponse], errResp azfake.ErrorResponder) @@ -87,37 +96,62 @@ func (g *GatewayServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GatewayClient.CreateOrUpdate": - resp, err = g.dispatchCreateOrUpdate(req) - case "GatewayClient.Delete": - resp, err = g.dispatchDelete(req) - case "GatewayClient.GenerateToken": - resp, err = g.dispatchGenerateToken(req) - case "GatewayClient.Get": - resp, err = g.dispatchGet(req) - case "GatewayClient.GetEntityTag": - resp, err = g.dispatchGetEntityTag(req) - case "GatewayClient.NewListByServicePager": - resp, err = g.dispatchNewListByServicePager(req) - case "GatewayClient.ListKeys": - resp, err = g.dispatchListKeys(req) - case "GatewayClient.RegenerateKey": - resp, err = g.dispatchRegenerateKey(req) - case "GatewayClient.Update": - resp, err = g.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GatewayServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if gatewayServerTransportInterceptor != nil { + res.resp, res.err, intercepted = gatewayServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GatewayClient.CreateOrUpdate": + res.resp, res.err = g.dispatchCreateOrUpdate(req) + case "GatewayClient.Delete": + res.resp, res.err = g.dispatchDelete(req) + case "GatewayClient.GenerateToken": + res.resp, res.err = g.dispatchGenerateToken(req) + case "GatewayClient.Get": + res.resp, res.err = g.dispatchGet(req) + case "GatewayClient.GetEntityTag": + res.resp, res.err = g.dispatchGetEntityTag(req) + case "GatewayClient.InvalidateDebugCredentials": + res.resp, res.err = g.dispatchInvalidateDebugCredentials(req) + case "GatewayClient.NewListByServicePager": + res.resp, res.err = g.dispatchNewListByServicePager(req) + case "GatewayClient.ListDebugCredentials": + res.resp, res.err = g.dispatchListDebugCredentials(req) + case "GatewayClient.ListKeys": + res.resp, res.err = g.dispatchListKeys(req) + case "GatewayClient.ListTrace": + res.resp, res.err = g.dispatchListTrace(req) + case "GatewayClient.RegenerateKey": + res.resp, res.err = g.dispatchRegenerateKey(req) + case "GatewayClient.Update": + res.resp, res.err = g.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GatewayServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -329,6 +363,43 @@ func (g *GatewayServerTransport) dispatchGetEntityTag(req *http.Request) (*http. return resp, nil } +func (g *GatewayServerTransport) dispatchInvalidateDebugCredentials(req *http.Request) (*http.Response, error) { + if g.srv.InvalidateDebugCredentials == nil { + return nil, &nonRetriableError{errors.New("fake for method InvalidateDebugCredentials not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invalidateDebugCredentials` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + gatewayIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayId")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.InvalidateDebugCredentials(req.Context(), resourceGroupNameParam, serviceNameParam, gatewayIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + func (g *GatewayServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { if g.srv.NewListByServicePager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} @@ -412,6 +483,47 @@ func (g *GatewayServerTransport) dispatchNewListByServicePager(req *http.Request return resp, nil } +func (g *GatewayServerTransport) dispatchListDebugCredentials(req *http.Request) (*http.Response, error) { + if g.srv.ListDebugCredentials == nil { + return nil, &nonRetriableError{errors.New("fake for method ListDebugCredentials not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listDebugCredentials` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.GatewayListDebugCredentialsContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + gatewayIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayId")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.ListDebugCredentials(req.Context(), resourceGroupNameParam, serviceNameParam, gatewayIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GatewayDebugCredentialsContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (g *GatewayServerTransport) dispatchListKeys(req *http.Request) (*http.Response, error) { if g.srv.ListKeys == nil { return nil, &nonRetriableError{errors.New("fake for method ListKeys not implemented")} @@ -452,6 +564,47 @@ func (g *GatewayServerTransport) dispatchListKeys(req *http.Request) (*http.Resp return resp, nil } +func (g *GatewayServerTransport) dispatchListTrace(req *http.Request) (*http.Response, error) { + if g.srv.ListTrace == nil { + return nil, &nonRetriableError{errors.New("fake for method ListTrace not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listTrace` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.GatewayListTraceContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + gatewayIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayId")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.ListTrace(req.Context(), resourceGroupNameParam, serviceNameParam, gatewayIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Value, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (g *GatewayServerTransport) dispatchRegenerateKey(req *http.Request) (*http.Response, error) { if g.srv.RegenerateKey == nil { return nil, &nonRetriableError{errors.New("fake for method RegenerateKey not implemented")} @@ -536,3 +689,9 @@ func (g *GatewayServerTransport) dispatchUpdate(req *http.Request) (*http.Respon } return resp, nil } + +// set this to conditionally intercept incoming requests to GatewayServerTransport +var gatewayServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayapi_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayapi_server.go index 9fdc6841a0ad..09eb88a48c89 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayapi_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayapi_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "reflect" @@ -68,27 +65,46 @@ func (g *GatewayAPIServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GatewayAPIClient.CreateOrUpdate": - resp, err = g.dispatchCreateOrUpdate(req) - case "GatewayAPIClient.Delete": - resp, err = g.dispatchDelete(req) - case "GatewayAPIClient.GetEntityTag": - resp, err = g.dispatchGetEntityTag(req) - case "GatewayAPIClient.NewListByServicePager": - resp, err = g.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GatewayAPIServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if gatewayApiServerTransportInterceptor != nil { + res.resp, res.err, intercepted = gatewayApiServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GatewayAPIClient.CreateOrUpdate": + res.resp, res.err = g.dispatchCreateOrUpdate(req) + case "GatewayAPIClient.Delete": + res.resp, res.err = g.dispatchDelete(req) + case "GatewayAPIClient.GetEntityTag": + res.resp, res.err = g.dispatchGetEntityTag(req) + case "GatewayAPIClient.NewListByServicePager": + res.resp, res.err = g.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GatewayAPIServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -313,3 +329,9 @@ func (g *GatewayAPIServerTransport) dispatchNewListByServicePager(req *http.Requ } return resp, nil } + +// set this to conditionally intercept incoming requests to GatewayAPIServerTransport +var gatewayApiServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewaycertificateauthority_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewaycertificateauthority_server.go index 8b275dcbb503..60ae8f1a7990 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewaycertificateauthority_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewaycertificateauthority_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -71,29 +68,48 @@ func (g *GatewayCertificateAuthorityServerTransport) Do(req *http.Request) (*htt return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GatewayCertificateAuthorityClient.CreateOrUpdate": - resp, err = g.dispatchCreateOrUpdate(req) - case "GatewayCertificateAuthorityClient.Delete": - resp, err = g.dispatchDelete(req) - case "GatewayCertificateAuthorityClient.Get": - resp, err = g.dispatchGet(req) - case "GatewayCertificateAuthorityClient.GetEntityTag": - resp, err = g.dispatchGetEntityTag(req) - case "GatewayCertificateAuthorityClient.NewListByServicePager": - resp, err = g.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GatewayCertificateAuthorityServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if gatewayCertificateAuthorityServerTransportInterceptor != nil { + res.resp, res.err, intercepted = gatewayCertificateAuthorityServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GatewayCertificateAuthorityClient.CreateOrUpdate": + res.resp, res.err = g.dispatchCreateOrUpdate(req) + case "GatewayCertificateAuthorityClient.Delete": + res.resp, res.err = g.dispatchDelete(req) + case "GatewayCertificateAuthorityClient.Get": + res.resp, res.err = g.dispatchGet(req) + case "GatewayCertificateAuthorityClient.GetEntityTag": + res.resp, res.err = g.dispatchGetEntityTag(req) + case "GatewayCertificateAuthorityClient.NewListByServicePager": + res.resp, res.err = g.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GatewayCertificateAuthorityServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -366,3 +382,9 @@ func (g *GatewayCertificateAuthorityServerTransport) dispatchNewListByServicePag } return resp, nil } + +// set this to conditionally intercept incoming requests to GatewayCertificateAuthorityServerTransport +var gatewayCertificateAuthorityServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayhostnameconfiguration_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayhostnameconfiguration_server.go index 73a753f6371d..990e6f41c169 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayhostnameconfiguration_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayhostnameconfiguration_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -71,29 +68,48 @@ func (g *GatewayHostnameConfigurationServerTransport) Do(req *http.Request) (*ht return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GatewayHostnameConfigurationClient.CreateOrUpdate": - resp, err = g.dispatchCreateOrUpdate(req) - case "GatewayHostnameConfigurationClient.Delete": - resp, err = g.dispatchDelete(req) - case "GatewayHostnameConfigurationClient.Get": - resp, err = g.dispatchGet(req) - case "GatewayHostnameConfigurationClient.GetEntityTag": - resp, err = g.dispatchGetEntityTag(req) - case "GatewayHostnameConfigurationClient.NewListByServicePager": - resp, err = g.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GatewayHostnameConfigurationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if gatewayHostnameConfigurationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = gatewayHostnameConfigurationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GatewayHostnameConfigurationClient.CreateOrUpdate": + res.resp, res.err = g.dispatchCreateOrUpdate(req) + case "GatewayHostnameConfigurationClient.Delete": + res.resp, res.err = g.dispatchDelete(req) + case "GatewayHostnameConfigurationClient.Get": + res.resp, res.err = g.dispatchGet(req) + case "GatewayHostnameConfigurationClient.GetEntityTag": + res.resp, res.err = g.dispatchGetEntityTag(req) + case "GatewayHostnameConfigurationClient.NewListByServicePager": + res.resp, res.err = g.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GatewayHostnameConfigurationServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -366,3 +382,9 @@ func (g *GatewayHostnameConfigurationServerTransport) dispatchNewListByServicePa } return resp, nil } + +// set this to conditionally intercept incoming requests to GatewayHostnameConfigurationServerTransport +var gatewayHostnameConfigurationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayskus_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayskus_server.go new file mode 100644 index 000000000000..f1e811d09bdc --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/gatewayskus_server.go @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// GatewaySKUsServer is a fake server for instances of the armapimanagement.GatewaySKUsClient type. +type GatewaySKUsServer struct { + // NewListAvailableSKUsPager is the fake for method GatewaySKUsClient.NewListAvailableSKUsPager + // HTTP status codes to indicate success: http.StatusOK + NewListAvailableSKUsPager func(resourceGroupName string, gatewayName string, options *armapimanagement.GatewaySKUsClientListAvailableSKUsOptions) (resp azfake.PagerResponder[armapimanagement.GatewaySKUsClientListAvailableSKUsResponse]) +} + +// NewGatewaySKUsServerTransport creates a new instance of GatewaySKUsServerTransport with the provided implementation. +// The returned GatewaySKUsServerTransport instance is connected to an instance of armapimanagement.GatewaySKUsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewGatewaySKUsServerTransport(srv *GatewaySKUsServer) *GatewaySKUsServerTransport { + return &GatewaySKUsServerTransport{ + srv: srv, + newListAvailableSKUsPager: newTracker[azfake.PagerResponder[armapimanagement.GatewaySKUsClientListAvailableSKUsResponse]](), + } +} + +// GatewaySKUsServerTransport connects instances of armapimanagement.GatewaySKUsClient to instances of GatewaySKUsServer. +// Don't use this type directly, use NewGatewaySKUsServerTransport instead. +type GatewaySKUsServerTransport struct { + srv *GatewaySKUsServer + newListAvailableSKUsPager *tracker[azfake.PagerResponder[armapimanagement.GatewaySKUsClientListAvailableSKUsResponse]] +} + +// Do implements the policy.Transporter interface for GatewaySKUsServerTransport. +func (g *GatewaySKUsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return g.dispatchToMethodFake(req, method) +} + +func (g *GatewaySKUsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if gatewaySkUsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = gatewaySkUsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GatewaySKUsClient.NewListAvailableSKUsPager": + res.resp, res.err = g.dispatchNewListAvailableSKUsPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (g *GatewaySKUsServerTransport) dispatchNewListAvailableSKUsPager(req *http.Request) (*http.Response, error) { + if g.srv.NewListAvailableSKUsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListAvailableSKUsPager not implemented")} + } + newListAvailableSKUsPager := g.newListAvailableSKUsPager.get(req) + if newListAvailableSKUsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/gateways/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/skus` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + gatewayNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("gatewayName")]) + if err != nil { + return nil, err + } + resp := g.srv.NewListAvailableSKUsPager(resourceGroupNameParam, gatewayNameParam, nil) + newListAvailableSKUsPager = &resp + g.newListAvailableSKUsPager.add(req, newListAvailableSKUsPager) + server.PagerResponderInjectNextLinks(newListAvailableSKUsPager, req, func(page *armapimanagement.GatewaySKUsClientListAvailableSKUsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListAvailableSKUsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + g.newListAvailableSKUsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListAvailableSKUsPager) { + g.newListAvailableSKUsPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to GatewaySKUsServerTransport +var gatewaySkUsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/globalschema_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/globalschema_server.go index 6a5db06643af..90d1237fac33 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/globalschema_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/globalschema_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -26,7 +23,7 @@ import ( // GlobalSchemaServer is a fake server for instances of the armapimanagement.GlobalSchemaClient type. type GlobalSchemaServer struct { // BeginCreateOrUpdate is the fake for method GlobalSchemaClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, schemaID string, parameters armapimanagement.GlobalSchemaContract, options *armapimanagement.GlobalSchemaClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.GlobalSchemaClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method GlobalSchemaClient.Delete @@ -73,29 +70,48 @@ func (g *GlobalSchemaServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GlobalSchemaClient.BeginCreateOrUpdate": - resp, err = g.dispatchBeginCreateOrUpdate(req) - case "GlobalSchemaClient.Delete": - resp, err = g.dispatchDelete(req) - case "GlobalSchemaClient.Get": - resp, err = g.dispatchGet(req) - case "GlobalSchemaClient.GetEntityTag": - resp, err = g.dispatchGetEntityTag(req) - case "GlobalSchemaClient.NewListByServicePager": - resp, err = g.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GlobalSchemaServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if globalSchemaServerTransportInterceptor != nil { + res.resp, res.err, intercepted = globalSchemaServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GlobalSchemaClient.BeginCreateOrUpdate": + res.resp, res.err = g.dispatchBeginCreateOrUpdate(req) + case "GlobalSchemaClient.Delete": + res.resp, res.err = g.dispatchDelete(req) + case "GlobalSchemaClient.Get": + res.resp, res.err = g.dispatchGet(req) + case "GlobalSchemaClient.GetEntityTag": + res.resp, res.err = g.dispatchGetEntityTag(req) + case "GlobalSchemaClient.NewListByServicePager": + res.resp, res.err = g.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GlobalSchemaServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -146,9 +162,9 @@ func (g *GlobalSchemaServerTransport) dispatchBeginCreateOrUpdate(req *http.Requ return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { g.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { g.beginCreateOrUpdate.remove(req) @@ -356,3 +372,9 @@ func (g *GlobalSchemaServerTransport) dispatchNewListByServicePager(req *http.Re } return resp, nil } + +// set this to conditionally intercept incoming requests to GlobalSchemaServerTransport +var globalSchemaServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/graphqlapiresolver_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/graphqlapiresolver_server.go index cfaf092e1d50..4992176fc8c3 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/graphqlapiresolver_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/graphqlapiresolver_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (g *GraphQLAPIResolverServerTransport) Do(req *http.Request) (*http.Respons return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GraphQLAPIResolverClient.CreateOrUpdate": - resp, err = g.dispatchCreateOrUpdate(req) - case "GraphQLAPIResolverClient.Delete": - resp, err = g.dispatchDelete(req) - case "GraphQLAPIResolverClient.Get": - resp, err = g.dispatchGet(req) - case "GraphQLAPIResolverClient.GetEntityTag": - resp, err = g.dispatchGetEntityTag(req) - case "GraphQLAPIResolverClient.NewListByAPIPager": - resp, err = g.dispatchNewListByAPIPager(req) - case "GraphQLAPIResolverClient.Update": - resp, err = g.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GraphQLAPIResolverServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if graphQlapiResolverServerTransportInterceptor != nil { + res.resp, res.err, intercepted = graphQlapiResolverServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GraphQLAPIResolverClient.CreateOrUpdate": + res.resp, res.err = g.dispatchCreateOrUpdate(req) + case "GraphQLAPIResolverClient.Delete": + res.resp, res.err = g.dispatchDelete(req) + case "GraphQLAPIResolverClient.Get": + res.resp, res.err = g.dispatchGet(req) + case "GraphQLAPIResolverClient.GetEntityTag": + res.resp, res.err = g.dispatchGetEntityTag(req) + case "GraphQLAPIResolverClient.NewListByAPIPager": + res.resp, res.err = g.dispatchNewListByAPIPager(req) + case "GraphQLAPIResolverClient.Update": + res.resp, res.err = g.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GraphQLAPIResolverServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -420,3 +436,9 @@ func (g *GraphQLAPIResolverServerTransport) dispatchUpdate(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to GraphQLAPIResolverServerTransport +var graphQlapiResolverServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/graphqlapiresolverpolicy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/graphqlapiresolverpolicy_server.go index 809ea1b85012..1fea9e57cd24 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/graphqlapiresolverpolicy_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/graphqlapiresolverpolicy_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -70,29 +67,48 @@ func (g *GraphQLAPIResolverPolicyServerTransport) Do(req *http.Request) (*http.R return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GraphQLAPIResolverPolicyClient.CreateOrUpdate": - resp, err = g.dispatchCreateOrUpdate(req) - case "GraphQLAPIResolverPolicyClient.Delete": - resp, err = g.dispatchDelete(req) - case "GraphQLAPIResolverPolicyClient.Get": - resp, err = g.dispatchGet(req) - case "GraphQLAPIResolverPolicyClient.GetEntityTag": - resp, err = g.dispatchGetEntityTag(req) - case "GraphQLAPIResolverPolicyClient.NewListByResolverPager": - resp, err = g.dispatchNewListByResolverPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GraphQLAPIResolverPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if graphQlapiResolverPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = graphQlapiResolverPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GraphQLAPIResolverPolicyClient.CreateOrUpdate": + res.resp, res.err = g.dispatchCreateOrUpdate(req) + case "GraphQLAPIResolverPolicyClient.Delete": + res.resp, res.err = g.dispatchDelete(req) + case "GraphQLAPIResolverPolicyClient.Get": + res.resp, res.err = g.dispatchGet(req) + case "GraphQLAPIResolverPolicyClient.GetEntityTag": + res.resp, res.err = g.dispatchGetEntityTag(req) + case "GraphQLAPIResolverPolicyClient.NewListByResolverPager": + res.resp, res.err = g.dispatchNewListByResolverPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GraphQLAPIResolverPolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -379,3 +395,9 @@ func (g *GraphQLAPIResolverPolicyServerTransport) dispatchNewListByResolverPager } return resp, nil } + +// set this to conditionally intercept incoming requests to GraphQLAPIResolverPolicyServerTransport +var graphQlapiResolverPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/group_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/group_server.go index b5595d3098d8..258771dce017 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/group_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/group_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (g *GroupServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GroupClient.CreateOrUpdate": - resp, err = g.dispatchCreateOrUpdate(req) - case "GroupClient.Delete": - resp, err = g.dispatchDelete(req) - case "GroupClient.Get": - resp, err = g.dispatchGet(req) - case "GroupClient.GetEntityTag": - resp, err = g.dispatchGetEntityTag(req) - case "GroupClient.NewListByServicePager": - resp, err = g.dispatchNewListByServicePager(req) - case "GroupClient.Update": - resp, err = g.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GroupServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if groupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = groupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GroupClient.CreateOrUpdate": + res.resp, res.err = g.dispatchCreateOrUpdate(req) + case "GroupClient.Delete": + res.resp, res.err = g.dispatchDelete(req) + case "GroupClient.Get": + res.resp, res.err = g.dispatchGet(req) + case "GroupClient.GetEntityTag": + res.resp, res.err = g.dispatchGetEntityTag(req) + case "GroupClient.NewListByServicePager": + res.resp, res.err = g.dispatchNewListByServicePager(req) + case "GroupClient.Update": + res.resp, res.err = g.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GroupServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -396,3 +412,9 @@ func (g *GroupServerTransport) dispatchUpdate(req *http.Request) (*http.Response } return resp, nil } + +// set this to conditionally intercept incoming requests to GroupServerTransport +var groupServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/groupuser_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/groupuser_server.go index f947ae8bfb44..b742ae758597 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/groupuser_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/groupuser_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -67,27 +64,46 @@ func (g *GroupUserServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GroupUserClient.CheckEntityExists": - resp, err = g.dispatchCheckEntityExists(req) - case "GroupUserClient.Create": - resp, err = g.dispatchCreate(req) - case "GroupUserClient.Delete": - resp, err = g.dispatchDelete(req) - case "GroupUserClient.NewListPager": - resp, err = g.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GroupUserServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if groupUserServerTransportInterceptor != nil { + res.resp, res.err, intercepted = groupUserServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GroupUserClient.CheckEntityExists": + res.resp, res.err = g.dispatchCheckEntityExists(req) + case "GroupUserClient.Create": + res.resp, res.err = g.dispatchCreate(req) + case "GroupUserClient.Delete": + res.resp, res.err = g.dispatchDelete(req) + case "GroupUserClient.NewListPager": + res.resp, res.err = g.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GroupUserServerTransport) dispatchCheckEntityExists(req *http.Request) (*http.Response, error) { @@ -299,3 +315,9 @@ func (g *GroupUserServerTransport) dispatchNewListPager(req *http.Request) (*htt } return resp, nil } + +// set this to conditionally intercept incoming requests to GroupUserServerTransport +var groupUserServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/identityprovider_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/identityprovider_server.go index fbd0f04595fc..30f261eebb7d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/identityprovider_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/identityprovider_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -78,33 +75,52 @@ func (i *IdentityProviderServerTransport) Do(req *http.Request) (*http.Response, return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return i.dispatchToMethodFake(req, method) +} - switch method { - case "IdentityProviderClient.CreateOrUpdate": - resp, err = i.dispatchCreateOrUpdate(req) - case "IdentityProviderClient.Delete": - resp, err = i.dispatchDelete(req) - case "IdentityProviderClient.Get": - resp, err = i.dispatchGet(req) - case "IdentityProviderClient.GetEntityTag": - resp, err = i.dispatchGetEntityTag(req) - case "IdentityProviderClient.NewListByServicePager": - resp, err = i.dispatchNewListByServicePager(req) - case "IdentityProviderClient.ListSecrets": - resp, err = i.dispatchListSecrets(req) - case "IdentityProviderClient.Update": - resp, err = i.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (i *IdentityProviderServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if identityProviderServerTransportInterceptor != nil { + res.resp, res.err, intercepted = identityProviderServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "IdentityProviderClient.CreateOrUpdate": + res.resp, res.err = i.dispatchCreateOrUpdate(req) + case "IdentityProviderClient.Delete": + res.resp, res.err = i.dispatchDelete(req) + case "IdentityProviderClient.Get": + res.resp, res.err = i.dispatchGet(req) + case "IdentityProviderClient.GetEntityTag": + res.resp, res.err = i.dispatchGetEntityTag(req) + case "IdentityProviderClient.NewListByServicePager": + res.resp, res.err = i.dispatchNewListByServicePager(req) + case "IdentityProviderClient.ListSecrets": + res.resp, res.err = i.dispatchListSecrets(req) + case "IdentityProviderClient.Update": + res.resp, res.err = i.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (i *IdentityProviderServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -435,3 +451,9 @@ func (i *IdentityProviderServerTransport) dispatchUpdate(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to IdentityProviderServerTransport +var identityProviderServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/internal.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/internal.go index 96339f26b377..aae62d9dd5b9 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/internal.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/internal.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,6 +12,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/issue_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/issue_server.go index 8834e3d480da..3753a5ef3d85 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/issue_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/issue_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -59,23 +56,42 @@ func (i *IssueServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return i.dispatchToMethodFake(req, method) +} - switch method { - case "IssueClient.Get": - resp, err = i.dispatchGet(req) - case "IssueClient.NewListByServicePager": - resp, err = i.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (i *IssueServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if issueServerTransportInterceptor != nil { + res.resp, res.err, intercepted = issueServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "IssueClient.Get": + res.resp, res.err = i.dispatchGet(req) + case "IssueClient.NewListByServicePager": + res.resp, res.err = i.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (i *IssueServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -200,3 +216,9 @@ func (i *IssueServerTransport) dispatchNewListByServicePager(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to IssueServerTransport +var issueServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/logger_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/logger_server.go index dd472316d075..6ba654361a02 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/logger_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/logger_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -75,31 +72,50 @@ func (l *LoggerServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return l.dispatchToMethodFake(req, method) +} - switch method { - case "LoggerClient.CreateOrUpdate": - resp, err = l.dispatchCreateOrUpdate(req) - case "LoggerClient.Delete": - resp, err = l.dispatchDelete(req) - case "LoggerClient.Get": - resp, err = l.dispatchGet(req) - case "LoggerClient.GetEntityTag": - resp, err = l.dispatchGetEntityTag(req) - case "LoggerClient.NewListByServicePager": - resp, err = l.dispatchNewListByServicePager(req) - case "LoggerClient.Update": - resp, err = l.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (l *LoggerServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if loggerServerTransportInterceptor != nil { + res.resp, res.err, intercepted = loggerServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "LoggerClient.CreateOrUpdate": + res.resp, res.err = l.dispatchCreateOrUpdate(req) + case "LoggerClient.Delete": + res.resp, res.err = l.dispatchDelete(req) + case "LoggerClient.Get": + res.resp, res.err = l.dispatchGet(req) + case "LoggerClient.GetEntityTag": + res.resp, res.err = l.dispatchGetEntityTag(req) + case "LoggerClient.NewListByServicePager": + res.resp, res.err = l.dispatchNewListByServicePager(req) + case "LoggerClient.Update": + res.resp, res.err = l.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (l *LoggerServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -396,3 +412,9 @@ func (l *LoggerServerTransport) dispatchUpdate(req *http.Request) (*http.Respons } return resp, nil } + +// set this to conditionally intercept incoming requests to LoggerServerTransport +var loggerServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/namedvalue_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/namedvalue_server.go index f1600eaaafb4..10e54302b22a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/namedvalue_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/namedvalue_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -26,7 +23,7 @@ import ( // NamedValueServer is a fake server for instances of the armapimanagement.NamedValueClient type. type NamedValueServer struct { // BeginCreateOrUpdate is the fake for method NamedValueClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters armapimanagement.NamedValueCreateContract, options *armapimanagement.NamedValueClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.NamedValueClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method NamedValueClient.Delete @@ -89,35 +86,54 @@ func (n *NamedValueServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "NamedValueClient.BeginCreateOrUpdate": - resp, err = n.dispatchBeginCreateOrUpdate(req) - case "NamedValueClient.Delete": - resp, err = n.dispatchDelete(req) - case "NamedValueClient.Get": - resp, err = n.dispatchGet(req) - case "NamedValueClient.GetEntityTag": - resp, err = n.dispatchGetEntityTag(req) - case "NamedValueClient.NewListByServicePager": - resp, err = n.dispatchNewListByServicePager(req) - case "NamedValueClient.ListValue": - resp, err = n.dispatchListValue(req) - case "NamedValueClient.BeginRefreshSecret": - resp, err = n.dispatchBeginRefreshSecret(req) - case "NamedValueClient.BeginUpdate": - resp, err = n.dispatchBeginUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return n.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (n *NamedValueServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - return resp, nil + go func() { + var intercepted bool + var res result + if namedValueServerTransportInterceptor != nil { + res.resp, res.err, intercepted = namedValueServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "NamedValueClient.BeginCreateOrUpdate": + res.resp, res.err = n.dispatchBeginCreateOrUpdate(req) + case "NamedValueClient.Delete": + res.resp, res.err = n.dispatchDelete(req) + case "NamedValueClient.Get": + res.resp, res.err = n.dispatchGet(req) + case "NamedValueClient.GetEntityTag": + res.resp, res.err = n.dispatchGetEntityTag(req) + case "NamedValueClient.NewListByServicePager": + res.resp, res.err = n.dispatchNewListByServicePager(req) + case "NamedValueClient.ListValue": + res.resp, res.err = n.dispatchListValue(req) + case "NamedValueClient.BeginRefreshSecret": + res.resp, res.err = n.dispatchBeginRefreshSecret(req) + case "NamedValueClient.BeginUpdate": + res.resp, res.err = n.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (n *NamedValueServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -168,9 +184,9 @@ func (n *NamedValueServerTransport) dispatchBeginCreateOrUpdate(req *http.Reques return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { n.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { n.beginCreateOrUpdate.remove(req) @@ -527,3 +543,9 @@ func (n *NamedValueServerTransport) dispatchBeginUpdate(req *http.Request) (*htt return resp, nil } + +// set this to conditionally intercept incoming requests to NamedValueServerTransport +var namedValueServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/networkstatus_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/networkstatus_server.go index 884b74576dc2..c9126c1e7b09 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/networkstatus_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/networkstatus_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -53,23 +50,42 @@ func (n *NetworkStatusServerTransport) Do(req *http.Request) (*http.Response, er return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return n.dispatchToMethodFake(req, method) +} - switch method { - case "NetworkStatusClient.ListByLocation": - resp, err = n.dispatchListByLocation(req) - case "NetworkStatusClient.ListByService": - resp, err = n.dispatchListByService(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (n *NetworkStatusServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if networkStatusServerTransportInterceptor != nil { + res.resp, res.err, intercepted = networkStatusServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "NetworkStatusClient.ListByLocation": + res.resp, res.err = n.dispatchListByLocation(req) + case "NetworkStatusClient.ListByService": + res.resp, res.err = n.dispatchListByService(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (n *NetworkStatusServerTransport) dispatchListByLocation(req *http.Request) (*http.Response, error) { @@ -141,3 +157,9 @@ func (n *NetworkStatusServerTransport) dispatchListByService(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to NetworkStatusServerTransport +var networkStatusServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/notification_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/notification_server.go index 99153032ccec..092fe20a0fb9 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/notification_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/notification_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -63,25 +60,44 @@ func (n *NotificationServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return n.dispatchToMethodFake(req, method) +} - switch method { - case "NotificationClient.CreateOrUpdate": - resp, err = n.dispatchCreateOrUpdate(req) - case "NotificationClient.Get": - resp, err = n.dispatchGet(req) - case "NotificationClient.NewListByServicePager": - resp, err = n.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (n *NotificationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if notificationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = notificationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "NotificationClient.CreateOrUpdate": + res.resp, res.err = n.dispatchCreateOrUpdate(req) + case "NotificationClient.Get": + res.resp, res.err = n.dispatchGet(req) + case "NotificationClient.NewListByServicePager": + res.resp, res.err = n.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (n *NotificationServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -253,3 +269,9 @@ func (n *NotificationServerTransport) dispatchNewListByServicePager(req *http.Re } return resp, nil } + +// set this to conditionally intercept incoming requests to NotificationServerTransport +var notificationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/notificationrecipientemail_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/notificationrecipientemail_server.go index 5f7f17c2c722..3e9b0dadbf37 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/notificationrecipientemail_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/notificationrecipientemail_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -61,27 +58,46 @@ func (n *NotificationRecipientEmailServerTransport) Do(req *http.Request) (*http return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return n.dispatchToMethodFake(req, method) +} - switch method { - case "NotificationRecipientEmailClient.CheckEntityExists": - resp, err = n.dispatchCheckEntityExists(req) - case "NotificationRecipientEmailClient.CreateOrUpdate": - resp, err = n.dispatchCreateOrUpdate(req) - case "NotificationRecipientEmailClient.Delete": - resp, err = n.dispatchDelete(req) - case "NotificationRecipientEmailClient.ListByNotification": - resp, err = n.dispatchListByNotification(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (n *NotificationRecipientEmailServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if notificationRecipientEmailServerTransportInterceptor != nil { + res.resp, res.err, intercepted = notificationRecipientEmailServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "NotificationRecipientEmailClient.CheckEntityExists": + res.resp, res.err = n.dispatchCheckEntityExists(req) + case "NotificationRecipientEmailClient.CreateOrUpdate": + res.resp, res.err = n.dispatchCreateOrUpdate(req) + case "NotificationRecipientEmailClient.Delete": + res.resp, res.err = n.dispatchDelete(req) + case "NotificationRecipientEmailClient.ListByNotification": + res.resp, res.err = n.dispatchListByNotification(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (n *NotificationRecipientEmailServerTransport) dispatchCheckEntityExists(req *http.Request) (*http.Response, error) { @@ -267,3 +283,9 @@ func (n *NotificationRecipientEmailServerTransport) dispatchListByNotification(r } return resp, nil } + +// set this to conditionally intercept incoming requests to NotificationRecipientEmailServerTransport +var notificationRecipientEmailServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/notificationrecipientuser_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/notificationrecipientuser_server.go index e9615fea7eb5..3b0de02c6890 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/notificationrecipientuser_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/notificationrecipientuser_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -61,27 +58,46 @@ func (n *NotificationRecipientUserServerTransport) Do(req *http.Request) (*http. return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return n.dispatchToMethodFake(req, method) +} - switch method { - case "NotificationRecipientUserClient.CheckEntityExists": - resp, err = n.dispatchCheckEntityExists(req) - case "NotificationRecipientUserClient.CreateOrUpdate": - resp, err = n.dispatchCreateOrUpdate(req) - case "NotificationRecipientUserClient.Delete": - resp, err = n.dispatchDelete(req) - case "NotificationRecipientUserClient.ListByNotification": - resp, err = n.dispatchListByNotification(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (n *NotificationRecipientUserServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if notificationRecipientUserServerTransportInterceptor != nil { + res.resp, res.err, intercepted = notificationRecipientUserServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "NotificationRecipientUserClient.CheckEntityExists": + res.resp, res.err = n.dispatchCheckEntityExists(req) + case "NotificationRecipientUserClient.CreateOrUpdate": + res.resp, res.err = n.dispatchCreateOrUpdate(req) + case "NotificationRecipientUserClient.Delete": + res.resp, res.err = n.dispatchDelete(req) + case "NotificationRecipientUserClient.ListByNotification": + res.resp, res.err = n.dispatchListByNotification(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (n *NotificationRecipientUserServerTransport) dispatchCheckEntityExists(req *http.Request) (*http.Response, error) { @@ -267,3 +283,9 @@ func (n *NotificationRecipientUserServerTransport) dispatchListByNotification(re } return resp, nil } + +// set this to conditionally intercept incoming requests to NotificationRecipientUserServerTransport +var notificationRecipientUserServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/openidconnectprovider_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/openidconnectprovider_server.go index 9a97001b5cac..2cdd2aeae6fe 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/openidconnectprovider_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/openidconnectprovider_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -79,33 +76,52 @@ func (o *OpenIDConnectProviderServerTransport) Do(req *http.Request) (*http.Resp return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OpenIDConnectProviderClient.CreateOrUpdate": - resp, err = o.dispatchCreateOrUpdate(req) - case "OpenIDConnectProviderClient.Delete": - resp, err = o.dispatchDelete(req) - case "OpenIDConnectProviderClient.Get": - resp, err = o.dispatchGet(req) - case "OpenIDConnectProviderClient.GetEntityTag": - resp, err = o.dispatchGetEntityTag(req) - case "OpenIDConnectProviderClient.NewListByServicePager": - resp, err = o.dispatchNewListByServicePager(req) - case "OpenIDConnectProviderClient.ListSecrets": - resp, err = o.dispatchListSecrets(req) - case "OpenIDConnectProviderClient.Update": - resp, err = o.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OpenIDConnectProviderServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if openIdConnectProviderServerTransportInterceptor != nil { + res.resp, res.err, intercepted = openIdConnectProviderServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OpenIDConnectProviderClient.CreateOrUpdate": + res.resp, res.err = o.dispatchCreateOrUpdate(req) + case "OpenIDConnectProviderClient.Delete": + res.resp, res.err = o.dispatchDelete(req) + case "OpenIDConnectProviderClient.Get": + res.resp, res.err = o.dispatchGet(req) + case "OpenIDConnectProviderClient.GetEntityTag": + res.resp, res.err = o.dispatchGetEntityTag(req) + case "OpenIDConnectProviderClient.NewListByServicePager": + res.resp, res.err = o.dispatchNewListByServicePager(req) + case "OpenIDConnectProviderClient.ListSecrets": + res.resp, res.err = o.dispatchListSecrets(req) + case "OpenIDConnectProviderClient.Update": + res.resp, res.err = o.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OpenIDConnectProviderServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -442,3 +458,9 @@ func (o *OpenIDConnectProviderServerTransport) dispatchUpdate(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to OpenIDConnectProviderServerTransport +var openIdConnectProviderServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/operation_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/operation_server.go index f8add5aabb63..37b68f7cc17e 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/operation_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/operation_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -54,21 +51,40 @@ func (o *OperationServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationClient.NewListByTagsPager": - resp, err = o.dispatchNewListByTagsPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationClient.NewListByTagsPager": + res.resp, res.err = o.dispatchNewListByTagsPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationServerTransport) dispatchNewListByTagsPager(req *http.Request) (*http.Response, error) { @@ -166,3 +182,9 @@ func (o *OperationServerTransport) dispatchNewListByTagsPager(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationServerTransport +var operationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/operations_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/operations_server.go index 37e7f88cccb1..7c331d74e4c7 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/operations_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/operations_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" ) @@ -51,21 +48,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/operationsresults_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/operationsresults_server.go new file mode 100644 index 000000000000..df7191a890fa --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/operationsresults_server.go @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// OperationsResultsServer is a fake server for instances of the armapimanagement.OperationsResultsClient type. +type OperationsResultsServer struct { + // Get is the fake for method OperationsResultsClient.Get + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + Get func(ctx context.Context, location string, operationID string, options *armapimanagement.OperationsResultsClientGetOptions) (resp azfake.Responder[armapimanagement.OperationsResultsClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationsResultsServerTransport creates a new instance of OperationsResultsServerTransport with the provided implementation. +// The returned OperationsResultsServerTransport instance is connected to an instance of armapimanagement.OperationsResultsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsResultsServerTransport(srv *OperationsResultsServer) *OperationsResultsServerTransport { + return &OperationsResultsServerTransport{srv: srv} +} + +// OperationsResultsServerTransport connects instances of armapimanagement.OperationsResultsClient to instances of OperationsResultsServer. +// Don't use this type directly, use NewOperationsResultsServerTransport instead. +type OperationsResultsServerTransport struct { + srv *OperationsResultsServer +} + +// Do implements the policy.Transporter interface for OperationsResultsServerTransport. +func (o *OperationsResultsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationsResultsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if operationsResultsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsResultsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsResultsClient.Get": + res.resp, res.err = o.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (o *OperationsResultsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationResults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), locationParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusAccepted}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).Location; val != nil { + resp.Header.Set("Location", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to OperationsResultsServerTransport +var operationsResultsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/operationstatus_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/operationstatus_server.go new file mode 100644 index 000000000000..0ddf1da5892e --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/operationstatus_server.go @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// OperationStatusServer is a fake server for instances of the armapimanagement.OperationStatusClient type. +type OperationStatusServer struct { + // Get is the fake for method OperationStatusClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, location string, operationID string, options *armapimanagement.OperationStatusClientGetOptions) (resp azfake.Responder[armapimanagement.OperationStatusClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationStatusServerTransport creates a new instance of OperationStatusServerTransport with the provided implementation. +// The returned OperationStatusServerTransport instance is connected to an instance of armapimanagement.OperationStatusClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationStatusServerTransport(srv *OperationStatusServer) *OperationStatusServerTransport { + return &OperationStatusServerTransport{srv: srv} +} + +// OperationStatusServerTransport connects instances of armapimanagement.OperationStatusClient to instances of OperationStatusServer. +// Don't use this type directly, use NewOperationStatusServerTransport instead. +type OperationStatusServerTransport struct { + srv *OperationStatusServer +} + +// Do implements the policy.Transporter interface for OperationStatusServerTransport. +func (o *OperationStatusServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationStatusServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if operationStatusServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationStatusServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationStatusClient.Get": + res.resp, res.err = o.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (o *OperationStatusServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationStatuses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), locationParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationStatusResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to OperationStatusServerTransport +var operationStatusServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/outboundnetworkdependenciesendpoints_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/outboundnetworkdependenciesendpoints_server.go index 637c6e743226..17d323098049 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/outboundnetworkdependenciesendpoints_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/outboundnetworkdependenciesendpoints_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (o *OutboundNetworkDependenciesEndpointsServerTransport) Do(req *http.Reque return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OutboundNetworkDependenciesEndpointsClient.ListByService": - resp, err = o.dispatchListByService(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OutboundNetworkDependenciesEndpointsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if outboundNetworkDependenciesEndpointsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = outboundNetworkDependenciesEndpointsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OutboundNetworkDependenciesEndpointsClient.ListByService": + res.resp, res.err = o.dispatchListByService(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OutboundNetworkDependenciesEndpointsServerTransport) dispatchListByService(req *http.Request) (*http.Response, error) { @@ -98,3 +114,9 @@ func (o *OutboundNetworkDependenciesEndpointsServerTransport) dispatchListByServ } return resp, nil } + +// set this to conditionally intercept incoming requests to OutboundNetworkDependenciesEndpointsServerTransport +var outboundNetworkDependenciesEndpointsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/policy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policy_server.go index 3cfdca1cf1c2..ee2dd856a832 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/policy_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policy_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -39,22 +37,26 @@ type PolicyServer struct { // HTTP status codes to indicate success: http.StatusOK GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, policyID armapimanagement.PolicyIDName, options *armapimanagement.PolicyClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.PolicyClientGetEntityTagResponse], errResp azfake.ErrorResponder) - // ListByService is the fake for method PolicyClient.ListByService + // NewListByServicePager is the fake for method PolicyClient.NewListByServicePager // HTTP status codes to indicate success: http.StatusOK - ListByService func(ctx context.Context, resourceGroupName string, serviceName string, options *armapimanagement.PolicyClientListByServiceOptions) (resp azfake.Responder[armapimanagement.PolicyClientListByServiceResponse], errResp azfake.ErrorResponder) + NewListByServicePager func(resourceGroupName string, serviceName string, options *armapimanagement.PolicyClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.PolicyClientListByServiceResponse]) } // NewPolicyServerTransport creates a new instance of PolicyServerTransport with the provided implementation. // The returned PolicyServerTransport instance is connected to an instance of armapimanagement.PolicyClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPolicyServerTransport(srv *PolicyServer) *PolicyServerTransport { - return &PolicyServerTransport{srv: srv} + return &PolicyServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.PolicyClientListByServiceResponse]](), + } } // PolicyServerTransport connects instances of armapimanagement.PolicyClient to instances of PolicyServer. // Don't use this type directly, use NewPolicyServerTransport instead. type PolicyServerTransport struct { - srv *PolicyServer + srv *PolicyServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.PolicyClientListByServiceResponse]] } // Do implements the policy.Transporter interface for PolicyServerTransport. @@ -65,29 +67,48 @@ func (p *PolicyServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PolicyClient.CreateOrUpdate": - resp, err = p.dispatchCreateOrUpdate(req) - case "PolicyClient.Delete": - resp, err = p.dispatchDelete(req) - case "PolicyClient.Get": - resp, err = p.dispatchGet(req) - case "PolicyClient.GetEntityTag": - resp, err = p.dispatchGetEntityTag(req) - case "PolicyClient.ListByService": - resp, err = p.dispatchListByService(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if policyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = policyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PolicyClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "PolicyClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "PolicyClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PolicyClient.GetEntityTag": + res.resp, res.err = p.dispatchGetEntityTag(req) + case "PolicyClient.NewListByServicePager": + res.resp, res.err = p.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -294,35 +315,49 @@ func (p *PolicyServerTransport) dispatchGetEntityTag(req *http.Request) (*http.R return resp, nil } -func (p *PolicyServerTransport) dispatchListByService(req *http.Request) (*http.Response, error) { - if p.srv.ListByService == nil { - return nil, &nonRetriableError{errors.New("fake for method ListByService not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) +func (p *PolicyServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := p.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, nil) + newListByServicePager = &resp + p.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.PolicyClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) if err != nil { return nil, err } - respr, errRespr := p.srv.ListByService(req.Context(), resourceGroupNameParam, serviceNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyCollection, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListByServicePager) { + p.newListByServicePager.remove(req) } return resp, nil } + +// set this to conditionally intercept incoming requests to PolicyServerTransport +var policyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/policydescription_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policydescription_server.go index 25754ad7f3ce..f5c14c68373b 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/policydescription_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policydescription_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (p *PolicyDescriptionServerTransport) Do(req *http.Request) (*http.Response return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PolicyDescriptionClient.ListByService": - resp, err = p.dispatchListByService(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PolicyDescriptionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if policyDescriptionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = policyDescriptionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PolicyDescriptionClient.ListByService": + res.resp, res.err = p.dispatchListByService(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PolicyDescriptionServerTransport) dispatchListByService(req *http.Request) (*http.Response, error) { @@ -110,3 +126,9 @@ func (p *PolicyDescriptionServerTransport) dispatchListByService(req *http.Reque } return resp, nil } + +// set this to conditionally intercept incoming requests to PolicyDescriptionServerTransport +var policyDescriptionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyfragment_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyfragment_server.go index 74db0c93224a..778d48001089 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyfragment_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyfragment_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -25,7 +23,7 @@ import ( // PolicyFragmentServer is a fake server for instances of the armapimanagement.PolicyFragmentClient type. type PolicyFragmentServer struct { // BeginCreateOrUpdate is the fake for method PolicyFragmentClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, id string, parameters armapimanagement.PolicyFragmentContract, options *armapimanagement.PolicyFragmentClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.PolicyFragmentClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method PolicyFragmentClient.Delete @@ -40,9 +38,9 @@ type PolicyFragmentServer struct { // HTTP status codes to indicate success: http.StatusOK GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, id string, options *armapimanagement.PolicyFragmentClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.PolicyFragmentClientGetEntityTagResponse], errResp azfake.ErrorResponder) - // ListByService is the fake for method PolicyFragmentClient.ListByService + // NewListByServicePager is the fake for method PolicyFragmentClient.NewListByServicePager // HTTP status codes to indicate success: http.StatusOK - ListByService func(ctx context.Context, resourceGroupName string, serviceName string, options *armapimanagement.PolicyFragmentClientListByServiceOptions) (resp azfake.Responder[armapimanagement.PolicyFragmentClientListByServiceResponse], errResp azfake.ErrorResponder) + NewListByServicePager func(resourceGroupName string, serviceName string, options *armapimanagement.PolicyFragmentClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.PolicyFragmentClientListByServiceResponse]) // ListReferences is the fake for method PolicyFragmentClient.ListReferences // HTTP status codes to indicate success: http.StatusOK @@ -54,16 +52,18 @@ type PolicyFragmentServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPolicyFragmentServerTransport(srv *PolicyFragmentServer) *PolicyFragmentServerTransport { return &PolicyFragmentServerTransport{ - srv: srv, - beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.PolicyFragmentClientCreateOrUpdateResponse]](), + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.PolicyFragmentClientCreateOrUpdateResponse]](), + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.PolicyFragmentClientListByServiceResponse]](), } } // PolicyFragmentServerTransport connects instances of armapimanagement.PolicyFragmentClient to instances of PolicyFragmentServer. // Don't use this type directly, use NewPolicyFragmentServerTransport instead. type PolicyFragmentServerTransport struct { - srv *PolicyFragmentServer - beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.PolicyFragmentClientCreateOrUpdateResponse]] + srv *PolicyFragmentServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.PolicyFragmentClientCreateOrUpdateResponse]] + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.PolicyFragmentClientListByServiceResponse]] } // Do implements the policy.Transporter interface for PolicyFragmentServerTransport. @@ -74,31 +74,50 @@ func (p *PolicyFragmentServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PolicyFragmentClient.BeginCreateOrUpdate": - resp, err = p.dispatchBeginCreateOrUpdate(req) - case "PolicyFragmentClient.Delete": - resp, err = p.dispatchDelete(req) - case "PolicyFragmentClient.Get": - resp, err = p.dispatchGet(req) - case "PolicyFragmentClient.GetEntityTag": - resp, err = p.dispatchGetEntityTag(req) - case "PolicyFragmentClient.ListByService": - resp, err = p.dispatchListByService(req) - case "PolicyFragmentClient.ListReferences": - resp, err = p.dispatchListReferences(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PolicyFragmentServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if policyFragmentServerTransportInterceptor != nil { + res.resp, res.err, intercepted = policyFragmentServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PolicyFragmentClient.BeginCreateOrUpdate": + res.resp, res.err = p.dispatchBeginCreateOrUpdate(req) + case "PolicyFragmentClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "PolicyFragmentClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PolicyFragmentClient.GetEntityTag": + res.resp, res.err = p.dispatchGetEntityTag(req) + case "PolicyFragmentClient.NewListByServicePager": + res.resp, res.err = p.dispatchNewListByServicePager(req) + case "PolicyFragmentClient.ListReferences": + res.resp, res.err = p.dispatchListReferences(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PolicyFragmentServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -149,9 +168,9 @@ func (p *PolicyFragmentServerTransport) dispatchBeginCreateOrUpdate(req *http.Re return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { p.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { p.beginCreateOrUpdate.remove(req) @@ -289,84 +308,92 @@ func (p *PolicyFragmentServerTransport) dispatchGetEntityTag(req *http.Request) return resp, nil } -func (p *PolicyFragmentServerTransport) dispatchListByService(req *http.Request) (*http.Response, error) { - if p.srv.ListByService == nil { - return nil, &nonRetriableError{errors.New("fake for method ListByService not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyFragments` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - orderbyUnescaped, err := url.QueryUnescape(qp.Get("$orderby")) - if err != nil { - return nil, err +func (p *PolicyFragmentServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} } - orderbyParam := getOptional(orderbyUnescaped) - topUnescaped, err := url.QueryUnescape(qp.Get("$top")) - if err != nil { - return nil, err - } - topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { - p, parseErr := strconv.ParseInt(v, 10, 32) - if parseErr != nil { - return 0, parseErr + newListByServicePager := p.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyFragments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - return int32(p), nil - }) - if err != nil { - return nil, err - } - skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) - if err != nil { - return nil, err - } - skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { - p, parseErr := strconv.ParseInt(v, 10, 32) - if parseErr != nil { - return 0, parseErr + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err } - return int32(p), nil - }) - if err != nil { - return nil, err - } - var options *armapimanagement.PolicyFragmentClientListByServiceOptions - if filterParam != nil || orderbyParam != nil || topParam != nil || skipParam != nil { - options = &armapimanagement.PolicyFragmentClientListByServiceOptions{ - Filter: filterParam, - Orderby: orderbyParam, - Top: topParam, - Skip: skipParam, + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderbyUnescaped, err := url.QueryUnescape(qp.Get("$orderby")) + if err != nil { + return nil, err + } + orderbyParam := getOptional(orderbyUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.PolicyFragmentClientListByServiceOptions + if filterParam != nil || orderbyParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.PolicyFragmentClientListByServiceOptions{ + Filter: filterParam, + Orderby: orderbyParam, + Top: topParam, + Skip: skipParam, + } + } + resp := p.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, options) + newListByServicePager = &resp + p.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.PolicyFragmentClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } - respr, errRespr := p.srv.ListByService(req.Context(), resourceGroupNameParam, serviceNameParam, options) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyFragmentCollection, req) + resp, err := server.PagerResponderNext(newListByServicePager, req) if err != nil { return nil, err } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + p.newListByServicePager.remove(req) + } return resp, nil } @@ -442,3 +469,9 @@ func (p *PolicyFragmentServerTransport) dispatchListReferences(req *http.Request } return resp, nil } + +// set this to conditionally intercept incoming requests to PolicyFragmentServerTransport +var policyFragmentServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyrestriction_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyrestriction_server.go new file mode 100644 index 000000000000..1834fe2f59a7 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyrestriction_server.go @@ -0,0 +1,384 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// PolicyRestrictionServer is a fake server for instances of the armapimanagement.PolicyRestrictionClient type. +type PolicyRestrictionServer struct { + // CreateOrUpdate is the fake for method PolicyRestrictionClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, parameters armapimanagement.PolicyRestrictionContract, options *armapimanagement.PolicyRestrictionClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.PolicyRestrictionClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method PolicyRestrictionClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, options *armapimanagement.PolicyRestrictionClientDeleteOptions) (resp azfake.Responder[armapimanagement.PolicyRestrictionClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PolicyRestrictionClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, options *armapimanagement.PolicyRestrictionClientGetOptions) (resp azfake.Responder[armapimanagement.PolicyRestrictionClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method PolicyRestrictionClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, options *armapimanagement.PolicyRestrictionClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.PolicyRestrictionClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method PolicyRestrictionClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, options *armapimanagement.PolicyRestrictionClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.PolicyRestrictionClientListByServiceResponse]) + + // Update is the fake for method PolicyRestrictionClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, ifMatch string, parameters armapimanagement.PolicyRestrictionUpdateContract, options *armapimanagement.PolicyRestrictionClientUpdateOptions) (resp azfake.Responder[armapimanagement.PolicyRestrictionClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewPolicyRestrictionServerTransport creates a new instance of PolicyRestrictionServerTransport with the provided implementation. +// The returned PolicyRestrictionServerTransport instance is connected to an instance of armapimanagement.PolicyRestrictionClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPolicyRestrictionServerTransport(srv *PolicyRestrictionServer) *PolicyRestrictionServerTransport { + return &PolicyRestrictionServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.PolicyRestrictionClientListByServiceResponse]](), + } +} + +// PolicyRestrictionServerTransport connects instances of armapimanagement.PolicyRestrictionClient to instances of PolicyRestrictionServer. +// Don't use this type directly, use NewPolicyRestrictionServerTransport instead. +type PolicyRestrictionServerTransport struct { + srv *PolicyRestrictionServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.PolicyRestrictionClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for PolicyRestrictionServerTransport. +func (p *PolicyRestrictionServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return p.dispatchToMethodFake(req, method) +} + +func (p *PolicyRestrictionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if policyRestrictionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = policyRestrictionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PolicyRestrictionClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "PolicyRestrictionClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "PolicyRestrictionClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PolicyRestrictionClient.GetEntityTag": + res.resp, res.err = p.dispatchGetEntityTag(req) + case "PolicyRestrictionClient.NewListByServicePager": + res.resp, res.err = p.dispatchNewListByServicePager(req) + case "PolicyRestrictionClient.Update": + res.resp, res.err = p.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (p *PolicyRestrictionServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyRestrictions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.PolicyRestrictionContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + policyRestrictionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyRestrictionId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.PolicyRestrictionClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.PolicyRestrictionClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := p.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, policyRestrictionIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyRestrictionContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (p *PolicyRestrictionServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if p.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyRestrictions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + policyRestrictionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyRestrictionId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.PolicyRestrictionClientDeleteOptions + if ifMatchParam != nil { + options = &armapimanagement.PolicyRestrictionClientDeleteOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := p.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, policyRestrictionIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PolicyRestrictionServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyRestrictions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + policyRestrictionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyRestrictionId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, policyRestrictionIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyRestrictionContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (p *PolicyRestrictionServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if p.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyRestrictions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + policyRestrictionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyRestrictionId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, policyRestrictionIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (p *PolicyRestrictionServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := p.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyRestrictions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, nil) + newListByServicePager = &resp + p.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.PolicyRestrictionClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + p.newListByServicePager.remove(req) + } + return resp, nil +} + +func (p *PolicyRestrictionServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if p.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyRestrictions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.PolicyRestrictionUpdateContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + policyRestrictionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyRestrictionId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, policyRestrictionIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyRestrictionContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to PolicyRestrictionServerTransport +var policyRestrictionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyrestrictionvalidations_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyrestrictionvalidations_server.go new file mode 100644 index 000000000000..155c97124980 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/policyrestrictionvalidations_server.go @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// PolicyRestrictionValidationsServer is a fake server for instances of the armapimanagement.PolicyRestrictionValidationsClient type. +type PolicyRestrictionValidationsServer struct { + // BeginByService is the fake for method PolicyRestrictionValidationsClient.BeginByService + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginByService func(ctx context.Context, resourceGroupName string, serviceName string, options *armapimanagement.PolicyRestrictionValidationsClientBeginByServiceOptions) (resp azfake.PollerResponder[armapimanagement.PolicyRestrictionValidationsClientByServiceResponse], errResp azfake.ErrorResponder) +} + +// NewPolicyRestrictionValidationsServerTransport creates a new instance of PolicyRestrictionValidationsServerTransport with the provided implementation. +// The returned PolicyRestrictionValidationsServerTransport instance is connected to an instance of armapimanagement.PolicyRestrictionValidationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPolicyRestrictionValidationsServerTransport(srv *PolicyRestrictionValidationsServer) *PolicyRestrictionValidationsServerTransport { + return &PolicyRestrictionValidationsServerTransport{ + srv: srv, + beginByService: newTracker[azfake.PollerResponder[armapimanagement.PolicyRestrictionValidationsClientByServiceResponse]](), + } +} + +// PolicyRestrictionValidationsServerTransport connects instances of armapimanagement.PolicyRestrictionValidationsClient to instances of PolicyRestrictionValidationsServer. +// Don't use this type directly, use NewPolicyRestrictionValidationsServerTransport instead. +type PolicyRestrictionValidationsServerTransport struct { + srv *PolicyRestrictionValidationsServer + beginByService *tracker[azfake.PollerResponder[armapimanagement.PolicyRestrictionValidationsClientByServiceResponse]] +} + +// Do implements the policy.Transporter interface for PolicyRestrictionValidationsServerTransport. +func (p *PolicyRestrictionValidationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return p.dispatchToMethodFake(req, method) +} + +func (p *PolicyRestrictionValidationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if policyRestrictionValidationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = policyRestrictionValidationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PolicyRestrictionValidationsClient.BeginByService": + res.resp, res.err = p.dispatchBeginByService(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (p *PolicyRestrictionValidationsServerTransport) dispatchBeginByService(req *http.Request) (*http.Response, error) { + if p.srv.BeginByService == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginByService not implemented")} + } + beginByService := p.beginByService.get(req) + if beginByService == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validatePolicies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginByService(req.Context(), resourceGroupNameParam, serviceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginByService = &respr + p.beginByService.add(req, beginByService) + } + + resp, err := server.PollerResponderNext(beginByService, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginByService.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginByService) { + p.beginByService.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to PolicyRestrictionValidationsServerTransport +var policyRestrictionValidationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalconfig_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalconfig_server.go index 0afd66a87f7c..7aa38e40d79b 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalconfig_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalconfig_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -35,9 +33,9 @@ type PortalConfigServer struct { // HTTP status codes to indicate success: http.StatusOK GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, options *armapimanagement.PortalConfigClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.PortalConfigClientGetEntityTagResponse], errResp azfake.ErrorResponder) - // ListByService is the fake for method PortalConfigClient.ListByService + // NewListByServicePager is the fake for method PortalConfigClient.NewListByServicePager // HTTP status codes to indicate success: http.StatusOK - ListByService func(ctx context.Context, resourceGroupName string, serviceName string, options *armapimanagement.PortalConfigClientListByServiceOptions) (resp azfake.Responder[armapimanagement.PortalConfigClientListByServiceResponse], errResp azfake.ErrorResponder) + NewListByServicePager func(resourceGroupName string, serviceName string, options *armapimanagement.PortalConfigClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.PortalConfigClientListByServiceResponse]) // Update is the fake for method PortalConfigClient.Update // HTTP status codes to indicate success: http.StatusOK @@ -48,13 +46,17 @@ type PortalConfigServer struct { // The returned PortalConfigServerTransport instance is connected to an instance of armapimanagement.PortalConfigClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPortalConfigServerTransport(srv *PortalConfigServer) *PortalConfigServerTransport { - return &PortalConfigServerTransport{srv: srv} + return &PortalConfigServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.PortalConfigClientListByServiceResponse]](), + } } // PortalConfigServerTransport connects instances of armapimanagement.PortalConfigClient to instances of PortalConfigServer. // Don't use this type directly, use NewPortalConfigServerTransport instead. type PortalConfigServerTransport struct { - srv *PortalConfigServer + srv *PortalConfigServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.PortalConfigClientListByServiceResponse]] } // Do implements the policy.Transporter interface for PortalConfigServerTransport. @@ -65,29 +67,48 @@ func (p *PortalConfigServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PortalConfigClient.CreateOrUpdate": - resp, err = p.dispatchCreateOrUpdate(req) - case "PortalConfigClient.Get": - resp, err = p.dispatchGet(req) - case "PortalConfigClient.GetEntityTag": - resp, err = p.dispatchGetEntityTag(req) - case "PortalConfigClient.ListByService": - resp, err = p.dispatchListByService(req) - case "PortalConfigClient.Update": - resp, err = p.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PortalConfigServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if portalConfigServerTransportInterceptor != nil { + res.resp, res.err, intercepted = portalConfigServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PortalConfigClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "PortalConfigClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PortalConfigClient.GetEntityTag": + res.resp, res.err = p.dispatchGetEntityTag(req) + case "PortalConfigClient.NewListByServicePager": + res.resp, res.err = p.dispatchNewListByServicePager(req) + case "PortalConfigClient.Update": + res.resp, res.err = p.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PortalConfigServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -211,35 +232,43 @@ func (p *PortalConfigServerTransport) dispatchGetEntityTag(req *http.Request) (* return resp, nil } -func (p *PortalConfigServerTransport) dispatchListByService(req *http.Request) (*http.Response, error) { - if p.srv.ListByService == nil { - return nil, &nonRetriableError{errors.New("fake for method ListByService not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/portalconfigs` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) +func (p *PortalConfigServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := p.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/portalconfigs` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, nil) + newListByServicePager = &resp + p.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.PortalConfigClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) if err != nil { return nil, err } - serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) - if err != nil { - return nil, err + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - respr, errRespr := p.srv.ListByService(req.Context(), resourceGroupNameParam, serviceNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PortalConfigCollection, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListByServicePager) { + p.newListByServicePager.remove(req) } return resp, nil } @@ -284,3 +313,9 @@ func (p *PortalConfigServerTransport) dispatchUpdate(req *http.Request) (*http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to PortalConfigServerTransport +var portalConfigServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalrevision_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalrevision_server.go index dd596769bfed..682837558655 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalrevision_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalrevision_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -26,7 +23,7 @@ import ( // PortalRevisionServer is a fake server for instances of the armapimanagement.PortalRevisionClient type. type PortalRevisionServer struct { // BeginCreateOrUpdate is the fake for method PortalRevisionClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusCreated, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters armapimanagement.PortalRevisionContract, options *armapimanagement.PortalRevisionClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.PortalRevisionClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Get is the fake for method PortalRevisionClient.Get @@ -75,29 +72,48 @@ func (p *PortalRevisionServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PortalRevisionClient.BeginCreateOrUpdate": - resp, err = p.dispatchBeginCreateOrUpdate(req) - case "PortalRevisionClient.Get": - resp, err = p.dispatchGet(req) - case "PortalRevisionClient.GetEntityTag": - resp, err = p.dispatchGetEntityTag(req) - case "PortalRevisionClient.NewListByServicePager": - resp, err = p.dispatchNewListByServicePager(req) - case "PortalRevisionClient.BeginUpdate": - resp, err = p.dispatchBeginUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PortalRevisionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if portalRevisionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = portalRevisionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PortalRevisionClient.BeginCreateOrUpdate": + res.resp, res.err = p.dispatchBeginCreateOrUpdate(req) + case "PortalRevisionClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PortalRevisionClient.GetEntityTag": + res.resp, res.err = p.dispatchGetEntityTag(req) + case "PortalRevisionClient.NewListByServicePager": + res.resp, res.err = p.dispatchNewListByServicePager(req) + case "PortalRevisionClient.BeginUpdate": + res.resp, res.err = p.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PortalRevisionServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -141,9 +157,9 @@ func (p *PortalRevisionServerTransport) dispatchBeginCreateOrUpdate(req *http.Re return nil, err } - if !contains([]int{http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { p.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { p.beginCreateOrUpdate.remove(req) @@ -366,3 +382,9 @@ func (p *PortalRevisionServerTransport) dispatchBeginUpdate(req *http.Request) ( return resp, nil } + +// set this to conditionally intercept incoming requests to PortalRevisionServerTransport +var portalRevisionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalsettings_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalsettings_server.go index b1d4333a763e..9e9f4be90b8f 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalsettings_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/portalsettings_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (p *PortalSettingsServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PortalSettingsClient.ListByService": - resp, err = p.dispatchListByService(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PortalSettingsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if portalSettingsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = portalSettingsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PortalSettingsClient.ListByService": + res.resp, res.err = p.dispatchListByService(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PortalSettingsServerTransport) dispatchListByService(req *http.Request) (*http.Response, error) { @@ -98,3 +114,9 @@ func (p *PortalSettingsServerTransport) dispatchListByService(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to PortalSettingsServerTransport +var portalSettingsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/privateendpointconnection_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/privateendpointconnection_server.go index 2ac787773e41..5c6a523fd80f 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/privateendpointconnection_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/privateendpointconnection_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -77,31 +74,50 @@ func (p *PrivateEndpointConnectionServerTransport) Do(req *http.Request) (*http. return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PrivateEndpointConnectionClient.BeginCreateOrUpdate": - resp, err = p.dispatchBeginCreateOrUpdate(req) - case "PrivateEndpointConnectionClient.BeginDelete": - resp, err = p.dispatchBeginDelete(req) - case "PrivateEndpointConnectionClient.GetByName": - resp, err = p.dispatchGetByName(req) - case "PrivateEndpointConnectionClient.GetPrivateLinkResource": - resp, err = p.dispatchGetPrivateLinkResource(req) - case "PrivateEndpointConnectionClient.NewListByServicePager": - resp, err = p.dispatchNewListByServicePager(req) - case "PrivateEndpointConnectionClient.ListPrivateLinkResources": - resp, err = p.dispatchListPrivateLinkResources(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PrivateEndpointConnectionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if privateEndpointConnectionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = privateEndpointConnectionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PrivateEndpointConnectionClient.BeginCreateOrUpdate": + res.resp, res.err = p.dispatchBeginCreateOrUpdate(req) + case "PrivateEndpointConnectionClient.BeginDelete": + res.resp, res.err = p.dispatchBeginDelete(req) + case "PrivateEndpointConnectionClient.GetByName": + res.resp, res.err = p.dispatchGetByName(req) + case "PrivateEndpointConnectionClient.GetPrivateLinkResource": + res.resp, res.err = p.dispatchGetPrivateLinkResource(req) + case "PrivateEndpointConnectionClient.NewListByServicePager": + res.resp, res.err = p.dispatchNewListByServicePager(req) + case "PrivateEndpointConnectionClient.ListPrivateLinkResources": + res.resp, res.err = p.dispatchListPrivateLinkResources(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *PrivateEndpointConnectionServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -348,3 +364,9 @@ func (p *PrivateEndpointConnectionServerTransport) dispatchListPrivateLinkResour } return resp, nil } + +// set this to conditionally intercept incoming requests to PrivateEndpointConnectionServerTransport +var privateEndpointConnectionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/product_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/product_server.go index a833a8d4eb18..0b71ef21fe13 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/product_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/product_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -81,33 +78,52 @@ func (p *ProductServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProductClient.CreateOrUpdate": - resp, err = p.dispatchCreateOrUpdate(req) - case "ProductClient.Delete": - resp, err = p.dispatchDelete(req) - case "ProductClient.Get": - resp, err = p.dispatchGet(req) - case "ProductClient.GetEntityTag": - resp, err = p.dispatchGetEntityTag(req) - case "ProductClient.NewListByServicePager": - resp, err = p.dispatchNewListByServicePager(req) - case "ProductClient.NewListByTagsPager": - resp, err = p.dispatchNewListByTagsPager(req) - case "ProductClient.Update": - resp, err = p.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProductServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if productServerTransportInterceptor != nil { + res.resp, res.err, intercepted = productServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProductClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "ProductClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "ProductClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "ProductClient.GetEntityTag": + res.resp, res.err = p.dispatchGetEntityTag(req) + case "ProductClient.NewListByServicePager": + res.resp, res.err = p.dispatchNewListByServicePager(req) + case "ProductClient.NewListByTagsPager": + res.resp, res.err = p.dispatchNewListByTagsPager(req) + case "ProductClient.Update": + res.resp, res.err = p.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProductServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -526,3 +542,9 @@ func (p *ProductServerTransport) dispatchUpdate(req *http.Request) (*http.Respon } return resp, nil } + +// set this to conditionally intercept incoming requests to ProductServerTransport +var productServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productapi_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productapi_server.go index 6725a39adc6f..1bea75ede0c2 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productapi_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productapi_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -67,27 +64,46 @@ func (p *ProductAPIServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProductAPIClient.CheckEntityExists": - resp, err = p.dispatchCheckEntityExists(req) - case "ProductAPIClient.CreateOrUpdate": - resp, err = p.dispatchCreateOrUpdate(req) - case "ProductAPIClient.Delete": - resp, err = p.dispatchDelete(req) - case "ProductAPIClient.NewListByProductPager": - resp, err = p.dispatchNewListByProductPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProductAPIServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if productApiServerTransportInterceptor != nil { + res.resp, res.err, intercepted = productApiServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProductAPIClient.CheckEntityExists": + res.resp, res.err = p.dispatchCheckEntityExists(req) + case "ProductAPIClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "ProductAPIClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "ProductAPIClient.NewListByProductPager": + res.resp, res.err = p.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProductAPIServerTransport) dispatchCheckEntityExists(req *http.Request) (*http.Response, error) { @@ -299,3 +315,9 @@ func (p *ProductAPIServerTransport) dispatchNewListByProductPager(req *http.Requ } return resp, nil } + +// set this to conditionally intercept incoming requests to ProductAPIServerTransport +var productApiServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productapilink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productapilink_server.go new file mode 100644 index 000000000000..a81e8d2cb2b3 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productapilink_server.go @@ -0,0 +1,330 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// ProductAPILinkServer is a fake server for instances of the armapimanagement.ProductAPILinkClient type. +type ProductAPILinkServer struct { + // CreateOrUpdate is the fake for method ProductAPILinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiLinkID string, parameters armapimanagement.ProductAPILinkContract, options *armapimanagement.ProductAPILinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.ProductAPILinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ProductAPILinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiLinkID string, options *armapimanagement.ProductAPILinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.ProductAPILinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ProductAPILinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiLinkID string, options *armapimanagement.ProductAPILinkClientGetOptions) (resp azfake.Responder[armapimanagement.ProductAPILinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method ProductAPILinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, productID string, options *armapimanagement.ProductAPILinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.ProductAPILinkClientListByProductResponse]) +} + +// NewProductAPILinkServerTransport creates a new instance of ProductAPILinkServerTransport with the provided implementation. +// The returned ProductAPILinkServerTransport instance is connected to an instance of armapimanagement.ProductAPILinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewProductAPILinkServerTransport(srv *ProductAPILinkServer) *ProductAPILinkServerTransport { + return &ProductAPILinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.ProductAPILinkClientListByProductResponse]](), + } +} + +// ProductAPILinkServerTransport connects instances of armapimanagement.ProductAPILinkClient to instances of ProductAPILinkServer. +// Don't use this type directly, use NewProductAPILinkServerTransport instead. +type ProductAPILinkServerTransport struct { + srv *ProductAPILinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.ProductAPILinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for ProductAPILinkServerTransport. +func (p *ProductAPILinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return p.dispatchToMethodFake(req, method) +} + +func (p *ProductAPILinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if productApiLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = productApiLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProductAPILinkClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "ProductAPILinkClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "ProductAPILinkClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "ProductAPILinkClient.NewListByProductPager": + res.resp, res.err = p.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (p *ProductAPILinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.ProductAPILinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, productIDParam, apiLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductAPILinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *ProductAPILinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if p.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, productIDParam, apiLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *ProductAPILinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, productIDParam, apiLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductAPILinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (p *ProductAPILinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := p.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.ProductAPILinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.ProductAPILinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := p.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, productIDParam, options) + newListByProductPager = &resp + p.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.ProductAPILinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + p.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ProductAPILinkServerTransport +var productApiLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productgroup_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productgroup_server.go index e3c520aca3f0..9b231267ebfd 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productgroup_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productgroup_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -67,27 +64,46 @@ func (p *ProductGroupServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProductGroupClient.CheckEntityExists": - resp, err = p.dispatchCheckEntityExists(req) - case "ProductGroupClient.CreateOrUpdate": - resp, err = p.dispatchCreateOrUpdate(req) - case "ProductGroupClient.Delete": - resp, err = p.dispatchDelete(req) - case "ProductGroupClient.NewListByProductPager": - resp, err = p.dispatchNewListByProductPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProductGroupServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if productGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = productGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProductGroupClient.CheckEntityExists": + res.resp, res.err = p.dispatchCheckEntityExists(req) + case "ProductGroupClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "ProductGroupClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "ProductGroupClient.NewListByProductPager": + res.resp, res.err = p.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProductGroupServerTransport) dispatchCheckEntityExists(req *http.Request) (*http.Response, error) { @@ -299,3 +315,9 @@ func (p *ProductGroupServerTransport) dispatchNewListByProductPager(req *http.Re } return resp, nil } + +// set this to conditionally intercept incoming requests to ProductGroupServerTransport +var productGroupServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productgrouplink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productgrouplink_server.go new file mode 100644 index 000000000000..efa5cd591f27 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productgrouplink_server.go @@ -0,0 +1,330 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// ProductGroupLinkServer is a fake server for instances of the armapimanagement.ProductGroupLinkClient type. +type ProductGroupLinkServer struct { + // CreateOrUpdate is the fake for method ProductGroupLinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupLinkID string, parameters armapimanagement.ProductGroupLinkContract, options *armapimanagement.ProductGroupLinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.ProductGroupLinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ProductGroupLinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupLinkID string, options *armapimanagement.ProductGroupLinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.ProductGroupLinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ProductGroupLinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupLinkID string, options *armapimanagement.ProductGroupLinkClientGetOptions) (resp azfake.Responder[armapimanagement.ProductGroupLinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method ProductGroupLinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, productID string, options *armapimanagement.ProductGroupLinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.ProductGroupLinkClientListByProductResponse]) +} + +// NewProductGroupLinkServerTransport creates a new instance of ProductGroupLinkServerTransport with the provided implementation. +// The returned ProductGroupLinkServerTransport instance is connected to an instance of armapimanagement.ProductGroupLinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewProductGroupLinkServerTransport(srv *ProductGroupLinkServer) *ProductGroupLinkServerTransport { + return &ProductGroupLinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.ProductGroupLinkClientListByProductResponse]](), + } +} + +// ProductGroupLinkServerTransport connects instances of armapimanagement.ProductGroupLinkClient to instances of ProductGroupLinkServer. +// Don't use this type directly, use NewProductGroupLinkServerTransport instead. +type ProductGroupLinkServerTransport struct { + srv *ProductGroupLinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.ProductGroupLinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for ProductGroupLinkServerTransport. +func (p *ProductGroupLinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return p.dispatchToMethodFake(req, method) +} + +func (p *ProductGroupLinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if productGroupLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = productGroupLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProductGroupLinkClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "ProductGroupLinkClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "ProductGroupLinkClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "ProductGroupLinkClient.NewListByProductPager": + res.resp, res.err = p.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (p *ProductGroupLinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groupLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.ProductGroupLinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + groupLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, productIDParam, groupLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductGroupLinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *ProductGroupLinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if p.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groupLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + groupLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, productIDParam, groupLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *ProductGroupLinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groupLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + groupLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, productIDParam, groupLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductGroupLinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (p *ProductGroupLinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := p.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groupLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.ProductGroupLinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.ProductGroupLinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := p.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, productIDParam, options) + newListByProductPager = &resp + p.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.ProductGroupLinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + p.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ProductGroupLinkServerTransport +var productGroupLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productpolicy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productpolicy_server.go index c3122785de56..c61b2cd68eb6 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productpolicy_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productpolicy_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -39,22 +37,26 @@ type ProductPolicyServer struct { // HTTP status codes to indicate success: http.StatusOK GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID armapimanagement.PolicyIDName, options *armapimanagement.ProductPolicyClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.ProductPolicyClientGetEntityTagResponse], errResp azfake.ErrorResponder) - // ListByProduct is the fake for method ProductPolicyClient.ListByProduct + // NewListByProductPager is the fake for method ProductPolicyClient.NewListByProductPager // HTTP status codes to indicate success: http.StatusOK - ListByProduct func(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *armapimanagement.ProductPolicyClientListByProductOptions) (resp azfake.Responder[armapimanagement.ProductPolicyClientListByProductResponse], errResp azfake.ErrorResponder) + NewListByProductPager func(resourceGroupName string, serviceName string, productID string, options *armapimanagement.ProductPolicyClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.ProductPolicyClientListByProductResponse]) } // NewProductPolicyServerTransport creates a new instance of ProductPolicyServerTransport with the provided implementation. // The returned ProductPolicyServerTransport instance is connected to an instance of armapimanagement.ProductPolicyClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewProductPolicyServerTransport(srv *ProductPolicyServer) *ProductPolicyServerTransport { - return &ProductPolicyServerTransport{srv: srv} + return &ProductPolicyServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.ProductPolicyClientListByProductResponse]](), + } } // ProductPolicyServerTransport connects instances of armapimanagement.ProductPolicyClient to instances of ProductPolicyServer. // Don't use this type directly, use NewProductPolicyServerTransport instead. type ProductPolicyServerTransport struct { - srv *ProductPolicyServer + srv *ProductPolicyServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.ProductPolicyClientListByProductResponse]] } // Do implements the policy.Transporter interface for ProductPolicyServerTransport. @@ -65,29 +67,48 @@ func (p *ProductPolicyServerTransport) Do(req *http.Request) (*http.Response, er return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProductPolicyClient.CreateOrUpdate": - resp, err = p.dispatchCreateOrUpdate(req) - case "ProductPolicyClient.Delete": - resp, err = p.dispatchDelete(req) - case "ProductPolicyClient.Get": - resp, err = p.dispatchGet(req) - case "ProductPolicyClient.GetEntityTag": - resp, err = p.dispatchGetEntityTag(req) - case "ProductPolicyClient.ListByProduct": - resp, err = p.dispatchListByProduct(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProductPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if productPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = productPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProductPolicyClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "ProductPolicyClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "ProductPolicyClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "ProductPolicyClient.GetEntityTag": + res.resp, res.err = p.dispatchGetEntityTag(req) + case "ProductPolicyClient.NewListByProductPager": + res.resp, res.err = p.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProductPolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -310,39 +331,53 @@ func (p *ProductPolicyServerTransport) dispatchGetEntityTag(req *http.Request) ( return resp, nil } -func (p *ProductPolicyServerTransport) dispatchListByProduct(req *http.Request) (*http.Response, error) { - if p.srv.ListByProduct == nil { - return nil, &nonRetriableError{errors.New("fake for method ListByProduct not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) - if err != nil { - return nil, err - } - productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) +func (p *ProductPolicyServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := p.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, productIDParam, nil) + newListByProductPager = &resp + p.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.ProductPolicyClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) if err != nil { return nil, err } - respr, errRespr := p.srv.ListByProduct(req.Context(), resourceGroupNameParam, serviceNameParam, productIDParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyCollection, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListByProductPager) { + p.newListByProductPager.remove(req) } return resp, nil } + +// set this to conditionally intercept incoming requests to ProductPolicyServerTransport +var productPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productsubscriptions_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productsubscriptions_server.go index 9ac1064dd364..092077453811 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productsubscriptions_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productsubscriptions_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -54,21 +51,40 @@ func (p *ProductSubscriptionsServerTransport) Do(req *http.Request) (*http.Respo return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProductSubscriptionsClient.NewListPager": - resp, err = p.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProductSubscriptionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if productSubscriptionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = productSubscriptionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProductSubscriptionsClient.NewListPager": + res.resp, res.err = p.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProductSubscriptionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -157,3 +173,9 @@ func (p *ProductSubscriptionsServerTransport) dispatchNewListPager(req *http.Req } return resp, nil } + +// set this to conditionally intercept incoming requests to ProductSubscriptionsServerTransport +var productSubscriptionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productwiki_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productwiki_server.go index fca8c5ba8e7c..cf1b67725d30 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productwiki_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productwiki_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -65,29 +62,48 @@ func (p *ProductWikiServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProductWikiClient.CreateOrUpdate": - resp, err = p.dispatchCreateOrUpdate(req) - case "ProductWikiClient.Delete": - resp, err = p.dispatchDelete(req) - case "ProductWikiClient.Get": - resp, err = p.dispatchGet(req) - case "ProductWikiClient.GetEntityTag": - resp, err = p.dispatchGetEntityTag(req) - case "ProductWikiClient.Update": - resp, err = p.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProductWikiServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if productWikiServerTransportInterceptor != nil { + res.resp, res.err, intercepted = productWikiServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProductWikiClient.CreateOrUpdate": + res.resp, res.err = p.dispatchCreateOrUpdate(req) + case "ProductWikiClient.Delete": + res.resp, res.err = p.dispatchDelete(req) + case "ProductWikiClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "ProductWikiClient.GetEntityTag": + res.resp, res.err = p.dispatchGetEntityTag(req) + case "ProductWikiClient.Update": + res.resp, res.err = p.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProductWikiServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -301,3 +317,9 @@ func (p *ProductWikiServerTransport) dispatchUpdate(req *http.Request) (*http.Re } return resp, nil } + +// set this to conditionally intercept incoming requests to ProductWikiServerTransport +var productWikiServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productwikis_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productwikis_server.go index ae6c9cf6d5b9..8148e5001343 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/productwikis_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/productwikis_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -54,21 +51,40 @@ func (p *ProductWikisServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProductWikisClient.NewListPager": - resp, err = p.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProductWikisServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if productWikisServerTransportInterceptor != nil { + res.resp, res.err, intercepted = productWikisServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProductWikisClient.NewListPager": + res.resp, res.err = p.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProductWikisServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -157,3 +173,9 @@ func (p *ProductWikisServerTransport) dispatchNewListPager(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to ProductWikisServerTransport +var productWikisServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/quotabycounterkeys_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/quotabycounterkeys_server.go index 70a92d394589..42405ff27d53 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/quotabycounterkeys_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/quotabycounterkeys_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -53,23 +50,42 @@ func (q *QuotaByCounterKeysServerTransport) Do(req *http.Request) (*http.Respons return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return q.dispatchToMethodFake(req, method) +} - switch method { - case "QuotaByCounterKeysClient.ListByService": - resp, err = q.dispatchListByService(req) - case "QuotaByCounterKeysClient.Update": - resp, err = q.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (q *QuotaByCounterKeysServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if quotaByCounterKeysServerTransportInterceptor != nil { + res.resp, res.err, intercepted = quotaByCounterKeysServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "QuotaByCounterKeysClient.ListByService": + res.resp, res.err = q.dispatchListByService(req) + case "QuotaByCounterKeysClient.Update": + res.resp, res.err = q.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (q *QuotaByCounterKeysServerTransport) dispatchListByService(req *http.Request) (*http.Response, error) { @@ -149,3 +165,9 @@ func (q *QuotaByCounterKeysServerTransport) dispatchUpdate(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to QuotaByCounterKeysServerTransport +var quotaByCounterKeysServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/quotabyperiodkeys_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/quotabyperiodkeys_server.go index 8a31664bd9f4..f309d3e463d3 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/quotabyperiodkeys_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/quotabyperiodkeys_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -53,23 +50,42 @@ func (q *QuotaByPeriodKeysServerTransport) Do(req *http.Request) (*http.Response return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return q.dispatchToMethodFake(req, method) +} - switch method { - case "QuotaByPeriodKeysClient.Get": - resp, err = q.dispatchGet(req) - case "QuotaByPeriodKeysClient.Update": - resp, err = q.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (q *QuotaByPeriodKeysServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if quotaByPeriodKeysServerTransportInterceptor != nil { + res.resp, res.err, intercepted = quotaByPeriodKeysServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "QuotaByPeriodKeysClient.Get": + res.resp, res.err = q.dispatchGet(req) + case "QuotaByPeriodKeysClient.Update": + res.resp, res.err = q.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (q *QuotaByPeriodKeysServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -157,3 +173,9 @@ func (q *QuotaByPeriodKeysServerTransport) dispatchUpdate(req *http.Request) (*h } return resp, nil } + +// set this to conditionally intercept incoming requests to QuotaByPeriodKeysServerTransport +var quotaByPeriodKeysServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/region_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/region_server.go index d5ee4e4184c5..d66b5f829431 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/region_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/region_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -53,21 +50,40 @@ func (r *RegionServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "RegionClient.NewListByServicePager": - resp, err = r.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *RegionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if regionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = regionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "RegionClient.NewListByServicePager": + res.resp, res.err = r.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *RegionServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { @@ -110,3 +126,9 @@ func (r *RegionServerTransport) dispatchNewListByServicePager(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to RegionServerTransport +var regionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/reports_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/reports_server.go index bc073b26a75f..eda9af739a87 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/reports_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/reports_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -96,35 +93,54 @@ func (r *ReportsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ReportsClient.NewListByAPIPager": - resp, err = r.dispatchNewListByAPIPager(req) - case "ReportsClient.NewListByGeoPager": - resp, err = r.dispatchNewListByGeoPager(req) - case "ReportsClient.NewListByOperationPager": - resp, err = r.dispatchNewListByOperationPager(req) - case "ReportsClient.NewListByProductPager": - resp, err = r.dispatchNewListByProductPager(req) - case "ReportsClient.NewListByRequestPager": - resp, err = r.dispatchNewListByRequestPager(req) - case "ReportsClient.NewListBySubscriptionPager": - resp, err = r.dispatchNewListBySubscriptionPager(req) - case "ReportsClient.NewListByTimePager": - resp, err = r.dispatchNewListByTimePager(req) - case "ReportsClient.NewListByUserPager": - resp, err = r.dispatchNewListByUserPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ReportsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if reportsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = reportsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ReportsClient.NewListByAPIPager": + res.resp, res.err = r.dispatchNewListByAPIPager(req) + case "ReportsClient.NewListByGeoPager": + res.resp, res.err = r.dispatchNewListByGeoPager(req) + case "ReportsClient.NewListByOperationPager": + res.resp, res.err = r.dispatchNewListByOperationPager(req) + case "ReportsClient.NewListByProductPager": + res.resp, res.err = r.dispatchNewListByProductPager(req) + case "ReportsClient.NewListByRequestPager": + res.resp, res.err = r.dispatchNewListByRequestPager(req) + case "ReportsClient.NewListBySubscriptionPager": + res.resp, res.err = r.dispatchNewListBySubscriptionPager(req) + case "ReportsClient.NewListByTimePager": + res.resp, res.err = r.dispatchNewListByTimePager(req) + case "ReportsClient.NewListByUserPager": + res.resp, res.err = r.dispatchNewListByUserPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *ReportsServerTransport) dispatchNewListByAPIPager(req *http.Request) (*http.Response, error) { @@ -811,3 +827,9 @@ func (r *ReportsServerTransport) dispatchNewListByUserPager(req *http.Request) ( } return resp, nil } + +// set this to conditionally intercept incoming requests to ReportsServerTransport +var reportsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/server.go index 74d50fed6047..f082f2b78de3 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -53,21 +50,40 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "Client.BeginPerformConnectivityCheckAsync": - resp, err = s.dispatchBeginPerformConnectivityCheckAsync(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.BeginPerformConnectivityCheckAsync": + res.resp, res.err = s.dispatchBeginPerformConnectivityCheckAsync(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ServerTransport) dispatchBeginPerformConnectivityCheckAsync(req *http.Request) (*http.Response, error) { @@ -117,3 +133,9 @@ func (s *ServerTransport) dispatchBeginPerformConnectivityCheckAsync(req *http.R return resp, nil } + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/server_factory.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/server_factory.go index 4f283fee1000..cfda5f3145de 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/server_factory.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/server_factory.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -19,95 +16,416 @@ import ( // ServerFactory is a fake server for instances of the armapimanagement.ClientFactory type. type ServerFactory struct { - APIServer APIServer - APIDiagnosticServer APIDiagnosticServer - APIExportServer APIExportServer - APIIssueAttachmentServer APIIssueAttachmentServer - APIIssueServer APIIssueServer - APIIssueCommentServer APIIssueCommentServer - APIOperationServer APIOperationServer - APIOperationPolicyServer APIOperationPolicyServer - APIPolicyServer APIPolicyServer - APIProductServer APIProductServer - APIReleaseServer APIReleaseServer - APIRevisionServer APIRevisionServer - APISchemaServer APISchemaServer - APITagDescriptionServer APITagDescriptionServer - APIVersionSetServer APIVersionSetServer - APIWikiServer APIWikiServer - APIWikisServer APIWikisServer - AuthorizationAccessPolicyServer AuthorizationAccessPolicyServer - AuthorizationServer AuthorizationServer - AuthorizationLoginLinksServer AuthorizationLoginLinksServer - AuthorizationProviderServer AuthorizationProviderServer - AuthorizationServerServer AuthorizationServerServer - BackendServer BackendServer - CacheServer CacheServer - CertificateServer CertificateServer - Server Server - ContentItemServer ContentItemServer - ContentTypeServer ContentTypeServer - DelegationSettingsServer DelegationSettingsServer - DeletedServicesServer DeletedServicesServer - DiagnosticServer DiagnosticServer - DocumentationServer DocumentationServer - EmailTemplateServer EmailTemplateServer - GatewayAPIServer GatewayAPIServer - GatewayCertificateAuthorityServer GatewayCertificateAuthorityServer - GatewayServer GatewayServer - GatewayHostnameConfigurationServer GatewayHostnameConfigurationServer - GlobalSchemaServer GlobalSchemaServer - GraphQLAPIResolverServer GraphQLAPIResolverServer - GraphQLAPIResolverPolicyServer GraphQLAPIResolverPolicyServer - GroupServer GroupServer - GroupUserServer GroupUserServer - IdentityProviderServer IdentityProviderServer - IssueServer IssueServer - LoggerServer LoggerServer - NamedValueServer NamedValueServer - NetworkStatusServer NetworkStatusServer - NotificationServer NotificationServer - NotificationRecipientEmailServer NotificationRecipientEmailServer - NotificationRecipientUserServer NotificationRecipientUserServer - OpenIDConnectProviderServer OpenIDConnectProviderServer - OperationServer OperationServer - OperationsServer OperationsServer + // APIServer contains the fakes for client APIClient + APIServer APIServer + + // APIDiagnosticServer contains the fakes for client APIDiagnosticClient + APIDiagnosticServer APIDiagnosticServer + + // APIExportServer contains the fakes for client APIExportClient + APIExportServer APIExportServer + + // APIGatewayServer contains the fakes for client APIGatewayClient + APIGatewayServer APIGatewayServer + + // APIGatewayConfigConnectionServer contains the fakes for client APIGatewayConfigConnectionClient + APIGatewayConfigConnectionServer APIGatewayConfigConnectionServer + + // APIIssueAttachmentServer contains the fakes for client APIIssueAttachmentClient + APIIssueAttachmentServer APIIssueAttachmentServer + + // APIIssueServer contains the fakes for client APIIssueClient + APIIssueServer APIIssueServer + + // APIIssueCommentServer contains the fakes for client APIIssueCommentClient + APIIssueCommentServer APIIssueCommentServer + + // APIOperationServer contains the fakes for client APIOperationClient + APIOperationServer APIOperationServer + + // APIOperationPolicyServer contains the fakes for client APIOperationPolicyClient + APIOperationPolicyServer APIOperationPolicyServer + + // APIPolicyServer contains the fakes for client APIPolicyClient + APIPolicyServer APIPolicyServer + + // APIProductServer contains the fakes for client APIProductClient + APIProductServer APIProductServer + + // APIReleaseServer contains the fakes for client APIReleaseClient + APIReleaseServer APIReleaseServer + + // APIRevisionServer contains the fakes for client APIRevisionClient + APIRevisionServer APIRevisionServer + + // APISchemaServer contains the fakes for client APISchemaClient + APISchemaServer APISchemaServer + + // APITagDescriptionServer contains the fakes for client APITagDescriptionClient + APITagDescriptionServer APITagDescriptionServer + + // APIVersionSetServer contains the fakes for client APIVersionSetClient + APIVersionSetServer APIVersionSetServer + + // APIWikiServer contains the fakes for client APIWikiClient + APIWikiServer APIWikiServer + + // APIWikisServer contains the fakes for client APIWikisClient + APIWikisServer APIWikisServer + + // AllPoliciesServer contains the fakes for client AllPoliciesClient + AllPoliciesServer AllPoliciesServer + + // AuthorizationAccessPolicyServer contains the fakes for client AuthorizationAccessPolicyClient + AuthorizationAccessPolicyServer AuthorizationAccessPolicyServer + + // AuthorizationServer contains the fakes for client AuthorizationClient + AuthorizationServer AuthorizationServer + + // AuthorizationLoginLinksServer contains the fakes for client AuthorizationLoginLinksClient + AuthorizationLoginLinksServer AuthorizationLoginLinksServer + + // AuthorizationProviderServer contains the fakes for client AuthorizationProviderClient + AuthorizationProviderServer AuthorizationProviderServer + + // AuthorizationServerServer contains the fakes for client AuthorizationServerClient + AuthorizationServerServer AuthorizationServerServer + + // BackendServer contains the fakes for client BackendClient + BackendServer BackendServer + + // CacheServer contains the fakes for client CacheClient + CacheServer CacheServer + + // CertificateServer contains the fakes for client CertificateClient + CertificateServer CertificateServer + + // Server contains the fakes for client Client + Server Server + + // ContentItemServer contains the fakes for client ContentItemClient + ContentItemServer ContentItemServer + + // ContentTypeServer contains the fakes for client ContentTypeClient + ContentTypeServer ContentTypeServer + + // DelegationSettingsServer contains the fakes for client DelegationSettingsClient + DelegationSettingsServer DelegationSettingsServer + + // DeletedServicesServer contains the fakes for client DeletedServicesClient + DeletedServicesServer DeletedServicesServer + + // DiagnosticServer contains the fakes for client DiagnosticClient + DiagnosticServer DiagnosticServer + + // DocumentationServer contains the fakes for client DocumentationClient + DocumentationServer DocumentationServer + + // EmailTemplateServer contains the fakes for client EmailTemplateClient + EmailTemplateServer EmailTemplateServer + + // GatewayAPIServer contains the fakes for client GatewayAPIClient + GatewayAPIServer GatewayAPIServer + + // GatewayCertificateAuthorityServer contains the fakes for client GatewayCertificateAuthorityClient + GatewayCertificateAuthorityServer GatewayCertificateAuthorityServer + + // GatewayServer contains the fakes for client GatewayClient + GatewayServer GatewayServer + + // GatewayHostnameConfigurationServer contains the fakes for client GatewayHostnameConfigurationClient + GatewayHostnameConfigurationServer GatewayHostnameConfigurationServer + + // GatewaySKUsServer contains the fakes for client GatewaySKUsClient + GatewaySKUsServer GatewaySKUsServer + + // GlobalSchemaServer contains the fakes for client GlobalSchemaClient + GlobalSchemaServer GlobalSchemaServer + + // GraphQLAPIResolverServer contains the fakes for client GraphQLAPIResolverClient + GraphQLAPIResolverServer GraphQLAPIResolverServer + + // GraphQLAPIResolverPolicyServer contains the fakes for client GraphQLAPIResolverPolicyClient + GraphQLAPIResolverPolicyServer GraphQLAPIResolverPolicyServer + + // GroupServer contains the fakes for client GroupClient + GroupServer GroupServer + + // GroupUserServer contains the fakes for client GroupUserClient + GroupUserServer GroupUserServer + + // IdentityProviderServer contains the fakes for client IdentityProviderClient + IdentityProviderServer IdentityProviderServer + + // IssueServer contains the fakes for client IssueClient + IssueServer IssueServer + + // LoggerServer contains the fakes for client LoggerClient + LoggerServer LoggerServer + + // NamedValueServer contains the fakes for client NamedValueClient + NamedValueServer NamedValueServer + + // NetworkStatusServer contains the fakes for client NetworkStatusClient + NetworkStatusServer NetworkStatusServer + + // NotificationServer contains the fakes for client NotificationClient + NotificationServer NotificationServer + + // NotificationRecipientEmailServer contains the fakes for client NotificationRecipientEmailClient + NotificationRecipientEmailServer NotificationRecipientEmailServer + + // NotificationRecipientUserServer contains the fakes for client NotificationRecipientUserClient + NotificationRecipientUserServer NotificationRecipientUserServer + + // OpenIDConnectProviderServer contains the fakes for client OpenIDConnectProviderClient + OpenIDConnectProviderServer OpenIDConnectProviderServer + + // OperationServer contains the fakes for client OperationClient + OperationServer OperationServer + + // OperationStatusServer contains the fakes for client OperationStatusClient + OperationStatusServer OperationStatusServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // OperationsResultsServer contains the fakes for client OperationsResultsClient + OperationsResultsServer OperationsResultsServer + + // OutboundNetworkDependenciesEndpointsServer contains the fakes for client OutboundNetworkDependenciesEndpointsClient OutboundNetworkDependenciesEndpointsServer OutboundNetworkDependenciesEndpointsServer - PolicyServer PolicyServer - PolicyDescriptionServer PolicyDescriptionServer - PolicyFragmentServer PolicyFragmentServer - PortalConfigServer PortalConfigServer - PortalRevisionServer PortalRevisionServer - PortalSettingsServer PortalSettingsServer - PrivateEndpointConnectionServer PrivateEndpointConnectionServer - ProductAPIServer ProductAPIServer - ProductServer ProductServer - ProductGroupServer ProductGroupServer - ProductPolicyServer ProductPolicyServer - ProductSubscriptionsServer ProductSubscriptionsServer - ProductWikiServer ProductWikiServer - ProductWikisServer ProductWikisServer - QuotaByCounterKeysServer QuotaByCounterKeysServer - QuotaByPeriodKeysServer QuotaByPeriodKeysServer - RegionServer RegionServer - ReportsServer ReportsServer - SKUsServer SKUsServer - ServiceServer ServiceServer - ServiceSKUsServer ServiceSKUsServer - SignInSettingsServer SignInSettingsServer - SignUpSettingsServer SignUpSettingsServer - SubscriptionServer SubscriptionServer - TagServer TagServer - TagResourceServer TagResourceServer - TenantAccessServer TenantAccessServer - TenantAccessGitServer TenantAccessGitServer - TenantConfigurationServer TenantConfigurationServer - TenantSettingsServer TenantSettingsServer - UserServer UserServer - UserConfirmationPasswordServer UserConfirmationPasswordServer - UserGroupServer UserGroupServer - UserIdentitiesServer UserIdentitiesServer - UserSubscriptionServer UserSubscriptionServer + + // PolicyServer contains the fakes for client PolicyClient + PolicyServer PolicyServer + + // PolicyDescriptionServer contains the fakes for client PolicyDescriptionClient + PolicyDescriptionServer PolicyDescriptionServer + + // PolicyFragmentServer contains the fakes for client PolicyFragmentClient + PolicyFragmentServer PolicyFragmentServer + + // PolicyRestrictionServer contains the fakes for client PolicyRestrictionClient + PolicyRestrictionServer PolicyRestrictionServer + + // PolicyRestrictionValidationsServer contains the fakes for client PolicyRestrictionValidationsClient + PolicyRestrictionValidationsServer PolicyRestrictionValidationsServer + + // PortalConfigServer contains the fakes for client PortalConfigClient + PortalConfigServer PortalConfigServer + + // PortalRevisionServer contains the fakes for client PortalRevisionClient + PortalRevisionServer PortalRevisionServer + + // PortalSettingsServer contains the fakes for client PortalSettingsClient + PortalSettingsServer PortalSettingsServer + + // PrivateEndpointConnectionServer contains the fakes for client PrivateEndpointConnectionClient + PrivateEndpointConnectionServer PrivateEndpointConnectionServer + + // ProductAPIServer contains the fakes for client ProductAPIClient + ProductAPIServer ProductAPIServer + + // ProductAPILinkServer contains the fakes for client ProductAPILinkClient + ProductAPILinkServer ProductAPILinkServer + + // ProductServer contains the fakes for client ProductClient + ProductServer ProductServer + + // ProductGroupServer contains the fakes for client ProductGroupClient + ProductGroupServer ProductGroupServer + + // ProductGroupLinkServer contains the fakes for client ProductGroupLinkClient + ProductGroupLinkServer ProductGroupLinkServer + + // ProductPolicyServer contains the fakes for client ProductPolicyClient + ProductPolicyServer ProductPolicyServer + + // ProductSubscriptionsServer contains the fakes for client ProductSubscriptionsClient + ProductSubscriptionsServer ProductSubscriptionsServer + + // ProductWikiServer contains the fakes for client ProductWikiClient + ProductWikiServer ProductWikiServer + + // ProductWikisServer contains the fakes for client ProductWikisClient + ProductWikisServer ProductWikisServer + + // QuotaByCounterKeysServer contains the fakes for client QuotaByCounterKeysClient + QuotaByCounterKeysServer QuotaByCounterKeysServer + + // QuotaByPeriodKeysServer contains the fakes for client QuotaByPeriodKeysClient + QuotaByPeriodKeysServer QuotaByPeriodKeysServer + + // RegionServer contains the fakes for client RegionClient + RegionServer RegionServer + + // ReportsServer contains the fakes for client ReportsClient + ReportsServer ReportsServer + + // SKUsServer contains the fakes for client SKUsClient + SKUsServer SKUsServer + + // ServiceServer contains the fakes for client ServiceClient + ServiceServer ServiceServer + + // ServiceSKUsServer contains the fakes for client ServiceSKUsClient + ServiceSKUsServer ServiceSKUsServer + + // SignInSettingsServer contains the fakes for client SignInSettingsClient + SignInSettingsServer SignInSettingsServer + + // SignUpSettingsServer contains the fakes for client SignUpSettingsClient + SignUpSettingsServer SignUpSettingsServer + + // SubscriptionServer contains the fakes for client SubscriptionClient + SubscriptionServer SubscriptionServer + + // TagAPILinkServer contains the fakes for client TagAPILinkClient + TagAPILinkServer TagAPILinkServer + + // TagServer contains the fakes for client TagClient + TagServer TagServer + + // TagOperationLinkServer contains the fakes for client TagOperationLinkClient + TagOperationLinkServer TagOperationLinkServer + + // TagProductLinkServer contains the fakes for client TagProductLinkClient + TagProductLinkServer TagProductLinkServer + + // TagResourceServer contains the fakes for client TagResourceClient + TagResourceServer TagResourceServer + + // TenantAccessServer contains the fakes for client TenantAccessClient + TenantAccessServer TenantAccessServer + + // TenantAccessGitServer contains the fakes for client TenantAccessGitClient + TenantAccessGitServer TenantAccessGitServer + + // TenantConfigurationServer contains the fakes for client TenantConfigurationClient + TenantConfigurationServer TenantConfigurationServer + + // TenantSettingsServer contains the fakes for client TenantSettingsClient + TenantSettingsServer TenantSettingsServer + + // UserServer contains the fakes for client UserClient + UserServer UserServer + + // UserConfirmationPasswordServer contains the fakes for client UserConfirmationPasswordClient + UserConfirmationPasswordServer UserConfirmationPasswordServer + + // UserGroupServer contains the fakes for client UserGroupClient + UserGroupServer UserGroupServer + + // UserIdentitiesServer contains the fakes for client UserIdentitiesClient + UserIdentitiesServer UserIdentitiesServer + + // UserSubscriptionServer contains the fakes for client UserSubscriptionClient + UserSubscriptionServer UserSubscriptionServer + + // WorkspaceAPIServer contains the fakes for client WorkspaceAPIClient + WorkspaceAPIServer WorkspaceAPIServer + + // WorkspaceAPIDiagnosticServer contains the fakes for client WorkspaceAPIDiagnosticClient + WorkspaceAPIDiagnosticServer WorkspaceAPIDiagnosticServer + + // WorkspaceAPIExportServer contains the fakes for client WorkspaceAPIExportClient + WorkspaceAPIExportServer WorkspaceAPIExportServer + + // WorkspaceAPIOperationServer contains the fakes for client WorkspaceAPIOperationClient + WorkspaceAPIOperationServer WorkspaceAPIOperationServer + + // WorkspaceAPIOperationPolicyServer contains the fakes for client WorkspaceAPIOperationPolicyClient + WorkspaceAPIOperationPolicyServer WorkspaceAPIOperationPolicyServer + + // WorkspaceAPIPolicyServer contains the fakes for client WorkspaceAPIPolicyClient + WorkspaceAPIPolicyServer WorkspaceAPIPolicyServer + + // WorkspaceAPIReleaseServer contains the fakes for client WorkspaceAPIReleaseClient + WorkspaceAPIReleaseServer WorkspaceAPIReleaseServer + + // WorkspaceAPIRevisionServer contains the fakes for client WorkspaceAPIRevisionClient + WorkspaceAPIRevisionServer WorkspaceAPIRevisionServer + + // WorkspaceAPISchemaServer contains the fakes for client WorkspaceAPISchemaClient + WorkspaceAPISchemaServer WorkspaceAPISchemaServer + + // WorkspaceAPIVersionSetServer contains the fakes for client WorkspaceAPIVersionSetClient + WorkspaceAPIVersionSetServer WorkspaceAPIVersionSetServer + + // WorkspaceBackendServer contains the fakes for client WorkspaceBackendClient + WorkspaceBackendServer WorkspaceBackendServer + + // WorkspaceCertificateServer contains the fakes for client WorkspaceCertificateClient + WorkspaceCertificateServer WorkspaceCertificateServer + + // WorkspaceServer contains the fakes for client WorkspaceClient + WorkspaceServer WorkspaceServer + + // WorkspaceDiagnosticServer contains the fakes for client WorkspaceDiagnosticClient + WorkspaceDiagnosticServer WorkspaceDiagnosticServer + + // WorkspaceGlobalSchemaServer contains the fakes for client WorkspaceGlobalSchemaClient + WorkspaceGlobalSchemaServer WorkspaceGlobalSchemaServer + + // WorkspaceGroupServer contains the fakes for client WorkspaceGroupClient + WorkspaceGroupServer WorkspaceGroupServer + + // WorkspaceGroupUserServer contains the fakes for client WorkspaceGroupUserClient + WorkspaceGroupUserServer WorkspaceGroupUserServer + + // WorkspaceLinkServer contains the fakes for client WorkspaceLinkClient + WorkspaceLinkServer WorkspaceLinkServer + + // WorkspaceLinksServer contains the fakes for client WorkspaceLinksClient + WorkspaceLinksServer WorkspaceLinksServer + + // WorkspaceLoggerServer contains the fakes for client WorkspaceLoggerClient + WorkspaceLoggerServer WorkspaceLoggerServer + + // WorkspaceNamedValueServer contains the fakes for client WorkspaceNamedValueClient + WorkspaceNamedValueServer WorkspaceNamedValueServer + + // WorkspaceNotificationServer contains the fakes for client WorkspaceNotificationClient + WorkspaceNotificationServer WorkspaceNotificationServer + + // WorkspaceNotificationRecipientEmailServer contains the fakes for client WorkspaceNotificationRecipientEmailClient + WorkspaceNotificationRecipientEmailServer WorkspaceNotificationRecipientEmailServer + + // WorkspaceNotificationRecipientUserServer contains the fakes for client WorkspaceNotificationRecipientUserClient + WorkspaceNotificationRecipientUserServer WorkspaceNotificationRecipientUserServer + + // WorkspacePolicyServer contains the fakes for client WorkspacePolicyClient + WorkspacePolicyServer WorkspacePolicyServer + + // WorkspacePolicyFragmentServer contains the fakes for client WorkspacePolicyFragmentClient + WorkspacePolicyFragmentServer WorkspacePolicyFragmentServer + + // WorkspaceProductAPILinkServer contains the fakes for client WorkspaceProductAPILinkClient + WorkspaceProductAPILinkServer WorkspaceProductAPILinkServer + + // WorkspaceProductServer contains the fakes for client WorkspaceProductClient + WorkspaceProductServer WorkspaceProductServer + + // WorkspaceProductGroupLinkServer contains the fakes for client WorkspaceProductGroupLinkClient + WorkspaceProductGroupLinkServer WorkspaceProductGroupLinkServer + + // WorkspaceProductPolicyServer contains the fakes for client WorkspaceProductPolicyClient + WorkspaceProductPolicyServer WorkspaceProductPolicyServer + + // WorkspaceSubscriptionServer contains the fakes for client WorkspaceSubscriptionClient + WorkspaceSubscriptionServer WorkspaceSubscriptionServer + + // WorkspaceTagAPILinkServer contains the fakes for client WorkspaceTagAPILinkClient + WorkspaceTagAPILinkServer WorkspaceTagAPILinkServer + + // WorkspaceTagServer contains the fakes for client WorkspaceTagClient + WorkspaceTagServer WorkspaceTagServer + + // WorkspaceTagOperationLinkServer contains the fakes for client WorkspaceTagOperationLinkClient + WorkspaceTagOperationLinkServer WorkspaceTagOperationLinkServer + + // WorkspaceTagProductLinkServer contains the fakes for client WorkspaceTagProductLinkClient + WorkspaceTagProductLinkServer WorkspaceTagProductLinkServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -127,6 +445,8 @@ type ServerFactoryTransport struct { trAPIServer *APIServerTransport trAPIDiagnosticServer *APIDiagnosticServerTransport trAPIExportServer *APIExportServerTransport + trAPIGatewayServer *APIGatewayServerTransport + trAPIGatewayConfigConnectionServer *APIGatewayConfigConnectionServerTransport trAPIIssueAttachmentServer *APIIssueAttachmentServerTransport trAPIIssueServer *APIIssueServerTransport trAPIIssueCommentServer *APIIssueCommentServerTransport @@ -141,6 +461,7 @@ type ServerFactoryTransport struct { trAPIVersionSetServer *APIVersionSetServerTransport trAPIWikiServer *APIWikiServerTransport trAPIWikisServer *APIWikisServerTransport + trAllPoliciesServer *AllPoliciesServerTransport trAuthorizationAccessPolicyServer *AuthorizationAccessPolicyServerTransport trAuthorizationServer *AuthorizationServerTransport trAuthorizationLoginLinksServer *AuthorizationLoginLinksServerTransport @@ -161,6 +482,7 @@ type ServerFactoryTransport struct { trGatewayCertificateAuthorityServer *GatewayCertificateAuthorityServerTransport trGatewayServer *GatewayServerTransport trGatewayHostnameConfigurationServer *GatewayHostnameConfigurationServerTransport + trGatewaySKUsServer *GatewaySKUsServerTransport trGlobalSchemaServer *GlobalSchemaServerTransport trGraphQLAPIResolverServer *GraphQLAPIResolverServerTransport trGraphQLAPIResolverPolicyServer *GraphQLAPIResolverPolicyServerTransport @@ -176,18 +498,24 @@ type ServerFactoryTransport struct { trNotificationRecipientUserServer *NotificationRecipientUserServerTransport trOpenIDConnectProviderServer *OpenIDConnectProviderServerTransport trOperationServer *OperationServerTransport + trOperationStatusServer *OperationStatusServerTransport trOperationsServer *OperationsServerTransport + trOperationsResultsServer *OperationsResultsServerTransport trOutboundNetworkDependenciesEndpointsServer *OutboundNetworkDependenciesEndpointsServerTransport trPolicyServer *PolicyServerTransport trPolicyDescriptionServer *PolicyDescriptionServerTransport trPolicyFragmentServer *PolicyFragmentServerTransport + trPolicyRestrictionServer *PolicyRestrictionServerTransport + trPolicyRestrictionValidationsServer *PolicyRestrictionValidationsServerTransport trPortalConfigServer *PortalConfigServerTransport trPortalRevisionServer *PortalRevisionServerTransport trPortalSettingsServer *PortalSettingsServerTransport trPrivateEndpointConnectionServer *PrivateEndpointConnectionServerTransport trProductAPIServer *ProductAPIServerTransport + trProductAPILinkServer *ProductAPILinkServerTransport trProductServer *ProductServerTransport trProductGroupServer *ProductGroupServerTransport + trProductGroupLinkServer *ProductGroupLinkServerTransport trProductPolicyServer *ProductPolicyServerTransport trProductSubscriptionsServer *ProductSubscriptionsServerTransport trProductWikiServer *ProductWikiServerTransport @@ -202,7 +530,10 @@ type ServerFactoryTransport struct { trSignInSettingsServer *SignInSettingsServerTransport trSignUpSettingsServer *SignUpSettingsServerTransport trSubscriptionServer *SubscriptionServerTransport + trTagAPILinkServer *TagAPILinkServerTransport trTagServer *TagServerTransport + trTagOperationLinkServer *TagOperationLinkServerTransport + trTagProductLinkServer *TagProductLinkServerTransport trTagResourceServer *TagResourceServerTransport trTenantAccessServer *TenantAccessServerTransport trTenantAccessGitServer *TenantAccessGitServerTransport @@ -213,6 +544,41 @@ type ServerFactoryTransport struct { trUserGroupServer *UserGroupServerTransport trUserIdentitiesServer *UserIdentitiesServerTransport trUserSubscriptionServer *UserSubscriptionServerTransport + trWorkspaceAPIServer *WorkspaceAPIServerTransport + trWorkspaceAPIDiagnosticServer *WorkspaceAPIDiagnosticServerTransport + trWorkspaceAPIExportServer *WorkspaceAPIExportServerTransport + trWorkspaceAPIOperationServer *WorkspaceAPIOperationServerTransport + trWorkspaceAPIOperationPolicyServer *WorkspaceAPIOperationPolicyServerTransport + trWorkspaceAPIPolicyServer *WorkspaceAPIPolicyServerTransport + trWorkspaceAPIReleaseServer *WorkspaceAPIReleaseServerTransport + trWorkspaceAPIRevisionServer *WorkspaceAPIRevisionServerTransport + trWorkspaceAPISchemaServer *WorkspaceAPISchemaServerTransport + trWorkspaceAPIVersionSetServer *WorkspaceAPIVersionSetServerTransport + trWorkspaceBackendServer *WorkspaceBackendServerTransport + trWorkspaceCertificateServer *WorkspaceCertificateServerTransport + trWorkspaceServer *WorkspaceServerTransport + trWorkspaceDiagnosticServer *WorkspaceDiagnosticServerTransport + trWorkspaceGlobalSchemaServer *WorkspaceGlobalSchemaServerTransport + trWorkspaceGroupServer *WorkspaceGroupServerTransport + trWorkspaceGroupUserServer *WorkspaceGroupUserServerTransport + trWorkspaceLinkServer *WorkspaceLinkServerTransport + trWorkspaceLinksServer *WorkspaceLinksServerTransport + trWorkspaceLoggerServer *WorkspaceLoggerServerTransport + trWorkspaceNamedValueServer *WorkspaceNamedValueServerTransport + trWorkspaceNotificationServer *WorkspaceNotificationServerTransport + trWorkspaceNotificationRecipientEmailServer *WorkspaceNotificationRecipientEmailServerTransport + trWorkspaceNotificationRecipientUserServer *WorkspaceNotificationRecipientUserServerTransport + trWorkspacePolicyServer *WorkspacePolicyServerTransport + trWorkspacePolicyFragmentServer *WorkspacePolicyFragmentServerTransport + trWorkspaceProductAPILinkServer *WorkspaceProductAPILinkServerTransport + trWorkspaceProductServer *WorkspaceProductServerTransport + trWorkspaceProductGroupLinkServer *WorkspaceProductGroupLinkServerTransport + trWorkspaceProductPolicyServer *WorkspaceProductPolicyServerTransport + trWorkspaceSubscriptionServer *WorkspaceSubscriptionServerTransport + trWorkspaceTagAPILinkServer *WorkspaceTagAPILinkServerTransport + trWorkspaceTagServer *WorkspaceTagServerTransport + trWorkspaceTagOperationLinkServer *WorkspaceTagOperationLinkServerTransport + trWorkspaceTagProductLinkServer *WorkspaceTagProductLinkServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -239,6 +605,14 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "APIExportClient": initServer(s, &s.trAPIExportServer, func() *APIExportServerTransport { return NewAPIExportServerTransport(&s.srv.APIExportServer) }) resp, err = s.trAPIExportServer.Do(req) + case "APIGatewayClient": + initServer(s, &s.trAPIGatewayServer, func() *APIGatewayServerTransport { return NewAPIGatewayServerTransport(&s.srv.APIGatewayServer) }) + resp, err = s.trAPIGatewayServer.Do(req) + case "APIGatewayConfigConnectionClient": + initServer(s, &s.trAPIGatewayConfigConnectionServer, func() *APIGatewayConfigConnectionServerTransport { + return NewAPIGatewayConfigConnectionServerTransport(&s.srv.APIGatewayConfigConnectionServer) + }) + resp, err = s.trAPIGatewayConfigConnectionServer.Do(req) case "APIIssueAttachmentClient": initServer(s, &s.trAPIIssueAttachmentServer, func() *APIIssueAttachmentServerTransport { return NewAPIIssueAttachmentServerTransport(&s.srv.APIIssueAttachmentServer) @@ -291,6 +665,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "APIWikisClient": initServer(s, &s.trAPIWikisServer, func() *APIWikisServerTransport { return NewAPIWikisServerTransport(&s.srv.APIWikisServer) }) resp, err = s.trAPIWikisServer.Do(req) + case "AllPoliciesClient": + initServer(s, &s.trAllPoliciesServer, func() *AllPoliciesServerTransport { return NewAllPoliciesServerTransport(&s.srv.AllPoliciesServer) }) + resp, err = s.trAllPoliciesServer.Do(req) case "AuthorizationAccessPolicyClient": initServer(s, &s.trAuthorizationAccessPolicyServer, func() *AuthorizationAccessPolicyServerTransport { return NewAuthorizationAccessPolicyServerTransport(&s.srv.AuthorizationAccessPolicyServer) @@ -373,6 +750,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewGatewayHostnameConfigurationServerTransport(&s.srv.GatewayHostnameConfigurationServer) }) resp, err = s.trGatewayHostnameConfigurationServer.Do(req) + case "GatewaySKUsClient": + initServer(s, &s.trGatewaySKUsServer, func() *GatewaySKUsServerTransport { return NewGatewaySKUsServerTransport(&s.srv.GatewaySKUsServer) }) + resp, err = s.trGatewaySKUsServer.Do(req) case "GlobalSchemaClient": initServer(s, &s.trGlobalSchemaServer, func() *GlobalSchemaServerTransport { return NewGlobalSchemaServerTransport(&s.srv.GlobalSchemaServer) }) resp, err = s.trGlobalSchemaServer.Do(req) @@ -432,9 +812,19 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "OperationClient": initServer(s, &s.trOperationServer, func() *OperationServerTransport { return NewOperationServerTransport(&s.srv.OperationServer) }) resp, err = s.trOperationServer.Do(req) + case "OperationStatusClient": + initServer(s, &s.trOperationStatusServer, func() *OperationStatusServerTransport { + return NewOperationStatusServerTransport(&s.srv.OperationStatusServer) + }) + resp, err = s.trOperationStatusServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) + case "OperationsResultsClient": + initServer(s, &s.trOperationsResultsServer, func() *OperationsResultsServerTransport { + return NewOperationsResultsServerTransport(&s.srv.OperationsResultsServer) + }) + resp, err = s.trOperationsResultsServer.Do(req) case "OutboundNetworkDependenciesEndpointsClient": initServer(s, &s.trOutboundNetworkDependenciesEndpointsServer, func() *OutboundNetworkDependenciesEndpointsServerTransport { return NewOutboundNetworkDependenciesEndpointsServerTransport(&s.srv.OutboundNetworkDependenciesEndpointsServer) @@ -453,6 +843,16 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewPolicyFragmentServerTransport(&s.srv.PolicyFragmentServer) }) resp, err = s.trPolicyFragmentServer.Do(req) + case "PolicyRestrictionClient": + initServer(s, &s.trPolicyRestrictionServer, func() *PolicyRestrictionServerTransport { + return NewPolicyRestrictionServerTransport(&s.srv.PolicyRestrictionServer) + }) + resp, err = s.trPolicyRestrictionServer.Do(req) + case "PolicyRestrictionValidationsClient": + initServer(s, &s.trPolicyRestrictionValidationsServer, func() *PolicyRestrictionValidationsServerTransport { + return NewPolicyRestrictionValidationsServerTransport(&s.srv.PolicyRestrictionValidationsServer) + }) + resp, err = s.trPolicyRestrictionValidationsServer.Do(req) case "PortalConfigClient": initServer(s, &s.trPortalConfigServer, func() *PortalConfigServerTransport { return NewPortalConfigServerTransport(&s.srv.PortalConfigServer) }) resp, err = s.trPortalConfigServer.Do(req) @@ -474,12 +874,22 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "ProductAPIClient": initServer(s, &s.trProductAPIServer, func() *ProductAPIServerTransport { return NewProductAPIServerTransport(&s.srv.ProductAPIServer) }) resp, err = s.trProductAPIServer.Do(req) + case "ProductAPILinkClient": + initServer(s, &s.trProductAPILinkServer, func() *ProductAPILinkServerTransport { + return NewProductAPILinkServerTransport(&s.srv.ProductAPILinkServer) + }) + resp, err = s.trProductAPILinkServer.Do(req) case "ProductClient": initServer(s, &s.trProductServer, func() *ProductServerTransport { return NewProductServerTransport(&s.srv.ProductServer) }) resp, err = s.trProductServer.Do(req) case "ProductGroupClient": initServer(s, &s.trProductGroupServer, func() *ProductGroupServerTransport { return NewProductGroupServerTransport(&s.srv.ProductGroupServer) }) resp, err = s.trProductGroupServer.Do(req) + case "ProductGroupLinkClient": + initServer(s, &s.trProductGroupLinkServer, func() *ProductGroupLinkServerTransport { + return NewProductGroupLinkServerTransport(&s.srv.ProductGroupLinkServer) + }) + resp, err = s.trProductGroupLinkServer.Do(req) case "ProductPolicyClient": initServer(s, &s.trProductPolicyServer, func() *ProductPolicyServerTransport { return NewProductPolicyServerTransport(&s.srv.ProductPolicyServer) @@ -534,9 +944,22 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "SubscriptionClient": initServer(s, &s.trSubscriptionServer, func() *SubscriptionServerTransport { return NewSubscriptionServerTransport(&s.srv.SubscriptionServer) }) resp, err = s.trSubscriptionServer.Do(req) + case "TagAPILinkClient": + initServer(s, &s.trTagAPILinkServer, func() *TagAPILinkServerTransport { return NewTagAPILinkServerTransport(&s.srv.TagAPILinkServer) }) + resp, err = s.trTagAPILinkServer.Do(req) case "TagClient": initServer(s, &s.trTagServer, func() *TagServerTransport { return NewTagServerTransport(&s.srv.TagServer) }) resp, err = s.trTagServer.Do(req) + case "TagOperationLinkClient": + initServer(s, &s.trTagOperationLinkServer, func() *TagOperationLinkServerTransport { + return NewTagOperationLinkServerTransport(&s.srv.TagOperationLinkServer) + }) + resp, err = s.trTagOperationLinkServer.Do(req) + case "TagProductLinkClient": + initServer(s, &s.trTagProductLinkServer, func() *TagProductLinkServerTransport { + return NewTagProductLinkServerTransport(&s.srv.TagProductLinkServer) + }) + resp, err = s.trTagProductLinkServer.Do(req) case "TagResourceClient": initServer(s, &s.trTagResourceServer, func() *TagResourceServerTransport { return NewTagResourceServerTransport(&s.srv.TagResourceServer) }) resp, err = s.trTagResourceServer.Do(req) @@ -579,6 +1002,175 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewUserSubscriptionServerTransport(&s.srv.UserSubscriptionServer) }) resp, err = s.trUserSubscriptionServer.Do(req) + case "WorkspaceAPIClient": + initServer(s, &s.trWorkspaceAPIServer, func() *WorkspaceAPIServerTransport { return NewWorkspaceAPIServerTransport(&s.srv.WorkspaceAPIServer) }) + resp, err = s.trWorkspaceAPIServer.Do(req) + case "WorkspaceAPIDiagnosticClient": + initServer(s, &s.trWorkspaceAPIDiagnosticServer, func() *WorkspaceAPIDiagnosticServerTransport { + return NewWorkspaceAPIDiagnosticServerTransport(&s.srv.WorkspaceAPIDiagnosticServer) + }) + resp, err = s.trWorkspaceAPIDiagnosticServer.Do(req) + case "WorkspaceAPIExportClient": + initServer(s, &s.trWorkspaceAPIExportServer, func() *WorkspaceAPIExportServerTransport { + return NewWorkspaceAPIExportServerTransport(&s.srv.WorkspaceAPIExportServer) + }) + resp, err = s.trWorkspaceAPIExportServer.Do(req) + case "WorkspaceAPIOperationClient": + initServer(s, &s.trWorkspaceAPIOperationServer, func() *WorkspaceAPIOperationServerTransport { + return NewWorkspaceAPIOperationServerTransport(&s.srv.WorkspaceAPIOperationServer) + }) + resp, err = s.trWorkspaceAPIOperationServer.Do(req) + case "WorkspaceAPIOperationPolicyClient": + initServer(s, &s.trWorkspaceAPIOperationPolicyServer, func() *WorkspaceAPIOperationPolicyServerTransport { + return NewWorkspaceAPIOperationPolicyServerTransport(&s.srv.WorkspaceAPIOperationPolicyServer) + }) + resp, err = s.trWorkspaceAPIOperationPolicyServer.Do(req) + case "WorkspaceAPIPolicyClient": + initServer(s, &s.trWorkspaceAPIPolicyServer, func() *WorkspaceAPIPolicyServerTransport { + return NewWorkspaceAPIPolicyServerTransport(&s.srv.WorkspaceAPIPolicyServer) + }) + resp, err = s.trWorkspaceAPIPolicyServer.Do(req) + case "WorkspaceAPIReleaseClient": + initServer(s, &s.trWorkspaceAPIReleaseServer, func() *WorkspaceAPIReleaseServerTransport { + return NewWorkspaceAPIReleaseServerTransport(&s.srv.WorkspaceAPIReleaseServer) + }) + resp, err = s.trWorkspaceAPIReleaseServer.Do(req) + case "WorkspaceAPIRevisionClient": + initServer(s, &s.trWorkspaceAPIRevisionServer, func() *WorkspaceAPIRevisionServerTransport { + return NewWorkspaceAPIRevisionServerTransport(&s.srv.WorkspaceAPIRevisionServer) + }) + resp, err = s.trWorkspaceAPIRevisionServer.Do(req) + case "WorkspaceAPISchemaClient": + initServer(s, &s.trWorkspaceAPISchemaServer, func() *WorkspaceAPISchemaServerTransport { + return NewWorkspaceAPISchemaServerTransport(&s.srv.WorkspaceAPISchemaServer) + }) + resp, err = s.trWorkspaceAPISchemaServer.Do(req) + case "WorkspaceAPIVersionSetClient": + initServer(s, &s.trWorkspaceAPIVersionSetServer, func() *WorkspaceAPIVersionSetServerTransport { + return NewWorkspaceAPIVersionSetServerTransport(&s.srv.WorkspaceAPIVersionSetServer) + }) + resp, err = s.trWorkspaceAPIVersionSetServer.Do(req) + case "WorkspaceBackendClient": + initServer(s, &s.trWorkspaceBackendServer, func() *WorkspaceBackendServerTransport { + return NewWorkspaceBackendServerTransport(&s.srv.WorkspaceBackendServer) + }) + resp, err = s.trWorkspaceBackendServer.Do(req) + case "WorkspaceCertificateClient": + initServer(s, &s.trWorkspaceCertificateServer, func() *WorkspaceCertificateServerTransport { + return NewWorkspaceCertificateServerTransport(&s.srv.WorkspaceCertificateServer) + }) + resp, err = s.trWorkspaceCertificateServer.Do(req) + case "WorkspaceClient": + initServer(s, &s.trWorkspaceServer, func() *WorkspaceServerTransport { return NewWorkspaceServerTransport(&s.srv.WorkspaceServer) }) + resp, err = s.trWorkspaceServer.Do(req) + case "WorkspaceDiagnosticClient": + initServer(s, &s.trWorkspaceDiagnosticServer, func() *WorkspaceDiagnosticServerTransport { + return NewWorkspaceDiagnosticServerTransport(&s.srv.WorkspaceDiagnosticServer) + }) + resp, err = s.trWorkspaceDiagnosticServer.Do(req) + case "WorkspaceGlobalSchemaClient": + initServer(s, &s.trWorkspaceGlobalSchemaServer, func() *WorkspaceGlobalSchemaServerTransport { + return NewWorkspaceGlobalSchemaServerTransport(&s.srv.WorkspaceGlobalSchemaServer) + }) + resp, err = s.trWorkspaceGlobalSchemaServer.Do(req) + case "WorkspaceGroupClient": + initServer(s, &s.trWorkspaceGroupServer, func() *WorkspaceGroupServerTransport { + return NewWorkspaceGroupServerTransport(&s.srv.WorkspaceGroupServer) + }) + resp, err = s.trWorkspaceGroupServer.Do(req) + case "WorkspaceGroupUserClient": + initServer(s, &s.trWorkspaceGroupUserServer, func() *WorkspaceGroupUserServerTransport { + return NewWorkspaceGroupUserServerTransport(&s.srv.WorkspaceGroupUserServer) + }) + resp, err = s.trWorkspaceGroupUserServer.Do(req) + case "WorkspaceLinkClient": + initServer(s, &s.trWorkspaceLinkServer, func() *WorkspaceLinkServerTransport { + return NewWorkspaceLinkServerTransport(&s.srv.WorkspaceLinkServer) + }) + resp, err = s.trWorkspaceLinkServer.Do(req) + case "WorkspaceLinksClient": + initServer(s, &s.trWorkspaceLinksServer, func() *WorkspaceLinksServerTransport { + return NewWorkspaceLinksServerTransport(&s.srv.WorkspaceLinksServer) + }) + resp, err = s.trWorkspaceLinksServer.Do(req) + case "WorkspaceLoggerClient": + initServer(s, &s.trWorkspaceLoggerServer, func() *WorkspaceLoggerServerTransport { + return NewWorkspaceLoggerServerTransport(&s.srv.WorkspaceLoggerServer) + }) + resp, err = s.trWorkspaceLoggerServer.Do(req) + case "WorkspaceNamedValueClient": + initServer(s, &s.trWorkspaceNamedValueServer, func() *WorkspaceNamedValueServerTransport { + return NewWorkspaceNamedValueServerTransport(&s.srv.WorkspaceNamedValueServer) + }) + resp, err = s.trWorkspaceNamedValueServer.Do(req) + case "WorkspaceNotificationClient": + initServer(s, &s.trWorkspaceNotificationServer, func() *WorkspaceNotificationServerTransport { + return NewWorkspaceNotificationServerTransport(&s.srv.WorkspaceNotificationServer) + }) + resp, err = s.trWorkspaceNotificationServer.Do(req) + case "WorkspaceNotificationRecipientEmailClient": + initServer(s, &s.trWorkspaceNotificationRecipientEmailServer, func() *WorkspaceNotificationRecipientEmailServerTransport { + return NewWorkspaceNotificationRecipientEmailServerTransport(&s.srv.WorkspaceNotificationRecipientEmailServer) + }) + resp, err = s.trWorkspaceNotificationRecipientEmailServer.Do(req) + case "WorkspaceNotificationRecipientUserClient": + initServer(s, &s.trWorkspaceNotificationRecipientUserServer, func() *WorkspaceNotificationRecipientUserServerTransport { + return NewWorkspaceNotificationRecipientUserServerTransport(&s.srv.WorkspaceNotificationRecipientUserServer) + }) + resp, err = s.trWorkspaceNotificationRecipientUserServer.Do(req) + case "WorkspacePolicyClient": + initServer(s, &s.trWorkspacePolicyServer, func() *WorkspacePolicyServerTransport { + return NewWorkspacePolicyServerTransport(&s.srv.WorkspacePolicyServer) + }) + resp, err = s.trWorkspacePolicyServer.Do(req) + case "WorkspacePolicyFragmentClient": + initServer(s, &s.trWorkspacePolicyFragmentServer, func() *WorkspacePolicyFragmentServerTransport { + return NewWorkspacePolicyFragmentServerTransport(&s.srv.WorkspacePolicyFragmentServer) + }) + resp, err = s.trWorkspacePolicyFragmentServer.Do(req) + case "WorkspaceProductAPILinkClient": + initServer(s, &s.trWorkspaceProductAPILinkServer, func() *WorkspaceProductAPILinkServerTransport { + return NewWorkspaceProductAPILinkServerTransport(&s.srv.WorkspaceProductAPILinkServer) + }) + resp, err = s.trWorkspaceProductAPILinkServer.Do(req) + case "WorkspaceProductClient": + initServer(s, &s.trWorkspaceProductServer, func() *WorkspaceProductServerTransport { + return NewWorkspaceProductServerTransport(&s.srv.WorkspaceProductServer) + }) + resp, err = s.trWorkspaceProductServer.Do(req) + case "WorkspaceProductGroupLinkClient": + initServer(s, &s.trWorkspaceProductGroupLinkServer, func() *WorkspaceProductGroupLinkServerTransport { + return NewWorkspaceProductGroupLinkServerTransport(&s.srv.WorkspaceProductGroupLinkServer) + }) + resp, err = s.trWorkspaceProductGroupLinkServer.Do(req) + case "WorkspaceProductPolicyClient": + initServer(s, &s.trWorkspaceProductPolicyServer, func() *WorkspaceProductPolicyServerTransport { + return NewWorkspaceProductPolicyServerTransport(&s.srv.WorkspaceProductPolicyServer) + }) + resp, err = s.trWorkspaceProductPolicyServer.Do(req) + case "WorkspaceSubscriptionClient": + initServer(s, &s.trWorkspaceSubscriptionServer, func() *WorkspaceSubscriptionServerTransport { + return NewWorkspaceSubscriptionServerTransport(&s.srv.WorkspaceSubscriptionServer) + }) + resp, err = s.trWorkspaceSubscriptionServer.Do(req) + case "WorkspaceTagAPILinkClient": + initServer(s, &s.trWorkspaceTagAPILinkServer, func() *WorkspaceTagAPILinkServerTransport { + return NewWorkspaceTagAPILinkServerTransport(&s.srv.WorkspaceTagAPILinkServer) + }) + resp, err = s.trWorkspaceTagAPILinkServer.Do(req) + case "WorkspaceTagClient": + initServer(s, &s.trWorkspaceTagServer, func() *WorkspaceTagServerTransport { return NewWorkspaceTagServerTransport(&s.srv.WorkspaceTagServer) }) + resp, err = s.trWorkspaceTagServer.Do(req) + case "WorkspaceTagOperationLinkClient": + initServer(s, &s.trWorkspaceTagOperationLinkServer, func() *WorkspaceTagOperationLinkServerTransport { + return NewWorkspaceTagOperationLinkServerTransport(&s.srv.WorkspaceTagOperationLinkServer) + }) + resp, err = s.trWorkspaceTagOperationLinkServer.Do(req) + case "WorkspaceTagProductLinkClient": + initServer(s, &s.trWorkspaceTagProductLinkServer, func() *WorkspaceTagProductLinkServerTransport { + return NewWorkspaceTagProductLinkServerTransport(&s.srv.WorkspaceTagProductLinkServer) + }) + resp, err = s.trWorkspaceTagProductLinkServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/service_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/service_server.go index 3bb7ee16fbfe..305b63570727 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/service_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/service_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "reflect" @@ -119,45 +116,64 @@ func (s *ServiceServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "ServiceClient.BeginApplyNetworkConfigurationUpdates": - resp, err = s.dispatchBeginApplyNetworkConfigurationUpdates(req) - case "ServiceClient.BeginBackup": - resp, err = s.dispatchBeginBackup(req) - case "ServiceClient.CheckNameAvailability": - resp, err = s.dispatchCheckNameAvailability(req) - case "ServiceClient.BeginCreateOrUpdate": - resp, err = s.dispatchBeginCreateOrUpdate(req) - case "ServiceClient.BeginDelete": - resp, err = s.dispatchBeginDelete(req) - case "ServiceClient.Get": - resp, err = s.dispatchGet(req) - case "ServiceClient.GetDomainOwnershipIdentifier": - resp, err = s.dispatchGetDomainOwnershipIdentifier(req) - case "ServiceClient.GetSsoToken": - resp, err = s.dispatchGetSsoToken(req) - case "ServiceClient.NewListPager": - resp, err = s.dispatchNewListPager(req) - case "ServiceClient.NewListByResourceGroupPager": - resp, err = s.dispatchNewListByResourceGroupPager(req) - case "ServiceClient.BeginMigrateToStv2": - resp, err = s.dispatchBeginMigrateToStv2(req) - case "ServiceClient.BeginRestore": - resp, err = s.dispatchBeginRestore(req) - case "ServiceClient.BeginUpdate": - resp, err = s.dispatchBeginUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return s.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (s *ServiceServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serviceServerTransportInterceptor != nil { + res.resp, res.err, intercepted = serviceServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ServiceClient.BeginApplyNetworkConfigurationUpdates": + res.resp, res.err = s.dispatchBeginApplyNetworkConfigurationUpdates(req) + case "ServiceClient.BeginBackup": + res.resp, res.err = s.dispatchBeginBackup(req) + case "ServiceClient.CheckNameAvailability": + res.resp, res.err = s.dispatchCheckNameAvailability(req) + case "ServiceClient.BeginCreateOrUpdate": + res.resp, res.err = s.dispatchBeginCreateOrUpdate(req) + case "ServiceClient.BeginDelete": + res.resp, res.err = s.dispatchBeginDelete(req) + case "ServiceClient.Get": + res.resp, res.err = s.dispatchGet(req) + case "ServiceClient.GetDomainOwnershipIdentifier": + res.resp, res.err = s.dispatchGetDomainOwnershipIdentifier(req) + case "ServiceClient.GetSsoToken": + res.resp, res.err = s.dispatchGetSsoToken(req) + case "ServiceClient.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "ServiceClient.NewListByResourceGroupPager": + res.resp, res.err = s.dispatchNewListByResourceGroupPager(req) + case "ServiceClient.BeginMigrateToStv2": + res.resp, res.err = s.dispatchBeginMigrateToStv2(req) + case "ServiceClient.BeginRestore": + res.resp, res.err = s.dispatchBeginRestore(req) + case "ServiceClient.BeginUpdate": + res.resp, res.err = s.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ServiceServerTransport) dispatchBeginApplyNetworkConfigurationUpdates(req *http.Request) (*http.Response, error) { @@ -556,6 +572,10 @@ func (s *ServiceServerTransport) dispatchBeginMigrateToStv2(req *http.Request) ( if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.MigrateToStv2Contract](req) + if err != nil { + return nil, err + } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err @@ -564,7 +584,13 @@ func (s *ServiceServerTransport) dispatchBeginMigrateToStv2(req *http.Request) ( if err != nil { return nil, err } - respr, errRespr := s.srv.BeginMigrateToStv2(req.Context(), resourceGroupNameParam, serviceNameParam, nil) + var options *armapimanagement.ServiceClientBeginMigrateToStv2Options + if !reflect.ValueOf(body).IsZero() { + options = &armapimanagement.ServiceClientBeginMigrateToStv2Options{ + Parameters: &body, + } + } + respr, errRespr := s.srv.BeginMigrateToStv2(req.Context(), resourceGroupNameParam, serviceNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -683,3 +709,9 @@ func (s *ServiceServerTransport) dispatchBeginUpdate(req *http.Request) (*http.R return resp, nil } + +// set this to conditionally intercept incoming requests to ServiceServerTransport +var serviceServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/serviceskus_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/serviceskus_server.go index f2368fff3a25..b6ba4f7f7685 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/serviceskus_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/serviceskus_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -53,21 +50,40 @@ func (s *ServiceSKUsServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "ServiceSKUsClient.NewListAvailableServiceSKUsPager": - resp, err = s.dispatchNewListAvailableServiceSKUsPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *ServiceSKUsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if serviceSkUsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = serviceSkUsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ServiceSKUsClient.NewListAvailableServiceSKUsPager": + res.resp, res.err = s.dispatchNewListAvailableServiceSKUsPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ServiceSKUsServerTransport) dispatchNewListAvailableServiceSKUsPager(req *http.Request) (*http.Response, error) { @@ -110,3 +126,9 @@ func (s *ServiceSKUsServerTransport) dispatchNewListAvailableServiceSKUsPager(re } return resp, nil } + +// set this to conditionally intercept incoming requests to ServiceSKUsServerTransport +var serviceSkUsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/signinsettings_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/signinsettings_server.go index c25ad29e49b2..5349e7dc10b9 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/signinsettings_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/signinsettings_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -61,27 +58,46 @@ func (s *SignInSettingsServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SignInSettingsClient.CreateOrUpdate": - resp, err = s.dispatchCreateOrUpdate(req) - case "SignInSettingsClient.Get": - resp, err = s.dispatchGet(req) - case "SignInSettingsClient.GetEntityTag": - resp, err = s.dispatchGetEntityTag(req) - case "SignInSettingsClient.Update": - resp, err = s.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SignInSettingsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if signInSettingsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = signInSettingsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SignInSettingsClient.CreateOrUpdate": + res.resp, res.err = s.dispatchCreateOrUpdate(req) + case "SignInSettingsClient.Get": + res.resp, res.err = s.dispatchGet(req) + case "SignInSettingsClient.GetEntityTag": + res.resp, res.err = s.dispatchGetEntityTag(req) + case "SignInSettingsClient.Update": + res.resp, res.err = s.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SignInSettingsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -236,3 +252,9 @@ func (s *SignInSettingsServerTransport) dispatchUpdate(req *http.Request) (*http } return resp, nil } + +// set this to conditionally intercept incoming requests to SignInSettingsServerTransport +var signInSettingsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/signupsettings_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/signupsettings_server.go index 4a9da8fcd1d1..47cd93a4a1cd 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/signupsettings_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/signupsettings_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -61,27 +58,46 @@ func (s *SignUpSettingsServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SignUpSettingsClient.CreateOrUpdate": - resp, err = s.dispatchCreateOrUpdate(req) - case "SignUpSettingsClient.Get": - resp, err = s.dispatchGet(req) - case "SignUpSettingsClient.GetEntityTag": - resp, err = s.dispatchGetEntityTag(req) - case "SignUpSettingsClient.Update": - resp, err = s.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SignUpSettingsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if signUpSettingsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = signUpSettingsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SignUpSettingsClient.CreateOrUpdate": + res.resp, res.err = s.dispatchCreateOrUpdate(req) + case "SignUpSettingsClient.Get": + res.resp, res.err = s.dispatchGet(req) + case "SignUpSettingsClient.GetEntityTag": + res.resp, res.err = s.dispatchGetEntityTag(req) + case "SignUpSettingsClient.Update": + res.resp, res.err = s.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SignUpSettingsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -236,3 +252,9 @@ func (s *SignUpSettingsServerTransport) dispatchUpdate(req *http.Request) (*http } return resp, nil } + +// set this to conditionally intercept incoming requests to SignUpSettingsServerTransport +var signUpSettingsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/skus_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/skus_server.go index 7a282dab28bb..cf9cfd1e9d3f 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/skus_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/skus_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "regexp" ) @@ -52,21 +49,40 @@ func (s *SKUsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SKUsClient.NewListPager": - resp, err = s.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SKUsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if skUsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = skUsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SKUsClient.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SKUsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -101,3 +117,9 @@ func (s *SKUsServerTransport) dispatchNewListPager(req *http.Request) (*http.Res } return resp, nil } + +// set this to conditionally intercept incoming requests to SKUsServerTransport +var skUsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/subscription_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/subscription_server.go index 25d2ee2cb514..3b9408a09b16 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/subscription_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/subscription_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -87,37 +84,56 @@ func (s *SubscriptionServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SubscriptionClient.CreateOrUpdate": - resp, err = s.dispatchCreateOrUpdate(req) - case "SubscriptionClient.Delete": - resp, err = s.dispatchDelete(req) - case "SubscriptionClient.Get": - resp, err = s.dispatchGet(req) - case "SubscriptionClient.GetEntityTag": - resp, err = s.dispatchGetEntityTag(req) - case "SubscriptionClient.NewListPager": - resp, err = s.dispatchNewListPager(req) - case "SubscriptionClient.ListSecrets": - resp, err = s.dispatchListSecrets(req) - case "SubscriptionClient.RegeneratePrimaryKey": - resp, err = s.dispatchRegeneratePrimaryKey(req) - case "SubscriptionClient.RegenerateSecondaryKey": - resp, err = s.dispatchRegenerateSecondaryKey(req) - case "SubscriptionClient.Update": - resp, err = s.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SubscriptionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if subscriptionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = subscriptionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SubscriptionClient.CreateOrUpdate": + res.resp, res.err = s.dispatchCreateOrUpdate(req) + case "SubscriptionClient.Delete": + res.resp, res.err = s.dispatchDelete(req) + case "SubscriptionClient.Get": + res.resp, res.err = s.dispatchGet(req) + case "SubscriptionClient.GetEntityTag": + res.resp, res.err = s.dispatchGetEntityTag(req) + case "SubscriptionClient.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "SubscriptionClient.ListSecrets": + res.resp, res.err = s.dispatchListSecrets(req) + case "SubscriptionClient.RegeneratePrimaryKey": + res.resp, res.err = s.dispatchRegeneratePrimaryKey(req) + case "SubscriptionClient.RegenerateSecondaryKey": + res.resp, res.err = s.dispatchRegenerateSecondaryKey(req) + case "SubscriptionClient.Update": + res.resp, res.err = s.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SubscriptionServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -565,3 +581,9 @@ func (s *SubscriptionServerTransport) dispatchUpdate(req *http.Request) (*http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to SubscriptionServerTransport +var subscriptionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tag_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tag_server.go index f6568a24503b..9ca8fa7e895c 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tag_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tag_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -141,61 +138,80 @@ func (t *TagServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return t.dispatchToMethodFake(req, method) +} - switch method { - case "TagClient.AssignToAPI": - resp, err = t.dispatchAssignToAPI(req) - case "TagClient.AssignToOperation": - resp, err = t.dispatchAssignToOperation(req) - case "TagClient.AssignToProduct": - resp, err = t.dispatchAssignToProduct(req) - case "TagClient.CreateOrUpdate": - resp, err = t.dispatchCreateOrUpdate(req) - case "TagClient.Delete": - resp, err = t.dispatchDelete(req) - case "TagClient.DetachFromAPI": - resp, err = t.dispatchDetachFromAPI(req) - case "TagClient.DetachFromOperation": - resp, err = t.dispatchDetachFromOperation(req) - case "TagClient.DetachFromProduct": - resp, err = t.dispatchDetachFromProduct(req) - case "TagClient.Get": - resp, err = t.dispatchGet(req) - case "TagClient.GetByAPI": - resp, err = t.dispatchGetByAPI(req) - case "TagClient.GetByOperation": - resp, err = t.dispatchGetByOperation(req) - case "TagClient.GetByProduct": - resp, err = t.dispatchGetByProduct(req) - case "TagClient.GetEntityState": - resp, err = t.dispatchGetEntityState(req) - case "TagClient.GetEntityStateByAPI": - resp, err = t.dispatchGetEntityStateByAPI(req) - case "TagClient.GetEntityStateByOperation": - resp, err = t.dispatchGetEntityStateByOperation(req) - case "TagClient.GetEntityStateByProduct": - resp, err = t.dispatchGetEntityStateByProduct(req) - case "TagClient.NewListByAPIPager": - resp, err = t.dispatchNewListByAPIPager(req) - case "TagClient.NewListByOperationPager": - resp, err = t.dispatchNewListByOperationPager(req) - case "TagClient.NewListByProductPager": - resp, err = t.dispatchNewListByProductPager(req) - case "TagClient.NewListByServicePager": - resp, err = t.dispatchNewListByServicePager(req) - case "TagClient.Update": - resp, err = t.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (t *TagServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if tagServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tagServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TagClient.AssignToAPI": + res.resp, res.err = t.dispatchAssignToAPI(req) + case "TagClient.AssignToOperation": + res.resp, res.err = t.dispatchAssignToOperation(req) + case "TagClient.AssignToProduct": + res.resp, res.err = t.dispatchAssignToProduct(req) + case "TagClient.CreateOrUpdate": + res.resp, res.err = t.dispatchCreateOrUpdate(req) + case "TagClient.Delete": + res.resp, res.err = t.dispatchDelete(req) + case "TagClient.DetachFromAPI": + res.resp, res.err = t.dispatchDetachFromAPI(req) + case "TagClient.DetachFromOperation": + res.resp, res.err = t.dispatchDetachFromOperation(req) + case "TagClient.DetachFromProduct": + res.resp, res.err = t.dispatchDetachFromProduct(req) + case "TagClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TagClient.GetByAPI": + res.resp, res.err = t.dispatchGetByAPI(req) + case "TagClient.GetByOperation": + res.resp, res.err = t.dispatchGetByOperation(req) + case "TagClient.GetByProduct": + res.resp, res.err = t.dispatchGetByProduct(req) + case "TagClient.GetEntityState": + res.resp, res.err = t.dispatchGetEntityState(req) + case "TagClient.GetEntityStateByAPI": + res.resp, res.err = t.dispatchGetEntityStateByAPI(req) + case "TagClient.GetEntityStateByOperation": + res.resp, res.err = t.dispatchGetEntityStateByOperation(req) + case "TagClient.GetEntityStateByProduct": + res.resp, res.err = t.dispatchGetEntityStateByProduct(req) + case "TagClient.NewListByAPIPager": + res.resp, res.err = t.dispatchNewListByAPIPager(req) + case "TagClient.NewListByOperationPager": + res.resp, res.err = t.dispatchNewListByOperationPager(req) + case "TagClient.NewListByProductPager": + res.resp, res.err = t.dispatchNewListByProductPager(req) + case "TagClient.NewListByServicePager": + res.resp, res.err = t.dispatchNewListByServicePager(req) + case "TagClient.Update": + res.resp, res.err = t.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (t *TagServerTransport) dispatchAssignToAPI(req *http.Request) (*http.Response, error) { @@ -1292,3 +1308,9 @@ func (t *TagServerTransport) dispatchUpdate(req *http.Request) (*http.Response, } return resp, nil } + +// set this to conditionally intercept incoming requests to TagServerTransport +var tagServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagapilink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagapilink_server.go new file mode 100644 index 000000000000..45681bb9487f --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagapilink_server.go @@ -0,0 +1,330 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// TagAPILinkServer is a fake server for instances of the armapimanagement.TagAPILinkClient type. +type TagAPILinkServer struct { + // CreateOrUpdate is the fake for method TagAPILinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, tagID string, apiLinkID string, parameters armapimanagement.TagAPILinkContract, options *armapimanagement.TagAPILinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.TagAPILinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method TagAPILinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, tagID string, apiLinkID string, options *armapimanagement.TagAPILinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.TagAPILinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TagAPILinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, tagID string, apiLinkID string, options *armapimanagement.TagAPILinkClientGetOptions) (resp azfake.Responder[armapimanagement.TagAPILinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method TagAPILinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, tagID string, options *armapimanagement.TagAPILinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.TagAPILinkClientListByProductResponse]) +} + +// NewTagAPILinkServerTransport creates a new instance of TagAPILinkServerTransport with the provided implementation. +// The returned TagAPILinkServerTransport instance is connected to an instance of armapimanagement.TagAPILinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTagAPILinkServerTransport(srv *TagAPILinkServer) *TagAPILinkServerTransport { + return &TagAPILinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.TagAPILinkClientListByProductResponse]](), + } +} + +// TagAPILinkServerTransport connects instances of armapimanagement.TagAPILinkClient to instances of TagAPILinkServer. +// Don't use this type directly, use NewTagAPILinkServerTransport instead. +type TagAPILinkServerTransport struct { + srv *TagAPILinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.TagAPILinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for TagAPILinkServerTransport. +func (t *TagAPILinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TagAPILinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if tagApiLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tagApiLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TagAPILinkClient.CreateOrUpdate": + res.resp, res.err = t.dispatchCreateOrUpdate(req) + case "TagAPILinkClient.Delete": + res.resp, res.err = t.dispatchDelete(req) + case "TagAPILinkClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TagAPILinkClient.NewListByProductPager": + res.resp, res.err = t.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TagAPILinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if t.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.TagAPILinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, tagIDParam, apiLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagAPILinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagAPILinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if t.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, tagIDParam, apiLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagAPILinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, tagIDParam, apiLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagAPILinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (t *TagAPILinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := t.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.TagAPILinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.TagAPILinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := t.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, tagIDParam, options) + newListByProductPager = &resp + t.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.TagAPILinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + t.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to TagAPILinkServerTransport +var tagApiLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagoperationlink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagoperationlink_server.go new file mode 100644 index 000000000000..07a30ba463af --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagoperationlink_server.go @@ -0,0 +1,330 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// TagOperationLinkServer is a fake server for instances of the armapimanagement.TagOperationLinkClient type. +type TagOperationLinkServer struct { + // CreateOrUpdate is the fake for method TagOperationLinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, tagID string, operationLinkID string, parameters armapimanagement.TagOperationLinkContract, options *armapimanagement.TagOperationLinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.TagOperationLinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method TagOperationLinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, tagID string, operationLinkID string, options *armapimanagement.TagOperationLinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.TagOperationLinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TagOperationLinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, tagID string, operationLinkID string, options *armapimanagement.TagOperationLinkClientGetOptions) (resp azfake.Responder[armapimanagement.TagOperationLinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method TagOperationLinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, tagID string, options *armapimanagement.TagOperationLinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.TagOperationLinkClientListByProductResponse]) +} + +// NewTagOperationLinkServerTransport creates a new instance of TagOperationLinkServerTransport with the provided implementation. +// The returned TagOperationLinkServerTransport instance is connected to an instance of armapimanagement.TagOperationLinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTagOperationLinkServerTransport(srv *TagOperationLinkServer) *TagOperationLinkServerTransport { + return &TagOperationLinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.TagOperationLinkClientListByProductResponse]](), + } +} + +// TagOperationLinkServerTransport connects instances of armapimanagement.TagOperationLinkClient to instances of TagOperationLinkServer. +// Don't use this type directly, use NewTagOperationLinkServerTransport instead. +type TagOperationLinkServerTransport struct { + srv *TagOperationLinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.TagOperationLinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for TagOperationLinkServerTransport. +func (t *TagOperationLinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TagOperationLinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if tagOperationLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tagOperationLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TagOperationLinkClient.CreateOrUpdate": + res.resp, res.err = t.dispatchCreateOrUpdate(req) + case "TagOperationLinkClient.Delete": + res.resp, res.err = t.dispatchDelete(req) + case "TagOperationLinkClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TagOperationLinkClient.NewListByProductPager": + res.resp, res.err = t.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TagOperationLinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if t.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.TagOperationLinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + operationLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, tagIDParam, operationLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagOperationLinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagOperationLinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if t.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + operationLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, tagIDParam, operationLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagOperationLinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + operationLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, tagIDParam, operationLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagOperationLinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (t *TagOperationLinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := t.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.TagOperationLinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.TagOperationLinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := t.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, tagIDParam, options) + newListByProductPager = &resp + t.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.TagOperationLinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + t.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to TagOperationLinkServerTransport +var tagOperationLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagproductlink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagproductlink_server.go new file mode 100644 index 000000000000..3e4a430e24da --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagproductlink_server.go @@ -0,0 +1,330 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// TagProductLinkServer is a fake server for instances of the armapimanagement.TagProductLinkClient type. +type TagProductLinkServer struct { + // CreateOrUpdate is the fake for method TagProductLinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, tagID string, productLinkID string, parameters armapimanagement.TagProductLinkContract, options *armapimanagement.TagProductLinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.TagProductLinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method TagProductLinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, tagID string, productLinkID string, options *armapimanagement.TagProductLinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.TagProductLinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TagProductLinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, tagID string, productLinkID string, options *armapimanagement.TagProductLinkClientGetOptions) (resp azfake.Responder[armapimanagement.TagProductLinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method TagProductLinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, tagID string, options *armapimanagement.TagProductLinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.TagProductLinkClientListByProductResponse]) +} + +// NewTagProductLinkServerTransport creates a new instance of TagProductLinkServerTransport with the provided implementation. +// The returned TagProductLinkServerTransport instance is connected to an instance of armapimanagement.TagProductLinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTagProductLinkServerTransport(srv *TagProductLinkServer) *TagProductLinkServerTransport { + return &TagProductLinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.TagProductLinkClientListByProductResponse]](), + } +} + +// TagProductLinkServerTransport connects instances of armapimanagement.TagProductLinkClient to instances of TagProductLinkServer. +// Don't use this type directly, use NewTagProductLinkServerTransport instead. +type TagProductLinkServerTransport struct { + srv *TagProductLinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.TagProductLinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for TagProductLinkServerTransport. +func (t *TagProductLinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TagProductLinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if tagProductLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tagProductLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TagProductLinkClient.CreateOrUpdate": + res.resp, res.err = t.dispatchCreateOrUpdate(req) + case "TagProductLinkClient.Delete": + res.resp, res.err = t.dispatchDelete(req) + case "TagProductLinkClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TagProductLinkClient.NewListByProductPager": + res.resp, res.err = t.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TagProductLinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if t.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/productLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.TagProductLinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + productLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, tagIDParam, productLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagProductLinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagProductLinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if t.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/productLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + productLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, tagIDParam, productLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagProductLinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/productLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + productLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, tagIDParam, productLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagProductLinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (t *TagProductLinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := t.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/productLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.TagProductLinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.TagProductLinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := t.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, tagIDParam, options) + newListByProductPager = &resp + t.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.TagProductLinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + t.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to TagProductLinkServerTransport +var tagProductLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagresource_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagresource_server.go index 873e396f3a76..2d65ccc072b7 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagresource_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tagresource_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -54,21 +51,40 @@ func (t *TagResourceServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return t.dispatchToMethodFake(req, method) +} - switch method { - case "TagResourceClient.NewListByServicePager": - resp, err = t.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (t *TagResourceServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if tagResourceServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tagResourceServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TagResourceClient.NewListByServicePager": + res.resp, res.err = t.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (t *TagResourceServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { @@ -153,3 +169,9 @@ func (t *TagResourceServerTransport) dispatchNewListByServicePager(req *http.Req } return resp, nil } + +// set this to conditionally intercept incoming requests to TagResourceServerTransport +var tagResourceServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantaccess_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantaccess_server.go index 39a39d67b018..e111d446a621 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantaccess_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantaccess_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -82,35 +79,54 @@ func (t *TenantAccessServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return t.dispatchToMethodFake(req, method) +} - switch method { - case "TenantAccessClient.Create": - resp, err = t.dispatchCreate(req) - case "TenantAccessClient.Get": - resp, err = t.dispatchGet(req) - case "TenantAccessClient.GetEntityTag": - resp, err = t.dispatchGetEntityTag(req) - case "TenantAccessClient.NewListByServicePager": - resp, err = t.dispatchNewListByServicePager(req) - case "TenantAccessClient.ListSecrets": - resp, err = t.dispatchListSecrets(req) - case "TenantAccessClient.RegeneratePrimaryKey": - resp, err = t.dispatchRegeneratePrimaryKey(req) - case "TenantAccessClient.RegenerateSecondaryKey": - resp, err = t.dispatchRegenerateSecondaryKey(req) - case "TenantAccessClient.Update": - resp, err = t.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (t *TenantAccessServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if tenantAccessServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tenantAccessServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TenantAccessClient.Create": + res.resp, res.err = t.dispatchCreate(req) + case "TenantAccessClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TenantAccessClient.GetEntityTag": + res.resp, res.err = t.dispatchGetEntityTag(req) + case "TenantAccessClient.NewListByServicePager": + res.resp, res.err = t.dispatchNewListByServicePager(req) + case "TenantAccessClient.ListSecrets": + res.resp, res.err = t.dispatchListSecrets(req) + case "TenantAccessClient.RegeneratePrimaryKey": + res.resp, res.err = t.dispatchRegeneratePrimaryKey(req) + case "TenantAccessClient.RegenerateSecondaryKey": + res.resp, res.err = t.dispatchRegenerateSecondaryKey(req) + case "TenantAccessClient.Update": + res.resp, res.err = t.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (t *TenantAccessServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { @@ -489,3 +505,9 @@ func (t *TenantAccessServerTransport) dispatchUpdate(req *http.Request) (*http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to TenantAccessServerTransport +var tenantAccessServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantaccessgit_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantaccessgit_server.go index 54d8b24c14dd..c93823f72f98 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantaccessgit_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantaccessgit_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -53,23 +50,42 @@ func (t *TenantAccessGitServerTransport) Do(req *http.Request) (*http.Response, return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return t.dispatchToMethodFake(req, method) +} - switch method { - case "TenantAccessGitClient.RegeneratePrimaryKey": - resp, err = t.dispatchRegeneratePrimaryKey(req) - case "TenantAccessGitClient.RegenerateSecondaryKey": - resp, err = t.dispatchRegenerateSecondaryKey(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (t *TenantAccessGitServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if tenantAccessGitServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tenantAccessGitServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TenantAccessGitClient.RegeneratePrimaryKey": + res.resp, res.err = t.dispatchRegeneratePrimaryKey(req) + case "TenantAccessGitClient.RegenerateSecondaryKey": + res.resp, res.err = t.dispatchRegenerateSecondaryKey(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (t *TenantAccessGitServerTransport) dispatchRegeneratePrimaryKey(req *http.Request) (*http.Response, error) { @@ -157,3 +173,9 @@ func (t *TenantAccessGitServerTransport) dispatchRegenerateSecondaryKey(req *htt } return resp, nil } + +// set this to conditionally intercept incoming requests to TenantAccessGitServerTransport +var tenantAccessGitServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantconfiguration_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantconfiguration_server.go index 2ada38ca9219..8bc909ab6c55 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantconfiguration_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantconfiguration_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -69,27 +66,46 @@ func (t *TenantConfigurationServerTransport) Do(req *http.Request) (*http.Respon return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return t.dispatchToMethodFake(req, method) +} - switch method { - case "TenantConfigurationClient.BeginDeploy": - resp, err = t.dispatchBeginDeploy(req) - case "TenantConfigurationClient.GetSyncState": - resp, err = t.dispatchGetSyncState(req) - case "TenantConfigurationClient.BeginSave": - resp, err = t.dispatchBeginSave(req) - case "TenantConfigurationClient.BeginValidate": - resp, err = t.dispatchBeginValidate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (t *TenantConfigurationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if tenantConfigurationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tenantConfigurationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TenantConfigurationClient.BeginDeploy": + res.resp, res.err = t.dispatchBeginDeploy(req) + case "TenantConfigurationClient.GetSyncState": + res.resp, res.err = t.dispatchGetSyncState(req) + case "TenantConfigurationClient.BeginSave": + res.resp, res.err = t.dispatchBeginSave(req) + case "TenantConfigurationClient.BeginValidate": + res.resp, res.err = t.dispatchBeginValidate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (t *TenantConfigurationServerTransport) dispatchBeginDeploy(req *http.Request) (*http.Response, error) { @@ -308,3 +324,9 @@ func (t *TenantConfigurationServerTransport) dispatchBeginValidate(req *http.Req return resp, nil } + +// set this to conditionally intercept incoming requests to TenantConfigurationServerTransport +var tenantConfigurationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantsettings_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantsettings_server.go index a516e90183b5..3902fe914afe 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantsettings_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/tenantsettings_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -58,23 +55,42 @@ func (t *TenantSettingsServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return t.dispatchToMethodFake(req, method) +} - switch method { - case "TenantSettingsClient.Get": - resp, err = t.dispatchGet(req) - case "TenantSettingsClient.NewListByServicePager": - resp, err = t.dispatchNewListByServicePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (t *TenantSettingsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if tenantSettingsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tenantSettingsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TenantSettingsClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TenantSettingsClient.NewListByServicePager": + res.resp, res.err = t.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (t *TenantSettingsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -175,3 +191,9 @@ func (t *TenantSettingsServerTransport) dispatchNewListByServicePager(req *http. } return resp, nil } + +// set this to conditionally intercept incoming requests to TenantSettingsServerTransport +var tenantSettingsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/time_rfc3339.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/time_rfc3339.go index b0535a7b63e6..7691a451714b 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/time_rfc3339.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/time_rfc3339.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -19,12 +16,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +41,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/user_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/user_server.go index d38ec64e1482..9d7865c934a0 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/user_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/user_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -29,9 +26,9 @@ type UserServer struct { // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters armapimanagement.UserCreateParameters, options *armapimanagement.UserClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.UserClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - // Delete is the fake for method UserClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, options *armapimanagement.UserClientDeleteOptions) (resp azfake.Responder[armapimanagement.UserClientDeleteResponse], errResp azfake.ErrorResponder) + // BeginDelete is the fake for method UserClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, options *armapimanagement.UserClientBeginDeleteOptions) (resp azfake.PollerResponder[armapimanagement.UserClientDeleteResponse], errResp azfake.ErrorResponder) // GenerateSsoURL is the fake for method UserClient.GenerateSsoURL // HTTP status codes to indicate success: http.StatusOK @@ -64,6 +61,7 @@ type UserServer struct { func NewUserServerTransport(srv *UserServer) *UserServerTransport { return &UserServerTransport{ srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armapimanagement.UserClientDeleteResponse]](), newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.UserClientListByServiceResponse]](), } } @@ -72,6 +70,7 @@ func NewUserServerTransport(srv *UserServer) *UserServerTransport { // Don't use this type directly, use NewUserServerTransport instead. type UserServerTransport struct { srv *UserServer + beginDelete *tracker[azfake.PollerResponder[armapimanagement.UserClientDeleteResponse]] newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.UserClientListByServiceResponse]] } @@ -83,35 +82,54 @@ func (u *UserServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return u.dispatchToMethodFake(req, method) +} - switch method { - case "UserClient.CreateOrUpdate": - resp, err = u.dispatchCreateOrUpdate(req) - case "UserClient.Delete": - resp, err = u.dispatchDelete(req) - case "UserClient.GenerateSsoURL": - resp, err = u.dispatchGenerateSsoURL(req) - case "UserClient.Get": - resp, err = u.dispatchGet(req) - case "UserClient.GetEntityTag": - resp, err = u.dispatchGetEntityTag(req) - case "UserClient.GetSharedAccessToken": - resp, err = u.dispatchGetSharedAccessToken(req) - case "UserClient.NewListByServicePager": - resp, err = u.dispatchNewListByServicePager(req) - case "UserClient.Update": - resp, err = u.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (u *UserServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if userServerTransportInterceptor != nil { + res.resp, res.err, intercepted = userServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "UserClient.CreateOrUpdate": + res.resp, res.err = u.dispatchCreateOrUpdate(req) + case "UserClient.BeginDelete": + res.resp, res.err = u.dispatchBeginDelete(req) + case "UserClient.GenerateSsoURL": + res.resp, res.err = u.dispatchGenerateSsoURL(req) + case "UserClient.Get": + res.resp, res.err = u.dispatchGet(req) + case "UserClient.GetEntityTag": + res.resp, res.err = u.dispatchGetEntityTag(req) + case "UserClient.GetSharedAccessToken": + res.resp, res.err = u.dispatchGetSharedAccessToken(req) + case "UserClient.NewListByServicePager": + res.resp, res.err = u.dispatchNewListByServicePager(req) + case "UserClient.Update": + res.resp, res.err = u.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (u *UserServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -175,70 +193,81 @@ func (u *UserServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.R return resp, nil } -func (u *UserServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if u.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err +func (u *UserServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if u.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } - serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) - if err != nil { - return nil, err - } - userIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("userId")]) - if err != nil { - return nil, err - } - deleteSubscriptionsUnescaped, err := url.QueryUnescape(qp.Get("deleteSubscriptions")) - if err != nil { - return nil, err - } - deleteSubscriptionsParam, err := parseOptional(deleteSubscriptionsUnescaped, strconv.ParseBool) - if err != nil { - return nil, err - } - notifyUnescaped, err := url.QueryUnescape(qp.Get("notify")) - if err != nil { - return nil, err - } - notifyParam, err := parseOptional(notifyUnescaped, strconv.ParseBool) - if err != nil { - return nil, err + beginDelete := u.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + userIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("userId")]) + if err != nil { + return nil, err + } + deleteSubscriptionsUnescaped, err := url.QueryUnescape(qp.Get("deleteSubscriptions")) + if err != nil { + return nil, err + } + deleteSubscriptionsParam, err := parseOptional(deleteSubscriptionsUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + notifyUnescaped, err := url.QueryUnescape(qp.Get("notify")) + if err != nil { + return nil, err + } + notifyParam, err := parseOptional(notifyUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + appTypeUnescaped, err := url.QueryUnescape(qp.Get("appType")) + if err != nil { + return nil, err + } + appTypeParam := getOptional(armapimanagement.AppType(appTypeUnescaped)) + var options *armapimanagement.UserClientBeginDeleteOptions + if deleteSubscriptionsParam != nil || notifyParam != nil || appTypeParam != nil { + options = &armapimanagement.UserClientBeginDeleteOptions{ + DeleteSubscriptions: deleteSubscriptionsParam, + Notify: notifyParam, + AppType: appTypeParam, + } + } + respr, errRespr := u.srv.BeginDelete(req.Context(), resourceGroupNameParam, serviceNameParam, userIDParam, getHeaderValue(req.Header, "If-Match"), options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + u.beginDelete.add(req, beginDelete) } - appTypeUnescaped, err := url.QueryUnescape(qp.Get("appType")) + + resp, err := server.PollerResponderNext(beginDelete, req) if err != nil { return nil, err } - appTypeParam := getOptional(armapimanagement.AppType(appTypeUnescaped)) - var options *armapimanagement.UserClientDeleteOptions - if deleteSubscriptionsParam != nil || notifyParam != nil || appTypeParam != nil { - options = &armapimanagement.UserClientDeleteOptions{ - DeleteSubscriptions: deleteSubscriptionsParam, - Notify: notifyParam, - AppType: appTypeParam, - } - } - respr, errRespr := u.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, userIDParam, getHeaderValue(req.Header, "If-Match"), options) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + u.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err + if !server.PollerResponderMore(beginDelete) { + u.beginDelete.remove(req) } + return resp, nil } @@ -535,3 +564,9 @@ func (u *UserServerTransport) dispatchUpdate(req *http.Request) (*http.Response, } return resp, nil } + +// set this to conditionally intercept incoming requests to UserServerTransport +var userServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/userconfirmationpassword_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/userconfirmationpassword_server.go index 382524d8a17d..dbf78889930a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/userconfirmationpassword_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/userconfirmationpassword_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (u *UserConfirmationPasswordServerTransport) Do(req *http.Request) (*http.R return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return u.dispatchToMethodFake(req, method) +} - switch method { - case "UserConfirmationPasswordClient.Send": - resp, err = u.dispatchSend(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (u *UserConfirmationPasswordServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if userConfirmationPasswordServerTransportInterceptor != nil { + res.resp, res.err, intercepted = userConfirmationPasswordServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "UserConfirmationPasswordClient.Send": + res.resp, res.err = u.dispatchSend(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (u *UserConfirmationPasswordServerTransport) dispatchSend(req *http.Request) (*http.Response, error) { @@ -114,3 +130,9 @@ func (u *UserConfirmationPasswordServerTransport) dispatchSend(req *http.Request } return resp, nil } + +// set this to conditionally intercept incoming requests to UserConfirmationPasswordServerTransport +var userConfirmationPasswordServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/usergroup_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/usergroup_server.go index 0f7620468bbf..9e1ab82bc186 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/usergroup_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/usergroup_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -54,21 +51,40 @@ func (u *UserGroupServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return u.dispatchToMethodFake(req, method) +} - switch method { - case "UserGroupClient.NewListPager": - resp, err = u.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (u *UserGroupServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if userGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = userGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "UserGroupClient.NewListPager": + res.resp, res.err = u.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (u *UserGroupServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -157,3 +173,9 @@ func (u *UserGroupServerTransport) dispatchNewListPager(req *http.Request) (*htt } return resp, nil } + +// set this to conditionally intercept incoming requests to UserGroupServerTransport +var userGroupServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/useridentities_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/useridentities_server.go index b572d30b5c20..8a0f0e8eea6c 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/useridentities_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/useridentities_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -53,21 +50,40 @@ func (u *UserIdentitiesServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return u.dispatchToMethodFake(req, method) +} - switch method { - case "UserIdentitiesClient.NewListPager": - resp, err = u.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (u *UserIdentitiesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if userIdentitiesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = userIdentitiesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "UserIdentitiesClient.NewListPager": + res.resp, res.err = u.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (u *UserIdentitiesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -114,3 +130,9 @@ func (u *UserIdentitiesServerTransport) dispatchNewListPager(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to UserIdentitiesServerTransport +var userIdentitiesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/usersubscription_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/usersubscription_server.go index dee27b7a5e66..3e85dacc8fc1 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/fake/usersubscription_server.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/usersubscription_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" @@ -59,23 +56,42 @@ func (u *UserSubscriptionServerTransport) Do(req *http.Request) (*http.Response, return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return u.dispatchToMethodFake(req, method) +} - switch method { - case "UserSubscriptionClient.Get": - resp, err = u.dispatchGet(req) - case "UserSubscriptionClient.NewListPager": - resp, err = u.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (u *UserSubscriptionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if userSubscriptionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = userSubscriptionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "UserSubscriptionClient.Get": + res.resp, res.err = u.dispatchGet(req) + case "UserSubscriptionClient.NewListPager": + res.resp, res.err = u.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (u *UserSubscriptionServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -208,3 +224,9 @@ func (u *UserSubscriptionServerTransport) dispatchNewListPager(req *http.Request } return resp, nil } + +// set this to conditionally intercept incoming requests to UserSubscriptionServerTransport +var userSubscriptionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspace_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspace_server.go new file mode 100644 index 000000000000..99020316e329 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspace_server.go @@ -0,0 +1,420 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceServer is a fake server for instances of the armapimanagement.WorkspaceClient type. +type WorkspaceServer struct { + // CreateOrUpdate is the fake for method WorkspaceClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, parameters armapimanagement.WorkspaceContract, options *armapimanagement.WorkspaceClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, ifMatch string, options *armapimanagement.WorkspaceClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, options *armapimanagement.WorkspaceClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceClientListByServiceResponse]) + + // Update is the fake for method WorkspaceClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, ifMatch string, parameters armapimanagement.WorkspaceContract, options *armapimanagement.WorkspaceClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceServerTransport creates a new instance of WorkspaceServerTransport with the provided implementation. +// The returned WorkspaceServerTransport instance is connected to an instance of armapimanagement.WorkspaceClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceServerTransport(srv *WorkspaceServer) *WorkspaceServerTransport { + return &WorkspaceServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceClientListByServiceResponse]](), + } +} + +// WorkspaceServerTransport connects instances of armapimanagement.WorkspaceClient to instances of WorkspaceServer. +// Don't use this type directly, use NewWorkspaceServerTransport instead. +type WorkspaceServerTransport struct { + srv *WorkspaceServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceServerTransport. +func (w *WorkspaceServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + case "WorkspaceClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.WorkspaceContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).WorkspaceContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).WorkspaceContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.WorkspaceContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).WorkspaceContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceServerTransport +var workspaceServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapi_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapi_server.go new file mode 100644 index 000000000000..2adb250659f3 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapi_server.go @@ -0,0 +1,484 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceAPIServer is a fake server for instances of the armapimanagement.WorkspaceAPIClient type. +type WorkspaceAPIServer struct { + // BeginCreateOrUpdate is the fake for method WorkspaceAPIClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, parameters armapimanagement.APICreateOrUpdateParameter, options *armapimanagement.WorkspaceAPIClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.WorkspaceAPIClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceAPIClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, ifMatch string, options *armapimanagement.WorkspaceAPIClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceAPIClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, options *armapimanagement.WorkspaceAPIClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceAPIClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, options *armapimanagement.WorkspaceAPIClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceAPIClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceAPIClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceAPIClientListByServiceResponse]) + + // Update is the fake for method WorkspaceAPIClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, ifMatch string, parameters armapimanagement.APIUpdateContract, options *armapimanagement.WorkspaceAPIClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceAPIServerTransport creates a new instance of WorkspaceAPIServerTransport with the provided implementation. +// The returned WorkspaceAPIServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPIClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPIServerTransport(srv *WorkspaceAPIServer) *WorkspaceAPIServerTransport { + return &WorkspaceAPIServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.WorkspaceAPIClientCreateOrUpdateResponse]](), + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIClientListByServiceResponse]](), + } +} + +// WorkspaceAPIServerTransport connects instances of armapimanagement.WorkspaceAPIClient to instances of WorkspaceAPIServer. +// Don't use this type directly, use NewWorkspaceAPIServerTransport instead. +type WorkspaceAPIServerTransport struct { + srv *WorkspaceAPIServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.WorkspaceAPIClientCreateOrUpdateResponse]] + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceAPIServerTransport. +func (w *WorkspaceAPIServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPIServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPIClient.BeginCreateOrUpdate": + res.resp, res.err = w.dispatchBeginCreateOrUpdate(req) + case "WorkspaceAPIClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceAPIClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceAPIClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceAPIClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + case "WorkspaceAPIClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPIServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := w.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.APICreateOrUpdateParameter](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceAPIClientBeginCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceAPIClientBeginCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + w.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + w.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + w.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (w *WorkspaceAPIServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + deleteRevisionsUnescaped, err := url.QueryUnescape(qp.Get("deleteRevisions")) + if err != nil { + return nil, err + } + deleteRevisionsParam, err := parseOptional(deleteRevisionsUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceAPIClientDeleteOptions + if deleteRevisionsParam != nil { + options = &armapimanagement.WorkspaceAPIClientDeleteOptions{ + DeleteRevisions: deleteRevisionsParam, + } + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, getHeaderValue(req.Header, "If-Match"), options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceAPIServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).APIContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + tagsUnescaped, err := url.QueryUnescape(qp.Get("tags")) + if err != nil { + return nil, err + } + tagsParam := getOptional(tagsUnescaped) + expandAPIVersionSetUnescaped, err := url.QueryUnescape(qp.Get("expandApiVersionSet")) + if err != nil { + return nil, err + } + expandAPIVersionSetParam, err := parseOptional(expandAPIVersionSetUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceAPIClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil || tagsParam != nil || expandAPIVersionSetParam != nil { + options = &armapimanagement.WorkspaceAPIClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + Tags: tagsParam, + ExpandAPIVersionSet: expandAPIVersionSetParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceAPIClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceAPIServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.APIUpdateContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).APIContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPIServerTransport +var workspaceApiServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapidiagnostic_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapidiagnostic_server.go new file mode 100644 index 000000000000..880cbe6f2b0d --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapidiagnostic_server.go @@ -0,0 +1,468 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceAPIDiagnosticServer is a fake server for instances of the armapimanagement.WorkspaceAPIDiagnosticClient type. +type WorkspaceAPIDiagnosticServer struct { + // CreateOrUpdate is the fake for method WorkspaceAPIDiagnosticClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, parameters armapimanagement.DiagnosticContract, options *armapimanagement.WorkspaceAPIDiagnosticClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIDiagnosticClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceAPIDiagnosticClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, ifMatch string, options *armapimanagement.WorkspaceAPIDiagnosticClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIDiagnosticClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceAPIDiagnosticClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, options *armapimanagement.WorkspaceAPIDiagnosticClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIDiagnosticClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceAPIDiagnosticClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, options *armapimanagement.WorkspaceAPIDiagnosticClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIDiagnosticClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByWorkspacePager is the fake for method WorkspaceAPIDiagnosticClient.NewListByWorkspacePager + // HTTP status codes to indicate success: http.StatusOK + NewListByWorkspacePager func(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *armapimanagement.WorkspaceAPIDiagnosticClientListByWorkspaceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceAPIDiagnosticClientListByWorkspaceResponse]) + + // Update is the fake for method WorkspaceAPIDiagnosticClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, ifMatch string, parameters armapimanagement.DiagnosticUpdateContract, options *armapimanagement.WorkspaceAPIDiagnosticClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIDiagnosticClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceAPIDiagnosticServerTransport creates a new instance of WorkspaceAPIDiagnosticServerTransport with the provided implementation. +// The returned WorkspaceAPIDiagnosticServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPIDiagnosticClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPIDiagnosticServerTransport(srv *WorkspaceAPIDiagnosticServer) *WorkspaceAPIDiagnosticServerTransport { + return &WorkspaceAPIDiagnosticServerTransport{ + srv: srv, + newListByWorkspacePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIDiagnosticClientListByWorkspaceResponse]](), + } +} + +// WorkspaceAPIDiagnosticServerTransport connects instances of armapimanagement.WorkspaceAPIDiagnosticClient to instances of WorkspaceAPIDiagnosticServer. +// Don't use this type directly, use NewWorkspaceAPIDiagnosticServerTransport instead. +type WorkspaceAPIDiagnosticServerTransport struct { + srv *WorkspaceAPIDiagnosticServer + newListByWorkspacePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIDiagnosticClientListByWorkspaceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceAPIDiagnosticServerTransport. +func (w *WorkspaceAPIDiagnosticServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPIDiagnosticServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiDiagnosticServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiDiagnosticServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPIDiagnosticClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceAPIDiagnosticClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceAPIDiagnosticClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceAPIDiagnosticClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceAPIDiagnosticClient.NewListByWorkspacePager": + res.resp, res.err = w.dispatchNewListByWorkspacePager(req) + case "WorkspaceAPIDiagnosticClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPIDiagnosticServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.DiagnosticContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceAPIDiagnosticClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceAPIDiagnosticClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, diagnosticIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DiagnosticContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIDiagnosticServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, diagnosticIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceAPIDiagnosticServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, diagnosticIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DiagnosticContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIDiagnosticServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, diagnosticIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIDiagnosticServerTransport) dispatchNewListByWorkspacePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByWorkspacePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByWorkspacePager not implemented")} + } + newListByWorkspacePager := w.newListByWorkspacePager.get(req) + if newListByWorkspacePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceAPIDiagnosticClientListByWorkspaceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceAPIDiagnosticClientListByWorkspaceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByWorkspacePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, options) + newListByWorkspacePager = &resp + w.newListByWorkspacePager.add(req, newListByWorkspacePager) + server.PagerResponderInjectNextLinks(newListByWorkspacePager, req, func(page *armapimanagement.WorkspaceAPIDiagnosticClientListByWorkspaceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByWorkspacePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByWorkspacePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByWorkspacePager) { + w.newListByWorkspacePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceAPIDiagnosticServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.DiagnosticUpdateContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, diagnosticIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DiagnosticContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPIDiagnosticServerTransport +var workspaceApiDiagnosticServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapiexport_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapiexport_server.go new file mode 100644 index 000000000000..752e9cda3059 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapiexport_server.go @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// WorkspaceAPIExportServer is a fake server for instances of the armapimanagement.WorkspaceAPIExportClient type. +type WorkspaceAPIExportServer struct { + // Get is the fake for method WorkspaceAPIExportClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, formatParam armapimanagement.ExportFormat, export armapimanagement.ExportAPI, options *armapimanagement.WorkspaceAPIExportClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIExportClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceAPIExportServerTransport creates a new instance of WorkspaceAPIExportServerTransport with the provided implementation. +// The returned WorkspaceAPIExportServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPIExportClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPIExportServerTransport(srv *WorkspaceAPIExportServer) *WorkspaceAPIExportServerTransport { + return &WorkspaceAPIExportServerTransport{srv: srv} +} + +// WorkspaceAPIExportServerTransport connects instances of armapimanagement.WorkspaceAPIExportClient to instances of WorkspaceAPIExportServer. +// Don't use this type directly, use NewWorkspaceAPIExportServerTransport instead. +type WorkspaceAPIExportServerTransport struct { + srv *WorkspaceAPIExportServer +} + +// Do implements the policy.Transporter interface for WorkspaceAPIExportServerTransport. +func (w *WorkspaceAPIExportServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPIExportServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiExportServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiExportServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPIExportClient.Get": + res.resp, res.err = w.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPIExportServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + formatParamParam, err := parseWithCast(qp.Get("format"), func(v string) (armapimanagement.ExportFormat, error) { + p, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.ExportFormat(p), nil + }) + if err != nil { + return nil, err + } + exportParam, err := parseWithCast(qp.Get("export"), func(v string) (armapimanagement.ExportAPI, error) { + p, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.ExportAPI(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, formatParamParam, exportParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).APIExportResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPIExportServerTransport +var workspaceApiExportServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapioperation_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapioperation_server.go new file mode 100644 index 000000000000..4f45e9aac06c --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapioperation_server.go @@ -0,0 +1,474 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceAPIOperationServer is a fake server for instances of the armapimanagement.WorkspaceAPIOperationClient type. +type WorkspaceAPIOperationServer struct { + // CreateOrUpdate is the fake for method WorkspaceAPIOperationClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, parameters armapimanagement.OperationContract, options *armapimanagement.WorkspaceAPIOperationClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIOperationClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceAPIOperationClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, ifMatch string, options *armapimanagement.WorkspaceAPIOperationClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIOperationClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceAPIOperationClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, options *armapimanagement.WorkspaceAPIOperationClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIOperationClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceAPIOperationClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, options *armapimanagement.WorkspaceAPIOperationClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIOperationClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByAPIPager is the fake for method WorkspaceAPIOperationClient.NewListByAPIPager + // HTTP status codes to indicate success: http.StatusOK + NewListByAPIPager func(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *armapimanagement.WorkspaceAPIOperationClientListByAPIOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceAPIOperationClientListByAPIResponse]) + + // Update is the fake for method WorkspaceAPIOperationClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, ifMatch string, parameters armapimanagement.OperationUpdateContract, options *armapimanagement.WorkspaceAPIOperationClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIOperationClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceAPIOperationServerTransport creates a new instance of WorkspaceAPIOperationServerTransport with the provided implementation. +// The returned WorkspaceAPIOperationServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPIOperationClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPIOperationServerTransport(srv *WorkspaceAPIOperationServer) *WorkspaceAPIOperationServerTransport { + return &WorkspaceAPIOperationServerTransport{ + srv: srv, + newListByAPIPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIOperationClientListByAPIResponse]](), + } +} + +// WorkspaceAPIOperationServerTransport connects instances of armapimanagement.WorkspaceAPIOperationClient to instances of WorkspaceAPIOperationServer. +// Don't use this type directly, use NewWorkspaceAPIOperationServerTransport instead. +type WorkspaceAPIOperationServerTransport struct { + srv *WorkspaceAPIOperationServer + newListByAPIPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIOperationClientListByAPIResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceAPIOperationServerTransport. +func (w *WorkspaceAPIOperationServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPIOperationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiOperationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiOperationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPIOperationClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceAPIOperationClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceAPIOperationClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceAPIOperationClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceAPIOperationClient.NewListByAPIPager": + res.resp, res.err = w.dispatchNewListByAPIPager(req) + case "WorkspaceAPIOperationClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPIOperationServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.OperationContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceAPIOperationClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceAPIOperationClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIOperationServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceAPIOperationServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIOperationServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIOperationServerTransport) dispatchNewListByAPIPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByAPIPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByAPIPager not implemented")} + } + newListByAPIPager := w.newListByAPIPager.get(req) + if newListByAPIPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + tagsUnescaped, err := url.QueryUnescape(qp.Get("tags")) + if err != nil { + return nil, err + } + tagsParam := getOptional(tagsUnescaped) + var options *armapimanagement.WorkspaceAPIOperationClientListByAPIOptions + if filterParam != nil || topParam != nil || skipParam != nil || tagsParam != nil { + options = &armapimanagement.WorkspaceAPIOperationClientListByAPIOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + Tags: tagsParam, + } + } + resp := w.srv.NewListByAPIPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, options) + newListByAPIPager = &resp + w.newListByAPIPager.add(req, newListByAPIPager) + server.PagerResponderInjectNextLinks(newListByAPIPager, req, func(page *armapimanagement.WorkspaceAPIOperationClientListByAPIResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByAPIPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByAPIPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByAPIPager) { + w.newListByAPIPager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceAPIOperationServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.OperationUpdateContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPIOperationServerTransport +var workspaceApiOperationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapioperationpolicy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapioperationpolicy_server.go new file mode 100644 index 000000000000..9892e9e094fe --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapioperationpolicy_server.go @@ -0,0 +1,423 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// WorkspaceAPIOperationPolicyServer is a fake server for instances of the armapimanagement.WorkspaceAPIOperationPolicyClient type. +type WorkspaceAPIOperationPolicyServer struct { + // CreateOrUpdate is the fake for method WorkspaceAPIOperationPolicyClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID armapimanagement.PolicyIDName, parameters armapimanagement.PolicyContract, options *armapimanagement.WorkspaceAPIOperationPolicyClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceAPIOperationPolicyClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID armapimanagement.PolicyIDName, ifMatch string, options *armapimanagement.WorkspaceAPIOperationPolicyClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIOperationPolicyClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceAPIOperationPolicyClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID armapimanagement.PolicyIDName, options *armapimanagement.WorkspaceAPIOperationPolicyClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIOperationPolicyClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceAPIOperationPolicyClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID armapimanagement.PolicyIDName, options *armapimanagement.WorkspaceAPIOperationPolicyClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIOperationPolicyClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByOperationPager is the fake for method WorkspaceAPIOperationPolicyClient.NewListByOperationPager + // HTTP status codes to indicate success: http.StatusOK + NewListByOperationPager func(resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, options *armapimanagement.WorkspaceAPIOperationPolicyClientListByOperationOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceAPIOperationPolicyClientListByOperationResponse]) +} + +// NewWorkspaceAPIOperationPolicyServerTransport creates a new instance of WorkspaceAPIOperationPolicyServerTransport with the provided implementation. +// The returned WorkspaceAPIOperationPolicyServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPIOperationPolicyClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPIOperationPolicyServerTransport(srv *WorkspaceAPIOperationPolicyServer) *WorkspaceAPIOperationPolicyServerTransport { + return &WorkspaceAPIOperationPolicyServerTransport{ + srv: srv, + newListByOperationPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIOperationPolicyClientListByOperationResponse]](), + } +} + +// WorkspaceAPIOperationPolicyServerTransport connects instances of armapimanagement.WorkspaceAPIOperationPolicyClient to instances of WorkspaceAPIOperationPolicyServer. +// Don't use this type directly, use NewWorkspaceAPIOperationPolicyServerTransport instead. +type WorkspaceAPIOperationPolicyServerTransport struct { + srv *WorkspaceAPIOperationPolicyServer + newListByOperationPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIOperationPolicyClientListByOperationResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceAPIOperationPolicyServerTransport. +func (w *WorkspaceAPIOperationPolicyServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPIOperationPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiOperationPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiOperationPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPIOperationPolicyClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceAPIOperationPolicyClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceAPIOperationPolicyClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceAPIOperationPolicyClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceAPIOperationPolicyClient.NewListByOperationPager": + res.resp, res.err = w.dispatchNewListByOperationPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPIOperationPolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.PolicyContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceAPIOperationPolicyClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceAPIOperationPolicyClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, policyIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIOperationPolicyServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, policyIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceAPIOperationPolicyServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + formatUnescaped, err := url.QueryUnescape(qp.Get("format")) + if err != nil { + return nil, err + } + formatParam := getOptional(armapimanagement.PolicyExportFormat(formatUnescaped)) + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceAPIOperationPolicyClientGetOptions + if formatParam != nil { + options = &armapimanagement.WorkspaceAPIOperationPolicyClientGetOptions{ + Format: formatParam, + } + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, policyIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIOperationPolicyServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, policyIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIOperationPolicyServerTransport) dispatchNewListByOperationPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByOperationPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByOperationPager not implemented")} + } + newListByOperationPager := w.newListByOperationPager.get(req) + if newListByOperationPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListByOperationPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, operationIDParam, nil) + newListByOperationPager = &resp + w.newListByOperationPager.add(req, newListByOperationPager) + server.PagerResponderInjectNextLinks(newListByOperationPager, req, func(page *armapimanagement.WorkspaceAPIOperationPolicyClientListByOperationResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByOperationPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByOperationPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByOperationPager) { + w.newListByOperationPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPIOperationPolicyServerTransport +var workspaceApiOperationPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapipolicy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapipolicy_server.go new file mode 100644 index 000000000000..ae7f4877259b --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapipolicy_server.go @@ -0,0 +1,403 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// WorkspaceAPIPolicyServer is a fake server for instances of the armapimanagement.WorkspaceAPIPolicyClient type. +type WorkspaceAPIPolicyServer struct { + // CreateOrUpdate is the fake for method WorkspaceAPIPolicyClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID armapimanagement.PolicyIDName, parameters armapimanagement.PolicyContract, options *armapimanagement.WorkspaceAPIPolicyClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIPolicyClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceAPIPolicyClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID armapimanagement.PolicyIDName, ifMatch string, options *armapimanagement.WorkspaceAPIPolicyClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIPolicyClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceAPIPolicyClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID armapimanagement.PolicyIDName, options *armapimanagement.WorkspaceAPIPolicyClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIPolicyClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceAPIPolicyClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID armapimanagement.PolicyIDName, options *armapimanagement.WorkspaceAPIPolicyClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIPolicyClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByAPIPager is the fake for method WorkspaceAPIPolicyClient.NewListByAPIPager + // HTTP status codes to indicate success: http.StatusOK + NewListByAPIPager func(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *armapimanagement.WorkspaceAPIPolicyClientListByAPIOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceAPIPolicyClientListByAPIResponse]) +} + +// NewWorkspaceAPIPolicyServerTransport creates a new instance of WorkspaceAPIPolicyServerTransport with the provided implementation. +// The returned WorkspaceAPIPolicyServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPIPolicyClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPIPolicyServerTransport(srv *WorkspaceAPIPolicyServer) *WorkspaceAPIPolicyServerTransport { + return &WorkspaceAPIPolicyServerTransport{ + srv: srv, + newListByAPIPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIPolicyClientListByAPIResponse]](), + } +} + +// WorkspaceAPIPolicyServerTransport connects instances of armapimanagement.WorkspaceAPIPolicyClient to instances of WorkspaceAPIPolicyServer. +// Don't use this type directly, use NewWorkspaceAPIPolicyServerTransport instead. +type WorkspaceAPIPolicyServerTransport struct { + srv *WorkspaceAPIPolicyServer + newListByAPIPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIPolicyClientListByAPIResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceAPIPolicyServerTransport. +func (w *WorkspaceAPIPolicyServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPIPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPIPolicyClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceAPIPolicyClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceAPIPolicyClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceAPIPolicyClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceAPIPolicyClient.NewListByAPIPager": + res.resp, res.err = w.dispatchNewListByAPIPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPIPolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.PolicyContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceAPIPolicyClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceAPIPolicyClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, policyIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIPolicyServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, policyIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceAPIPolicyServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + formatUnescaped, err := url.QueryUnescape(qp.Get("format")) + if err != nil { + return nil, err + } + formatParam := getOptional(armapimanagement.PolicyExportFormat(formatUnescaped)) + var options *armapimanagement.WorkspaceAPIPolicyClientGetOptions + if formatParam != nil { + options = &armapimanagement.WorkspaceAPIPolicyClientGetOptions{ + Format: formatParam, + } + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, policyIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIPolicyServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, policyIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIPolicyServerTransport) dispatchNewListByAPIPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByAPIPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByAPIPager not implemented")} + } + newListByAPIPager := w.newListByAPIPager.get(req) + if newListByAPIPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListByAPIPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, nil) + newListByAPIPager = &resp + w.newListByAPIPager.add(req, newListByAPIPager) + server.PagerResponderInjectNextLinks(newListByAPIPager, req, func(page *armapimanagement.WorkspaceAPIPolicyClientListByAPIResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByAPIPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByAPIPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByAPIPager) { + w.newListByAPIPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPIPolicyServerTransport +var workspaceApiPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapirelease_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapirelease_server.go new file mode 100644 index 000000000000..facf80cdac88 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapirelease_server.go @@ -0,0 +1,468 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceAPIReleaseServer is a fake server for instances of the armapimanagement.WorkspaceAPIReleaseClient type. +type WorkspaceAPIReleaseServer struct { + // CreateOrUpdate is the fake for method WorkspaceAPIReleaseClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, parameters armapimanagement.APIReleaseContract, options *armapimanagement.WorkspaceAPIReleaseClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIReleaseClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceAPIReleaseClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, ifMatch string, options *armapimanagement.WorkspaceAPIReleaseClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIReleaseClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceAPIReleaseClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, options *armapimanagement.WorkspaceAPIReleaseClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIReleaseClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceAPIReleaseClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, options *armapimanagement.WorkspaceAPIReleaseClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIReleaseClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceAPIReleaseClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *armapimanagement.WorkspaceAPIReleaseClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceAPIReleaseClientListByServiceResponse]) + + // Update is the fake for method WorkspaceAPIReleaseClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, ifMatch string, parameters armapimanagement.APIReleaseContract, options *armapimanagement.WorkspaceAPIReleaseClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIReleaseClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceAPIReleaseServerTransport creates a new instance of WorkspaceAPIReleaseServerTransport with the provided implementation. +// The returned WorkspaceAPIReleaseServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPIReleaseClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPIReleaseServerTransport(srv *WorkspaceAPIReleaseServer) *WorkspaceAPIReleaseServerTransport { + return &WorkspaceAPIReleaseServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIReleaseClientListByServiceResponse]](), + } +} + +// WorkspaceAPIReleaseServerTransport connects instances of armapimanagement.WorkspaceAPIReleaseClient to instances of WorkspaceAPIReleaseServer. +// Don't use this type directly, use NewWorkspaceAPIReleaseServerTransport instead. +type WorkspaceAPIReleaseServerTransport struct { + srv *WorkspaceAPIReleaseServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIReleaseClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceAPIReleaseServerTransport. +func (w *WorkspaceAPIReleaseServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPIReleaseServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiReleaseServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiReleaseServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPIReleaseClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceAPIReleaseClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceAPIReleaseClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceAPIReleaseClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceAPIReleaseClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + case "WorkspaceAPIReleaseClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPIReleaseServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/releases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.APIReleaseContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + releaseIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("releaseId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceAPIReleaseClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceAPIReleaseClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, releaseIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).APIReleaseContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIReleaseServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/releases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + releaseIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("releaseId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, releaseIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceAPIReleaseServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/releases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + releaseIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("releaseId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, releaseIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).APIReleaseContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIReleaseServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/releases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + releaseIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("releaseId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, releaseIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIReleaseServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/releases` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceAPIReleaseClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceAPIReleaseClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceAPIReleaseClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceAPIReleaseServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/releases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.APIReleaseContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + releaseIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("releaseId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, releaseIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).APIReleaseContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPIReleaseServerTransport +var workspaceApiReleaseServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapirevision_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapirevision_server.go new file mode 100644 index 000000000000..75a675121a84 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapirevision_server.go @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceAPIRevisionServer is a fake server for instances of the armapimanagement.WorkspaceAPIRevisionClient type. +type WorkspaceAPIRevisionServer struct { + // NewListByServicePager is the fake for method WorkspaceAPIRevisionClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *armapimanagement.WorkspaceAPIRevisionClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceAPIRevisionClientListByServiceResponse]) +} + +// NewWorkspaceAPIRevisionServerTransport creates a new instance of WorkspaceAPIRevisionServerTransport with the provided implementation. +// The returned WorkspaceAPIRevisionServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPIRevisionClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPIRevisionServerTransport(srv *WorkspaceAPIRevisionServer) *WorkspaceAPIRevisionServerTransport { + return &WorkspaceAPIRevisionServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIRevisionClientListByServiceResponse]](), + } +} + +// WorkspaceAPIRevisionServerTransport connects instances of armapimanagement.WorkspaceAPIRevisionClient to instances of WorkspaceAPIRevisionServer. +// Don't use this type directly, use NewWorkspaceAPIRevisionServerTransport instead. +type WorkspaceAPIRevisionServerTransport struct { + srv *WorkspaceAPIRevisionServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIRevisionClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceAPIRevisionServerTransport. +func (w *WorkspaceAPIRevisionServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPIRevisionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiRevisionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiRevisionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPIRevisionClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPIRevisionServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/revisions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceAPIRevisionClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceAPIRevisionClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceAPIRevisionClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPIRevisionServerTransport +var workspaceApiRevisionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapischema_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapischema_server.go new file mode 100644 index 000000000000..b2953bbf5be5 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapischema_server.go @@ -0,0 +1,435 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceAPISchemaServer is a fake server for instances of the armapimanagement.WorkspaceAPISchemaClient type. +type WorkspaceAPISchemaServer struct { + // BeginCreateOrUpdate is the fake for method WorkspaceAPISchemaClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, parameters armapimanagement.SchemaContract, options *armapimanagement.WorkspaceAPISchemaClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.WorkspaceAPISchemaClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceAPISchemaClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, ifMatch string, options *armapimanagement.WorkspaceAPISchemaClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPISchemaClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceAPISchemaClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, options *armapimanagement.WorkspaceAPISchemaClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPISchemaClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceAPISchemaClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, options *armapimanagement.WorkspaceAPISchemaClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPISchemaClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByAPIPager is the fake for method WorkspaceAPISchemaClient.NewListByAPIPager + // HTTP status codes to indicate success: http.StatusOK + NewListByAPIPager func(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *armapimanagement.WorkspaceAPISchemaClientListByAPIOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceAPISchemaClientListByAPIResponse]) +} + +// NewWorkspaceAPISchemaServerTransport creates a new instance of WorkspaceAPISchemaServerTransport with the provided implementation. +// The returned WorkspaceAPISchemaServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPISchemaClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPISchemaServerTransport(srv *WorkspaceAPISchemaServer) *WorkspaceAPISchemaServerTransport { + return &WorkspaceAPISchemaServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.WorkspaceAPISchemaClientCreateOrUpdateResponse]](), + newListByAPIPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceAPISchemaClientListByAPIResponse]](), + } +} + +// WorkspaceAPISchemaServerTransport connects instances of armapimanagement.WorkspaceAPISchemaClient to instances of WorkspaceAPISchemaServer. +// Don't use this type directly, use NewWorkspaceAPISchemaServerTransport instead. +type WorkspaceAPISchemaServerTransport struct { + srv *WorkspaceAPISchemaServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.WorkspaceAPISchemaClientCreateOrUpdateResponse]] + newListByAPIPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceAPISchemaClientListByAPIResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceAPISchemaServerTransport. +func (w *WorkspaceAPISchemaServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPISchemaServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiSchemaServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiSchemaServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPISchemaClient.BeginCreateOrUpdate": + res.resp, res.err = w.dispatchBeginCreateOrUpdate(req) + case "WorkspaceAPISchemaClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceAPISchemaClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceAPISchemaClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceAPISchemaClient.NewListByAPIPager": + res.resp, res.err = w.dispatchNewListByAPIPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPISchemaServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := w.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.SchemaContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + schemaIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceAPISchemaClientBeginCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceAPISchemaClientBeginCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, schemaIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + w.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + w.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + w.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (w *WorkspaceAPISchemaServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + schemaIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaId")]) + if err != nil { + return nil, err + } + forceUnescaped, err := url.QueryUnescape(qp.Get("force")) + if err != nil { + return nil, err + } + forceParam, err := parseOptional(forceUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceAPISchemaClientDeleteOptions + if forceParam != nil { + options = &armapimanagement.WorkspaceAPISchemaClientDeleteOptions{ + Force: forceParam, + } + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, schemaIDParam, getHeaderValue(req.Header, "If-Match"), options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceAPISchemaServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + schemaIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, schemaIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SchemaContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPISchemaServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + schemaIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, schemaIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPISchemaServerTransport) dispatchNewListByAPIPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByAPIPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByAPIPager not implemented")} + } + newListByAPIPager := w.newListByAPIPager.get(req) + if newListByAPIPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + apiIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceAPISchemaClientListByAPIOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceAPISchemaClientListByAPIOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByAPIPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, apiIDParam, options) + newListByAPIPager = &resp + w.newListByAPIPager.add(req, newListByAPIPager) + server.PagerResponderInjectNextLinks(newListByAPIPager, req, func(page *armapimanagement.WorkspaceAPISchemaClientListByAPIResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByAPIPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByAPIPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByAPIPager) { + w.newListByAPIPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPISchemaServerTransport +var workspaceApiSchemaServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapiversionset_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapiversionset_server.go new file mode 100644 index 000000000000..0b7b9c66ce70 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceapiversionset_server.go @@ -0,0 +1,444 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceAPIVersionSetServer is a fake server for instances of the armapimanagement.WorkspaceAPIVersionSetClient type. +type WorkspaceAPIVersionSetServer struct { + // CreateOrUpdate is the fake for method WorkspaceAPIVersionSetClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, parameters armapimanagement.APIVersionSetContract, options *armapimanagement.WorkspaceAPIVersionSetClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIVersionSetClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceAPIVersionSetClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, ifMatch string, options *armapimanagement.WorkspaceAPIVersionSetClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIVersionSetClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceAPIVersionSetClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, options *armapimanagement.WorkspaceAPIVersionSetClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIVersionSetClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceAPIVersionSetClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, options *armapimanagement.WorkspaceAPIVersionSetClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIVersionSetClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceAPIVersionSetClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceAPIVersionSetClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceAPIVersionSetClientListByServiceResponse]) + + // Update is the fake for method WorkspaceAPIVersionSetClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, ifMatch string, parameters armapimanagement.APIVersionSetUpdateParameters, options *armapimanagement.WorkspaceAPIVersionSetClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceAPIVersionSetClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceAPIVersionSetServerTransport creates a new instance of WorkspaceAPIVersionSetServerTransport with the provided implementation. +// The returned WorkspaceAPIVersionSetServerTransport instance is connected to an instance of armapimanagement.WorkspaceAPIVersionSetClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceAPIVersionSetServerTransport(srv *WorkspaceAPIVersionSetServer) *WorkspaceAPIVersionSetServerTransport { + return &WorkspaceAPIVersionSetServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIVersionSetClientListByServiceResponse]](), + } +} + +// WorkspaceAPIVersionSetServerTransport connects instances of armapimanagement.WorkspaceAPIVersionSetClient to instances of WorkspaceAPIVersionSetServer. +// Don't use this type directly, use NewWorkspaceAPIVersionSetServerTransport instead. +type WorkspaceAPIVersionSetServerTransport struct { + srv *WorkspaceAPIVersionSetServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceAPIVersionSetClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceAPIVersionSetServerTransport. +func (w *WorkspaceAPIVersionSetServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceAPIVersionSetServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceApiVersionSetServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceApiVersionSetServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceAPIVersionSetClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceAPIVersionSetClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceAPIVersionSetClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceAPIVersionSetClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceAPIVersionSetClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + case "WorkspaceAPIVersionSetClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceAPIVersionSetServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiVersionSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.APIVersionSetContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + versionSetIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("versionSetId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceAPIVersionSetClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceAPIVersionSetClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, versionSetIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).APIVersionSetContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIVersionSetServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiVersionSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + versionSetIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("versionSetId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, versionSetIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceAPIVersionSetServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiVersionSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + versionSetIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("versionSetId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, versionSetIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).APIVersionSetContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIVersionSetServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiVersionSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + versionSetIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("versionSetId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, versionSetIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceAPIVersionSetServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiVersionSets` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceAPIVersionSetClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceAPIVersionSetClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceAPIVersionSetClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceAPIVersionSetServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiVersionSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.APIVersionSetUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + versionSetIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("versionSetId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, versionSetIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).APIVersionSetContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceAPIVersionSetServerTransport +var workspaceApiVersionSetServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacebackend_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacebackend_server.go new file mode 100644 index 000000000000..93c787602e11 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacebackend_server.go @@ -0,0 +1,444 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceBackendServer is a fake server for instances of the armapimanagement.WorkspaceBackendClient type. +type WorkspaceBackendServer struct { + // CreateOrUpdate is the fake for method WorkspaceBackendClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, parameters armapimanagement.BackendContract, options *armapimanagement.WorkspaceBackendClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceBackendClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceBackendClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, ifMatch string, options *armapimanagement.WorkspaceBackendClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceBackendClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceBackendClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, options *armapimanagement.WorkspaceBackendClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceBackendClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceBackendClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, options *armapimanagement.WorkspaceBackendClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceBackendClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByWorkspacePager is the fake for method WorkspaceBackendClient.NewListByWorkspacePager + // HTTP status codes to indicate success: http.StatusOK + NewListByWorkspacePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceBackendClientListByWorkspaceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceBackendClientListByWorkspaceResponse]) + + // Update is the fake for method WorkspaceBackendClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, ifMatch string, parameters armapimanagement.BackendUpdateParameters, options *armapimanagement.WorkspaceBackendClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceBackendClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceBackendServerTransport creates a new instance of WorkspaceBackendServerTransport with the provided implementation. +// The returned WorkspaceBackendServerTransport instance is connected to an instance of armapimanagement.WorkspaceBackendClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceBackendServerTransport(srv *WorkspaceBackendServer) *WorkspaceBackendServerTransport { + return &WorkspaceBackendServerTransport{ + srv: srv, + newListByWorkspacePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceBackendClientListByWorkspaceResponse]](), + } +} + +// WorkspaceBackendServerTransport connects instances of armapimanagement.WorkspaceBackendClient to instances of WorkspaceBackendServer. +// Don't use this type directly, use NewWorkspaceBackendServerTransport instead. +type WorkspaceBackendServerTransport struct { + srv *WorkspaceBackendServer + newListByWorkspacePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceBackendClientListByWorkspaceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceBackendServerTransport. +func (w *WorkspaceBackendServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceBackendServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceBackendServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceBackendServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceBackendClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceBackendClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceBackendClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceBackendClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceBackendClient.NewListByWorkspacePager": + res.resp, res.err = w.dispatchNewListByWorkspacePager(req) + case "WorkspaceBackendClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceBackendServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backends/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.BackendContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + backendIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("backendId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceBackendClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceBackendClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, backendIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BackendContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceBackendServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backends/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + backendIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("backendId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, backendIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceBackendServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backends/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + backendIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("backendId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, backendIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BackendContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceBackendServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backends/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + backendIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("backendId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, backendIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceBackendServerTransport) dispatchNewListByWorkspacePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByWorkspacePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByWorkspacePager not implemented")} + } + newListByWorkspacePager := w.newListByWorkspacePager.get(req) + if newListByWorkspacePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backends` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceBackendClientListByWorkspaceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceBackendClientListByWorkspaceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByWorkspacePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByWorkspacePager = &resp + w.newListByWorkspacePager.add(req, newListByWorkspacePager) + server.PagerResponderInjectNextLinks(newListByWorkspacePager, req, func(page *armapimanagement.WorkspaceBackendClientListByWorkspaceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByWorkspacePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByWorkspacePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByWorkspacePager) { + w.newListByWorkspacePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceBackendServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backends/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.BackendUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + backendIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("backendId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, backendIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BackendContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceBackendServerTransport +var workspaceBackendServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacecertificate_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacecertificate_server.go new file mode 100644 index 000000000000..f4ab000aaf1f --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacecertificate_server.go @@ -0,0 +1,449 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceCertificateServer is a fake server for instances of the armapimanagement.WorkspaceCertificateClient type. +type WorkspaceCertificateServer struct { + // CreateOrUpdate is the fake for method WorkspaceCertificateClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, parameters armapimanagement.CertificateCreateOrUpdateParameters, options *armapimanagement.WorkspaceCertificateClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceCertificateClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceCertificateClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, ifMatch string, options *armapimanagement.WorkspaceCertificateClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceCertificateClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceCertificateClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, options *armapimanagement.WorkspaceCertificateClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceCertificateClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceCertificateClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, options *armapimanagement.WorkspaceCertificateClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceCertificateClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByWorkspacePager is the fake for method WorkspaceCertificateClient.NewListByWorkspacePager + // HTTP status codes to indicate success: http.StatusOK + NewListByWorkspacePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceCertificateClientListByWorkspaceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceCertificateClientListByWorkspaceResponse]) + + // RefreshSecret is the fake for method WorkspaceCertificateClient.RefreshSecret + // HTTP status codes to indicate success: http.StatusOK + RefreshSecret func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, options *armapimanagement.WorkspaceCertificateClientRefreshSecretOptions) (resp azfake.Responder[armapimanagement.WorkspaceCertificateClientRefreshSecretResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceCertificateServerTransport creates a new instance of WorkspaceCertificateServerTransport with the provided implementation. +// The returned WorkspaceCertificateServerTransport instance is connected to an instance of armapimanagement.WorkspaceCertificateClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceCertificateServerTransport(srv *WorkspaceCertificateServer) *WorkspaceCertificateServerTransport { + return &WorkspaceCertificateServerTransport{ + srv: srv, + newListByWorkspacePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceCertificateClientListByWorkspaceResponse]](), + } +} + +// WorkspaceCertificateServerTransport connects instances of armapimanagement.WorkspaceCertificateClient to instances of WorkspaceCertificateServer. +// Don't use this type directly, use NewWorkspaceCertificateServerTransport instead. +type WorkspaceCertificateServerTransport struct { + srv *WorkspaceCertificateServer + newListByWorkspacePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceCertificateClientListByWorkspaceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceCertificateServerTransport. +func (w *WorkspaceCertificateServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceCertificateServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceCertificateServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceCertificateServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceCertificateClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceCertificateClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceCertificateClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceCertificateClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceCertificateClient.NewListByWorkspacePager": + res.resp, res.err = w.dispatchNewListByWorkspacePager(req) + case "WorkspaceCertificateClient.RefreshSecret": + res.resp, res.err = w.dispatchRefreshSecret(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceCertificateServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.CertificateCreateOrUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + certificateIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceCertificateClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceCertificateClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, certificateIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificateContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceCertificateServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + certificateIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, certificateIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceCertificateServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + certificateIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, certificateIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificateContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceCertificateServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + certificateIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, certificateIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceCertificateServerTransport) dispatchNewListByWorkspacePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByWorkspacePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByWorkspacePager not implemented")} + } + newListByWorkspacePager := w.newListByWorkspacePager.get(req) + if newListByWorkspacePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + isKeyVaultRefreshFailedUnescaped, err := url.QueryUnescape(qp.Get("isKeyVaultRefreshFailed")) + if err != nil { + return nil, err + } + isKeyVaultRefreshFailedParam, err := parseOptional(isKeyVaultRefreshFailedUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceCertificateClientListByWorkspaceOptions + if filterParam != nil || topParam != nil || skipParam != nil || isKeyVaultRefreshFailedParam != nil { + options = &armapimanagement.WorkspaceCertificateClientListByWorkspaceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + IsKeyVaultRefreshFailed: isKeyVaultRefreshFailedParam, + } + } + resp := w.srv.NewListByWorkspacePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByWorkspacePager = &resp + w.newListByWorkspacePager.add(req, newListByWorkspacePager) + server.PagerResponderInjectNextLinks(newListByWorkspacePager, req, func(page *armapimanagement.WorkspaceCertificateClientListByWorkspaceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByWorkspacePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByWorkspacePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByWorkspacePager) { + w.newListByWorkspacePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceCertificateServerTransport) dispatchRefreshSecret(req *http.Request) (*http.Response, error) { + if w.srv.RefreshSecret == nil { + return nil, &nonRetriableError{errors.New("fake for method RefreshSecret not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/refreshSecret` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + certificateIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.RefreshSecret(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, certificateIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificateContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceCertificateServerTransport +var workspaceCertificateServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacediagnostic_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacediagnostic_server.go new file mode 100644 index 000000000000..b864a203cb64 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacediagnostic_server.go @@ -0,0 +1,444 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceDiagnosticServer is a fake server for instances of the armapimanagement.WorkspaceDiagnosticClient type. +type WorkspaceDiagnosticServer struct { + // CreateOrUpdate is the fake for method WorkspaceDiagnosticClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, parameters armapimanagement.DiagnosticContract, options *armapimanagement.WorkspaceDiagnosticClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceDiagnosticClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceDiagnosticClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, ifMatch string, options *armapimanagement.WorkspaceDiagnosticClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceDiagnosticClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceDiagnosticClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, options *armapimanagement.WorkspaceDiagnosticClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceDiagnosticClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceDiagnosticClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, options *armapimanagement.WorkspaceDiagnosticClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceDiagnosticClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByWorkspacePager is the fake for method WorkspaceDiagnosticClient.NewListByWorkspacePager + // HTTP status codes to indicate success: http.StatusOK + NewListByWorkspacePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceDiagnosticClientListByWorkspaceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceDiagnosticClientListByWorkspaceResponse]) + + // Update is the fake for method WorkspaceDiagnosticClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, ifMatch string, parameters armapimanagement.DiagnosticUpdateContract, options *armapimanagement.WorkspaceDiagnosticClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceDiagnosticClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceDiagnosticServerTransport creates a new instance of WorkspaceDiagnosticServerTransport with the provided implementation. +// The returned WorkspaceDiagnosticServerTransport instance is connected to an instance of armapimanagement.WorkspaceDiagnosticClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceDiagnosticServerTransport(srv *WorkspaceDiagnosticServer) *WorkspaceDiagnosticServerTransport { + return &WorkspaceDiagnosticServerTransport{ + srv: srv, + newListByWorkspacePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceDiagnosticClientListByWorkspaceResponse]](), + } +} + +// WorkspaceDiagnosticServerTransport connects instances of armapimanagement.WorkspaceDiagnosticClient to instances of WorkspaceDiagnosticServer. +// Don't use this type directly, use NewWorkspaceDiagnosticServerTransport instead. +type WorkspaceDiagnosticServerTransport struct { + srv *WorkspaceDiagnosticServer + newListByWorkspacePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceDiagnosticClientListByWorkspaceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceDiagnosticServerTransport. +func (w *WorkspaceDiagnosticServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceDiagnosticServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceDiagnosticServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceDiagnosticServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceDiagnosticClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceDiagnosticClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceDiagnosticClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceDiagnosticClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceDiagnosticClient.NewListByWorkspacePager": + res.resp, res.err = w.dispatchNewListByWorkspacePager(req) + case "WorkspaceDiagnosticClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceDiagnosticServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.DiagnosticContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceDiagnosticClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceDiagnosticClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, diagnosticIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DiagnosticContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceDiagnosticServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, diagnosticIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceDiagnosticServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, diagnosticIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DiagnosticContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceDiagnosticServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, diagnosticIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceDiagnosticServerTransport) dispatchNewListByWorkspacePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByWorkspacePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByWorkspacePager not implemented")} + } + newListByWorkspacePager := w.newListByWorkspacePager.get(req) + if newListByWorkspacePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceDiagnosticClientListByWorkspaceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceDiagnosticClientListByWorkspaceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByWorkspacePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByWorkspacePager = &resp + w.newListByWorkspacePager.add(req, newListByWorkspacePager) + server.PagerResponderInjectNextLinks(newListByWorkspacePager, req, func(page *armapimanagement.WorkspaceDiagnosticClientListByWorkspaceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByWorkspacePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByWorkspacePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByWorkspacePager) { + w.newListByWorkspacePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceDiagnosticServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnostics/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.DiagnosticUpdateContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + diagnosticIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("diagnosticId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, diagnosticIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DiagnosticContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceDiagnosticServerTransport +var workspaceDiagnosticServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceglobalschema_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceglobalschema_server.go new file mode 100644 index 000000000000..b1008c101b0e --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceglobalschema_server.go @@ -0,0 +1,400 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceGlobalSchemaServer is a fake server for instances of the armapimanagement.WorkspaceGlobalSchemaClient type. +type WorkspaceGlobalSchemaServer struct { + // BeginCreateOrUpdate is the fake for method WorkspaceGlobalSchemaClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, parameters armapimanagement.GlobalSchemaContract, options *armapimanagement.WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.WorkspaceGlobalSchemaClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceGlobalSchemaClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, ifMatch string, options *armapimanagement.WorkspaceGlobalSchemaClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceGlobalSchemaClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceGlobalSchemaClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, options *armapimanagement.WorkspaceGlobalSchemaClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceGlobalSchemaClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceGlobalSchemaClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, options *armapimanagement.WorkspaceGlobalSchemaClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceGlobalSchemaClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceGlobalSchemaClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceGlobalSchemaClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceGlobalSchemaClientListByServiceResponse]) +} + +// NewWorkspaceGlobalSchemaServerTransport creates a new instance of WorkspaceGlobalSchemaServerTransport with the provided implementation. +// The returned WorkspaceGlobalSchemaServerTransport instance is connected to an instance of armapimanagement.WorkspaceGlobalSchemaClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceGlobalSchemaServerTransport(srv *WorkspaceGlobalSchemaServer) *WorkspaceGlobalSchemaServerTransport { + return &WorkspaceGlobalSchemaServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.WorkspaceGlobalSchemaClientCreateOrUpdateResponse]](), + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceGlobalSchemaClientListByServiceResponse]](), + } +} + +// WorkspaceGlobalSchemaServerTransport connects instances of armapimanagement.WorkspaceGlobalSchemaClient to instances of WorkspaceGlobalSchemaServer. +// Don't use this type directly, use NewWorkspaceGlobalSchemaServerTransport instead. +type WorkspaceGlobalSchemaServerTransport struct { + srv *WorkspaceGlobalSchemaServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.WorkspaceGlobalSchemaClientCreateOrUpdateResponse]] + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceGlobalSchemaClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceGlobalSchemaServerTransport. +func (w *WorkspaceGlobalSchemaServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceGlobalSchemaServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceGlobalSchemaServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceGlobalSchemaServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceGlobalSchemaClient.BeginCreateOrUpdate": + res.resp, res.err = w.dispatchBeginCreateOrUpdate(req) + case "WorkspaceGlobalSchemaClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceGlobalSchemaClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceGlobalSchemaClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceGlobalSchemaClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceGlobalSchemaServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := w.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.GlobalSchemaContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + schemaIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, schemaIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + w.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + w.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + w.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (w *WorkspaceGlobalSchemaServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + schemaIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, schemaIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceGlobalSchemaServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + schemaIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, schemaIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GlobalSchemaContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceGlobalSchemaServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + schemaIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, schemaIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceGlobalSchemaServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceGlobalSchemaClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceGlobalSchemaClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceGlobalSchemaClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceGlobalSchemaServerTransport +var workspaceGlobalSchemaServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacegroup_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacegroup_server.go new file mode 100644 index 000000000000..ffc902c51d79 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacegroup_server.go @@ -0,0 +1,444 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceGroupServer is a fake server for instances of the armapimanagement.WorkspaceGroupClient type. +type WorkspaceGroupServer struct { + // CreateOrUpdate is the fake for method WorkspaceGroupClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, parameters armapimanagement.GroupCreateParameters, options *armapimanagement.WorkspaceGroupClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceGroupClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceGroupClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, ifMatch string, options *armapimanagement.WorkspaceGroupClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceGroupClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceGroupClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, options *armapimanagement.WorkspaceGroupClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceGroupClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceGroupClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, options *armapimanagement.WorkspaceGroupClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceGroupClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceGroupClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceGroupClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceGroupClientListByServiceResponse]) + + // Update is the fake for method WorkspaceGroupClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, ifMatch string, parameters armapimanagement.GroupUpdateParameters, options *armapimanagement.WorkspaceGroupClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceGroupClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceGroupServerTransport creates a new instance of WorkspaceGroupServerTransport with the provided implementation. +// The returned WorkspaceGroupServerTransport instance is connected to an instance of armapimanagement.WorkspaceGroupClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceGroupServerTransport(srv *WorkspaceGroupServer) *WorkspaceGroupServerTransport { + return &WorkspaceGroupServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceGroupClientListByServiceResponse]](), + } +} + +// WorkspaceGroupServerTransport connects instances of armapimanagement.WorkspaceGroupClient to instances of WorkspaceGroupServer. +// Don't use this type directly, use NewWorkspaceGroupServerTransport instead. +type WorkspaceGroupServerTransport struct { + srv *WorkspaceGroupServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceGroupClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceGroupServerTransport. +func (w *WorkspaceGroupServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceGroupServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceGroupClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceGroupClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceGroupClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceGroupClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceGroupClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + case "WorkspaceGroupClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceGroupServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.GroupCreateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceGroupClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceGroupClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, groupIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GroupContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceGroupServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, groupIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceGroupServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, groupIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GroupContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceGroupServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, groupIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceGroupServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceGroupClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceGroupClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceGroupClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceGroupServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.GroupUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, groupIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GroupContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceGroupServerTransport +var workspaceGroupServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacegroupuser_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacegroupuser_server.go new file mode 100644 index 000000000000..ceafea901ee1 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacegroupuser_server.go @@ -0,0 +1,339 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceGroupUserServer is a fake server for instances of the armapimanagement.WorkspaceGroupUserClient type. +type WorkspaceGroupUserServer struct { + // CheckEntityExists is the fake for method WorkspaceGroupUserClient.CheckEntityExists + // HTTP status codes to indicate success: http.StatusNoContent, http.StatusNotFound + CheckEntityExists func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, userID string, options *armapimanagement.WorkspaceGroupUserClientCheckEntityExistsOptions) (resp azfake.Responder[armapimanagement.WorkspaceGroupUserClientCheckEntityExistsResponse], errResp azfake.ErrorResponder) + + // Create is the fake for method WorkspaceGroupUserClient.Create + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Create func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, userID string, options *armapimanagement.WorkspaceGroupUserClientCreateOptions) (resp azfake.Responder[armapimanagement.WorkspaceGroupUserClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceGroupUserClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, userID string, options *armapimanagement.WorkspaceGroupUserClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceGroupUserClientDeleteResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkspaceGroupUserClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, serviceName string, workspaceID string, groupID string, options *armapimanagement.WorkspaceGroupUserClientListOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceGroupUserClientListResponse]) +} + +// NewWorkspaceGroupUserServerTransport creates a new instance of WorkspaceGroupUserServerTransport with the provided implementation. +// The returned WorkspaceGroupUserServerTransport instance is connected to an instance of armapimanagement.WorkspaceGroupUserClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceGroupUserServerTransport(srv *WorkspaceGroupUserServer) *WorkspaceGroupUserServerTransport { + return &WorkspaceGroupUserServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceGroupUserClientListResponse]](), + } +} + +// WorkspaceGroupUserServerTransport connects instances of armapimanagement.WorkspaceGroupUserClient to instances of WorkspaceGroupUserServer. +// Don't use this type directly, use NewWorkspaceGroupUserServerTransport instead. +type WorkspaceGroupUserServerTransport struct { + srv *WorkspaceGroupUserServer + newListPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceGroupUserClientListResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceGroupUserServerTransport. +func (w *WorkspaceGroupUserServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceGroupUserServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceGroupUserServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceGroupUserServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceGroupUserClient.CheckEntityExists": + res.resp, res.err = w.dispatchCheckEntityExists(req) + case "WorkspaceGroupUserClient.Create": + res.resp, res.err = w.dispatchCreate(req) + case "WorkspaceGroupUserClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceGroupUserClient.NewListPager": + res.resp, res.err = w.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceGroupUserServerTransport) dispatchCheckEntityExists(req *http.Request) (*http.Response, error) { + if w.srv.CheckEntityExists == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckEntityExists not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + userIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("userId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CheckEntityExists(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, groupIDParam, userIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent, http.StatusNotFound}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent, http.StatusNotFound", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceGroupUserServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if w.srv.Create == nil { + return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + userIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("userId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Create(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, groupIDParam, userIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).UserContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceGroupUserServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + userIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("userId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, groupIDParam, userIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceGroupUserServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceGroupUserClientListOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceGroupUserClientListOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, groupIDParam, options) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armapimanagement.WorkspaceGroupUserClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceGroupUserServerTransport +var workspaceGroupUserServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacelink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacelink_server.go new file mode 100644 index 000000000000..29276c4ffedb --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacelink_server.go @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// WorkspaceLinkServer is a fake server for instances of the armapimanagement.WorkspaceLinkClient type. +type WorkspaceLinkServer struct { + // Get is the fake for method WorkspaceLinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceLinkClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceLinkClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceLinkServerTransport creates a new instance of WorkspaceLinkServerTransport with the provided implementation. +// The returned WorkspaceLinkServerTransport instance is connected to an instance of armapimanagement.WorkspaceLinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceLinkServerTransport(srv *WorkspaceLinkServer) *WorkspaceLinkServerTransport { + return &WorkspaceLinkServerTransport{srv: srv} +} + +// WorkspaceLinkServerTransport connects instances of armapimanagement.WorkspaceLinkClient to instances of WorkspaceLinkServer. +// Don't use this type directly, use NewWorkspaceLinkServerTransport instead. +type WorkspaceLinkServerTransport struct { + srv *WorkspaceLinkServer +} + +// Do implements the policy.Transporter interface for WorkspaceLinkServerTransport. +func (w *WorkspaceLinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceLinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceLinkClient.Get": + res.resp, res.err = w.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceLinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaceLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).WorkspaceLinksResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceLinkServerTransport +var workspaceLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacelinks_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacelinks_server.go new file mode 100644 index 000000000000..f2a71651fe32 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacelinks_server.go @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// WorkspaceLinksServer is a fake server for instances of the armapimanagement.WorkspaceLinksClient type. +type WorkspaceLinksServer struct { + // NewListByServicePager is the fake for method WorkspaceLinksClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, options *armapimanagement.WorkspaceLinksClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceLinksClientListByServiceResponse]) +} + +// NewWorkspaceLinksServerTransport creates a new instance of WorkspaceLinksServerTransport with the provided implementation. +// The returned WorkspaceLinksServerTransport instance is connected to an instance of armapimanagement.WorkspaceLinksClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceLinksServerTransport(srv *WorkspaceLinksServer) *WorkspaceLinksServerTransport { + return &WorkspaceLinksServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceLinksClientListByServiceResponse]](), + } +} + +// WorkspaceLinksServerTransport connects instances of armapimanagement.WorkspaceLinksClient to instances of WorkspaceLinksServer. +// Don't use this type directly, use NewWorkspaceLinksServerTransport instead. +type WorkspaceLinksServerTransport struct { + srv *WorkspaceLinksServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceLinksClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceLinksServerTransport. +func (w *WorkspaceLinksServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceLinksServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceLinksServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceLinksServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceLinksClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceLinksServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaceLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, nil) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceLinksClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceLinksServerTransport +var workspaceLinksServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacelogger_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacelogger_server.go new file mode 100644 index 000000000000..984df353cfd2 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacelogger_server.go @@ -0,0 +1,444 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceLoggerServer is a fake server for instances of the armapimanagement.WorkspaceLoggerClient type. +type WorkspaceLoggerServer struct { + // CreateOrUpdate is the fake for method WorkspaceLoggerClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, parameters armapimanagement.LoggerContract, options *armapimanagement.WorkspaceLoggerClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceLoggerClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceLoggerClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, ifMatch string, options *armapimanagement.WorkspaceLoggerClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceLoggerClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceLoggerClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, options *armapimanagement.WorkspaceLoggerClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceLoggerClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceLoggerClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, options *armapimanagement.WorkspaceLoggerClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceLoggerClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByWorkspacePager is the fake for method WorkspaceLoggerClient.NewListByWorkspacePager + // HTTP status codes to indicate success: http.StatusOK + NewListByWorkspacePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceLoggerClientListByWorkspaceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceLoggerClientListByWorkspaceResponse]) + + // Update is the fake for method WorkspaceLoggerClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, ifMatch string, parameters armapimanagement.LoggerUpdateContract, options *armapimanagement.WorkspaceLoggerClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceLoggerClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceLoggerServerTransport creates a new instance of WorkspaceLoggerServerTransport with the provided implementation. +// The returned WorkspaceLoggerServerTransport instance is connected to an instance of armapimanagement.WorkspaceLoggerClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceLoggerServerTransport(srv *WorkspaceLoggerServer) *WorkspaceLoggerServerTransport { + return &WorkspaceLoggerServerTransport{ + srv: srv, + newListByWorkspacePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceLoggerClientListByWorkspaceResponse]](), + } +} + +// WorkspaceLoggerServerTransport connects instances of armapimanagement.WorkspaceLoggerClient to instances of WorkspaceLoggerServer. +// Don't use this type directly, use NewWorkspaceLoggerServerTransport instead. +type WorkspaceLoggerServerTransport struct { + srv *WorkspaceLoggerServer + newListByWorkspacePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceLoggerClientListByWorkspaceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceLoggerServerTransport. +func (w *WorkspaceLoggerServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceLoggerServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceLoggerServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceLoggerServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceLoggerClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceLoggerClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceLoggerClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceLoggerClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceLoggerClient.NewListByWorkspacePager": + res.resp, res.err = w.dispatchNewListByWorkspacePager(req) + case "WorkspaceLoggerClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceLoggerServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/loggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.LoggerContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + loggerIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("loggerId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceLoggerClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceLoggerClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, loggerIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LoggerContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceLoggerServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/loggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + loggerIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("loggerId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, loggerIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceLoggerServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/loggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + loggerIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("loggerId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, loggerIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LoggerContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceLoggerServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/loggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + loggerIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("loggerId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, loggerIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceLoggerServerTransport) dispatchNewListByWorkspacePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByWorkspacePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByWorkspacePager not implemented")} + } + newListByWorkspacePager := w.newListByWorkspacePager.get(req) + if newListByWorkspacePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/loggers` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceLoggerClientListByWorkspaceOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceLoggerClientListByWorkspaceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByWorkspacePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByWorkspacePager = &resp + w.newListByWorkspacePager.add(req, newListByWorkspacePager) + server.PagerResponderInjectNextLinks(newListByWorkspacePager, req, func(page *armapimanagement.WorkspaceLoggerClientListByWorkspaceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByWorkspacePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByWorkspacePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByWorkspacePager) { + w.newListByWorkspacePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceLoggerServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/loggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.LoggerUpdateContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + loggerIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("loggerId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, loggerIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LoggerContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceLoggerServerTransport +var workspaceLoggerServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenamedvalue_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenamedvalue_server.go new file mode 100644 index 000000000000..e2ee13f5a6dd --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenamedvalue_server.go @@ -0,0 +1,580 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceNamedValueServer is a fake server for instances of the armapimanagement.WorkspaceNamedValueClient type. +type WorkspaceNamedValueServer struct { + // BeginCreateOrUpdate is the fake for method WorkspaceNamedValueClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, parameters armapimanagement.NamedValueCreateContract, options *armapimanagement.WorkspaceNamedValueClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceNamedValueClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, ifMatch string, options *armapimanagement.WorkspaceNamedValueClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceNamedValueClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceNamedValueClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *armapimanagement.WorkspaceNamedValueClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceNamedValueClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceNamedValueClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *armapimanagement.WorkspaceNamedValueClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceNamedValueClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceNamedValueClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceNamedValueClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceNamedValueClientListByServiceResponse]) + + // ListValue is the fake for method WorkspaceNamedValueClient.ListValue + // HTTP status codes to indicate success: http.StatusOK + ListValue func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *armapimanagement.WorkspaceNamedValueClientListValueOptions) (resp azfake.Responder[armapimanagement.WorkspaceNamedValueClientListValueResponse], errResp azfake.ErrorResponder) + + // BeginRefreshSecret is the fake for method WorkspaceNamedValueClient.BeginRefreshSecret + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginRefreshSecret func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *armapimanagement.WorkspaceNamedValueClientBeginRefreshSecretOptions) (resp azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientRefreshSecretResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method WorkspaceNamedValueClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, ifMatch string, parameters armapimanagement.NamedValueUpdateParameters, options *armapimanagement.WorkspaceNamedValueClientBeginUpdateOptions) (resp azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceNamedValueServerTransport creates a new instance of WorkspaceNamedValueServerTransport with the provided implementation. +// The returned WorkspaceNamedValueServerTransport instance is connected to an instance of armapimanagement.WorkspaceNamedValueClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceNamedValueServerTransport(srv *WorkspaceNamedValueServer) *WorkspaceNamedValueServerTransport { + return &WorkspaceNamedValueServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientCreateOrUpdateResponse]](), + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceNamedValueClientListByServiceResponse]](), + beginRefreshSecret: newTracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientRefreshSecretResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientUpdateResponse]](), + } +} + +// WorkspaceNamedValueServerTransport connects instances of armapimanagement.WorkspaceNamedValueClient to instances of WorkspaceNamedValueServer. +// Don't use this type directly, use NewWorkspaceNamedValueServerTransport instead. +type WorkspaceNamedValueServerTransport struct { + srv *WorkspaceNamedValueServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientCreateOrUpdateResponse]] + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceNamedValueClientListByServiceResponse]] + beginRefreshSecret *tracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientRefreshSecretResponse]] + beginUpdate *tracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceNamedValueServerTransport. +func (w *WorkspaceNamedValueServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceNamedValueServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceNamedValueServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceNamedValueServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceNamedValueClient.BeginCreateOrUpdate": + res.resp, res.err = w.dispatchBeginCreateOrUpdate(req) + case "WorkspaceNamedValueClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceNamedValueClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceNamedValueClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceNamedValueClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + case "WorkspaceNamedValueClient.ListValue": + res.resp, res.err = w.dispatchListValue(req) + case "WorkspaceNamedValueClient.BeginRefreshSecret": + res.resp, res.err = w.dispatchBeginRefreshSecret(req) + case "WorkspaceNamedValueClient.BeginUpdate": + res.resp, res.err = w.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceNamedValueServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := w.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.NamedValueCreateContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceNamedValueClientBeginCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceNamedValueClientBeginCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + w.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + w.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + w.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (w *WorkspaceNamedValueServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceNamedValueServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).NamedValueContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceNamedValueServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceNamedValueServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + isKeyVaultRefreshFailedUnescaped, err := url.QueryUnescape(qp.Get("isKeyVaultRefreshFailed")) + if err != nil { + return nil, err + } + isKeyVaultRefreshFailedParam := getOptional(armapimanagement.KeyVaultRefreshState(isKeyVaultRefreshFailedUnescaped)) + var options *armapimanagement.WorkspaceNamedValueClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil || isKeyVaultRefreshFailedParam != nil { + options = &armapimanagement.WorkspaceNamedValueClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + IsKeyVaultRefreshFailed: isKeyVaultRefreshFailedParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceNamedValueClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceNamedValueServerTransport) dispatchListValue(req *http.Request) (*http.Response, error) { + if w.srv.ListValue == nil { + return nil, &nonRetriableError{errors.New("fake for method ListValue not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listValue` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ListValue(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).NamedValueSecretContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceNamedValueServerTransport) dispatchBeginRefreshSecret(req *http.Request) (*http.Response, error) { + if w.srv.BeginRefreshSecret == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginRefreshSecret not implemented")} + } + beginRefreshSecret := w.beginRefreshSecret.get(req) + if beginRefreshSecret == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/refreshSecret` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginRefreshSecret(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginRefreshSecret = &respr + w.beginRefreshSecret.add(req, beginRefreshSecret) + } + + resp, err := server.PollerResponderNext(beginRefreshSecret, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + w.beginRefreshSecret.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginRefreshSecret) { + w.beginRefreshSecret.remove(req) + } + + return resp, nil +} + +func (w *WorkspaceNamedValueServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := w.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.NamedValueUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + w.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + w.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + w.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceNamedValueServerTransport +var workspaceNamedValueServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenotification_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenotification_server.go new file mode 100644 index 000000000000..1dc21e9015ad --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenotification_server.go @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceNotificationServer is a fake server for instances of the armapimanagement.WorkspaceNotificationClient type. +type WorkspaceNotificationServer struct { + // CreateOrUpdate is the fake for method WorkspaceNotificationClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, options *armapimanagement.WorkspaceNotificationClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceNotificationClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, options *armapimanagement.WorkspaceNotificationClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceNotificationClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceNotificationClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceNotificationClientListByServiceResponse]) +} + +// NewWorkspaceNotificationServerTransport creates a new instance of WorkspaceNotificationServerTransport with the provided implementation. +// The returned WorkspaceNotificationServerTransport instance is connected to an instance of armapimanagement.WorkspaceNotificationClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceNotificationServerTransport(srv *WorkspaceNotificationServer) *WorkspaceNotificationServerTransport { + return &WorkspaceNotificationServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceNotificationClientListByServiceResponse]](), + } +} + +// WorkspaceNotificationServerTransport connects instances of armapimanagement.WorkspaceNotificationClient to instances of WorkspaceNotificationServer. +// Don't use this type directly, use NewWorkspaceNotificationServerTransport instead. +type WorkspaceNotificationServerTransport struct { + srv *WorkspaceNotificationServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceNotificationClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceNotificationServerTransport. +func (w *WorkspaceNotificationServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceNotificationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceNotificationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceNotificationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceNotificationClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceNotificationClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceNotificationClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceNotificationServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceNotificationClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceNotificationClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).NotificationContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceNotificationServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).NotificationContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceNotificationServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceNotificationClientListByServiceOptions + if topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceNotificationClientListByServiceOptions{ + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceNotificationClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceNotificationServerTransport +var workspaceNotificationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenotificationrecipientemail_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenotificationrecipientemail_server.go new file mode 100644 index 000000000000..dbef9c43b512 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenotificationrecipientemail_server.go @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// WorkspaceNotificationRecipientEmailServer is a fake server for instances of the armapimanagement.WorkspaceNotificationRecipientEmailClient type. +type WorkspaceNotificationRecipientEmailServer struct { + // CheckEntityExists is the fake for method WorkspaceNotificationRecipientEmailClient.CheckEntityExists + // HTTP status codes to indicate success: http.StatusNoContent, http.StatusNotFound + CheckEntityExists func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, email string, options *armapimanagement.WorkspaceNotificationRecipientEmailClientCheckEntityExistsOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationRecipientEmailClientCheckEntityExistsResponse], errResp azfake.ErrorResponder) + + // CreateOrUpdate is the fake for method WorkspaceNotificationRecipientEmailClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, email string, options *armapimanagement.WorkspaceNotificationRecipientEmailClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceNotificationRecipientEmailClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, email string, options *armapimanagement.WorkspaceNotificationRecipientEmailClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationRecipientEmailClientDeleteResponse], errResp azfake.ErrorResponder) + + // ListByNotification is the fake for method WorkspaceNotificationRecipientEmailClient.ListByNotification + // HTTP status codes to indicate success: http.StatusOK + ListByNotification func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, options *armapimanagement.WorkspaceNotificationRecipientEmailClientListByNotificationOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationRecipientEmailClientListByNotificationResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceNotificationRecipientEmailServerTransport creates a new instance of WorkspaceNotificationRecipientEmailServerTransport with the provided implementation. +// The returned WorkspaceNotificationRecipientEmailServerTransport instance is connected to an instance of armapimanagement.WorkspaceNotificationRecipientEmailClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceNotificationRecipientEmailServerTransport(srv *WorkspaceNotificationRecipientEmailServer) *WorkspaceNotificationRecipientEmailServerTransport { + return &WorkspaceNotificationRecipientEmailServerTransport{srv: srv} +} + +// WorkspaceNotificationRecipientEmailServerTransport connects instances of armapimanagement.WorkspaceNotificationRecipientEmailClient to instances of WorkspaceNotificationRecipientEmailServer. +// Don't use this type directly, use NewWorkspaceNotificationRecipientEmailServerTransport instead. +type WorkspaceNotificationRecipientEmailServerTransport struct { + srv *WorkspaceNotificationRecipientEmailServer +} + +// Do implements the policy.Transporter interface for WorkspaceNotificationRecipientEmailServerTransport. +func (w *WorkspaceNotificationRecipientEmailServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceNotificationRecipientEmailServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceNotificationRecipientEmailServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceNotificationRecipientEmailServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceNotificationRecipientEmailClient.CheckEntityExists": + res.resp, res.err = w.dispatchCheckEntityExists(req) + case "WorkspaceNotificationRecipientEmailClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceNotificationRecipientEmailClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceNotificationRecipientEmailClient.ListByNotification": + res.resp, res.err = w.dispatchListByNotification(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceNotificationRecipientEmailServerTransport) dispatchCheckEntityExists(req *http.Request) (*http.Response, error) { + if w.srv.CheckEntityExists == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckEntityExists not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recipientEmails/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + emailParam, err := url.PathUnescape(matches[regex.SubexpIndex("email")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CheckEntityExists(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, emailParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent, http.StatusNotFound}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent, http.StatusNotFound", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceNotificationRecipientEmailServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recipientEmails/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + emailParam, err := url.PathUnescape(matches[regex.SubexpIndex("email")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, emailParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RecipientEmailContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceNotificationRecipientEmailServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recipientEmails/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + emailParam, err := url.PathUnescape(matches[regex.SubexpIndex("email")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, emailParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceNotificationRecipientEmailServerTransport) dispatchListByNotification(req *http.Request) (*http.Response, error) { + if w.srv.ListByNotification == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByNotification not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recipientEmails` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ListByNotification(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RecipientEmailCollection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceNotificationRecipientEmailServerTransport +var workspaceNotificationRecipientEmailServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenotificationrecipientuser_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenotificationrecipientuser_server.go new file mode 100644 index 000000000000..c082374528fa --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenotificationrecipientuser_server.go @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// WorkspaceNotificationRecipientUserServer is a fake server for instances of the armapimanagement.WorkspaceNotificationRecipientUserClient type. +type WorkspaceNotificationRecipientUserServer struct { + // CheckEntityExists is the fake for method WorkspaceNotificationRecipientUserClient.CheckEntityExists + // HTTP status codes to indicate success: http.StatusNoContent, http.StatusNotFound + CheckEntityExists func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, userID string, options *armapimanagement.WorkspaceNotificationRecipientUserClientCheckEntityExistsOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationRecipientUserClientCheckEntityExistsResponse], errResp azfake.ErrorResponder) + + // CreateOrUpdate is the fake for method WorkspaceNotificationRecipientUserClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, userID string, options *armapimanagement.WorkspaceNotificationRecipientUserClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceNotificationRecipientUserClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, userID string, options *armapimanagement.WorkspaceNotificationRecipientUserClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationRecipientUserClientDeleteResponse], errResp azfake.ErrorResponder) + + // ListByNotification is the fake for method WorkspaceNotificationRecipientUserClient.ListByNotification + // HTTP status codes to indicate success: http.StatusOK + ListByNotification func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName armapimanagement.NotificationName, options *armapimanagement.WorkspaceNotificationRecipientUserClientListByNotificationOptions) (resp azfake.Responder[armapimanagement.WorkspaceNotificationRecipientUserClientListByNotificationResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceNotificationRecipientUserServerTransport creates a new instance of WorkspaceNotificationRecipientUserServerTransport with the provided implementation. +// The returned WorkspaceNotificationRecipientUserServerTransport instance is connected to an instance of armapimanagement.WorkspaceNotificationRecipientUserClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceNotificationRecipientUserServerTransport(srv *WorkspaceNotificationRecipientUserServer) *WorkspaceNotificationRecipientUserServerTransport { + return &WorkspaceNotificationRecipientUserServerTransport{srv: srv} +} + +// WorkspaceNotificationRecipientUserServerTransport connects instances of armapimanagement.WorkspaceNotificationRecipientUserClient to instances of WorkspaceNotificationRecipientUserServer. +// Don't use this type directly, use NewWorkspaceNotificationRecipientUserServerTransport instead. +type WorkspaceNotificationRecipientUserServerTransport struct { + srv *WorkspaceNotificationRecipientUserServer +} + +// Do implements the policy.Transporter interface for WorkspaceNotificationRecipientUserServerTransport. +func (w *WorkspaceNotificationRecipientUserServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceNotificationRecipientUserServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceNotificationRecipientUserServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceNotificationRecipientUserServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceNotificationRecipientUserClient.CheckEntityExists": + res.resp, res.err = w.dispatchCheckEntityExists(req) + case "WorkspaceNotificationRecipientUserClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceNotificationRecipientUserClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceNotificationRecipientUserClient.ListByNotification": + res.resp, res.err = w.dispatchListByNotification(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceNotificationRecipientUserServerTransport) dispatchCheckEntityExists(req *http.Request) (*http.Response, error) { + if w.srv.CheckEntityExists == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckEntityExists not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recipientUsers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + userIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("userId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CheckEntityExists(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, userIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent, http.StatusNotFound}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent, http.StatusNotFound", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceNotificationRecipientUserServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recipientUsers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + userIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("userId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, userIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RecipientUserContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceNotificationRecipientUserServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recipientUsers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + userIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("userId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, userIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceNotificationRecipientUserServerTransport) dispatchListByNotification(req *http.Request) (*http.Response, error) { + if w.srv.ListByNotification == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByNotification not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recipientUsers` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + notificationNameParam, err := parseWithCast(matches[regex.SubexpIndex("notificationName")], func(v string) (armapimanagement.NotificationName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.NotificationName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ListByNotification(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, notificationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RecipientUserCollection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceNotificationRecipientUserServerTransport +var workspaceNotificationRecipientUserServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacepolicy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacepolicy_server.go new file mode 100644 index 000000000000..e05a533033f8 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacepolicy_server.go @@ -0,0 +1,383 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// WorkspacePolicyServer is a fake server for instances of the armapimanagement.WorkspacePolicyClient type. +type WorkspacePolicyServer struct { + // CreateOrUpdate is the fake for method WorkspacePolicyClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID armapimanagement.PolicyIDName, parameters armapimanagement.PolicyContract, options *armapimanagement.WorkspacePolicyClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspacePolicyClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspacePolicyClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID armapimanagement.PolicyIDName, ifMatch string, options *armapimanagement.WorkspacePolicyClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspacePolicyClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspacePolicyClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID armapimanagement.PolicyIDName, options *armapimanagement.WorkspacePolicyClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspacePolicyClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspacePolicyClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID armapimanagement.PolicyIDName, options *armapimanagement.WorkspacePolicyClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspacePolicyClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByAPIPager is the fake for method WorkspacePolicyClient.NewListByAPIPager + // HTTP status codes to indicate success: http.StatusOK + NewListByAPIPager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspacePolicyClientListByAPIOptions) (resp azfake.PagerResponder[armapimanagement.WorkspacePolicyClientListByAPIResponse]) +} + +// NewWorkspacePolicyServerTransport creates a new instance of WorkspacePolicyServerTransport with the provided implementation. +// The returned WorkspacePolicyServerTransport instance is connected to an instance of armapimanagement.WorkspacePolicyClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspacePolicyServerTransport(srv *WorkspacePolicyServer) *WorkspacePolicyServerTransport { + return &WorkspacePolicyServerTransport{ + srv: srv, + newListByAPIPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspacePolicyClientListByAPIResponse]](), + } +} + +// WorkspacePolicyServerTransport connects instances of armapimanagement.WorkspacePolicyClient to instances of WorkspacePolicyServer. +// Don't use this type directly, use NewWorkspacePolicyServerTransport instead. +type WorkspacePolicyServerTransport struct { + srv *WorkspacePolicyServer + newListByAPIPager *tracker[azfake.PagerResponder[armapimanagement.WorkspacePolicyClientListByAPIResponse]] +} + +// Do implements the policy.Transporter interface for WorkspacePolicyServerTransport. +func (w *WorkspacePolicyServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspacePolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspacePolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspacePolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspacePolicyClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspacePolicyClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspacePolicyClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspacePolicyClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspacePolicyClient.NewListByAPIPager": + res.resp, res.err = w.dispatchNewListByAPIPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspacePolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.PolicyContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspacePolicyClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspacePolicyClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, policyIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspacePolicyServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, policyIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspacePolicyServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + formatUnescaped, err := url.QueryUnescape(qp.Get("format")) + if err != nil { + return nil, err + } + formatParam := getOptional(armapimanagement.PolicyExportFormat(formatUnescaped)) + var options *armapimanagement.WorkspacePolicyClientGetOptions + if formatParam != nil { + options = &armapimanagement.WorkspacePolicyClientGetOptions{ + Format: formatParam, + } + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, policyIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspacePolicyServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, policyIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspacePolicyServerTransport) dispatchNewListByAPIPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByAPIPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByAPIPager not implemented")} + } + newListByAPIPager := w.newListByAPIPager.get(req) + if newListByAPIPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListByAPIPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, nil) + newListByAPIPager = &resp + w.newListByAPIPager.add(req, newListByAPIPager) + server.PagerResponderInjectNextLinks(newListByAPIPager, req, func(page *armapimanagement.WorkspacePolicyClientListByAPIResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByAPIPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByAPIPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByAPIPager) { + w.newListByAPIPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspacePolicyServerTransport +var workspacePolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacepolicyfragment_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacepolicyfragment_server.go new file mode 100644 index 000000000000..f4c5b94807f9 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacepolicyfragment_server.go @@ -0,0 +1,501 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspacePolicyFragmentServer is a fake server for instances of the armapimanagement.WorkspacePolicyFragmentClient type. +type WorkspacePolicyFragmentServer struct { + // BeginCreateOrUpdate is the fake for method WorkspacePolicyFragmentClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, parameters armapimanagement.PolicyFragmentContract, options *armapimanagement.WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.WorkspacePolicyFragmentClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspacePolicyFragmentClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, ifMatch string, options *armapimanagement.WorkspacePolicyFragmentClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspacePolicyFragmentClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspacePolicyFragmentClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, options *armapimanagement.WorkspacePolicyFragmentClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspacePolicyFragmentClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspacePolicyFragmentClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, options *armapimanagement.WorkspacePolicyFragmentClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspacePolicyFragmentClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspacePolicyFragmentClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspacePolicyFragmentClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspacePolicyFragmentClientListByServiceResponse]) + + // ListReferences is the fake for method WorkspacePolicyFragmentClient.ListReferences + // HTTP status codes to indicate success: http.StatusOK + ListReferences func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, options *armapimanagement.WorkspacePolicyFragmentClientListReferencesOptions) (resp azfake.Responder[armapimanagement.WorkspacePolicyFragmentClientListReferencesResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspacePolicyFragmentServerTransport creates a new instance of WorkspacePolicyFragmentServerTransport with the provided implementation. +// The returned WorkspacePolicyFragmentServerTransport instance is connected to an instance of armapimanagement.WorkspacePolicyFragmentClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspacePolicyFragmentServerTransport(srv *WorkspacePolicyFragmentServer) *WorkspacePolicyFragmentServerTransport { + return &WorkspacePolicyFragmentServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.WorkspacePolicyFragmentClientCreateOrUpdateResponse]](), + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspacePolicyFragmentClientListByServiceResponse]](), + } +} + +// WorkspacePolicyFragmentServerTransport connects instances of armapimanagement.WorkspacePolicyFragmentClient to instances of WorkspacePolicyFragmentServer. +// Don't use this type directly, use NewWorkspacePolicyFragmentServerTransport instead. +type WorkspacePolicyFragmentServerTransport struct { + srv *WorkspacePolicyFragmentServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.WorkspacePolicyFragmentClientCreateOrUpdateResponse]] + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspacePolicyFragmentClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspacePolicyFragmentServerTransport. +func (w *WorkspacePolicyFragmentServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspacePolicyFragmentServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspacePolicyFragmentServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspacePolicyFragmentServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspacePolicyFragmentClient.BeginCreateOrUpdate": + res.resp, res.err = w.dispatchBeginCreateOrUpdate(req) + case "WorkspacePolicyFragmentClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspacePolicyFragmentClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspacePolicyFragmentClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspacePolicyFragmentClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + case "WorkspacePolicyFragmentClient.ListReferences": + res.resp, res.err = w.dispatchListReferences(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspacePolicyFragmentServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := w.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyFragments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.PolicyFragmentContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + idParam, err := url.PathUnescape(matches[regex.SubexpIndex("id")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, idParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + w.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + w.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + w.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (w *WorkspacePolicyFragmentServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyFragments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + idParam, err := url.PathUnescape(matches[regex.SubexpIndex("id")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, idParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspacePolicyFragmentServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyFragments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + idParam, err := url.PathUnescape(matches[regex.SubexpIndex("id")]) + if err != nil { + return nil, err + } + formatUnescaped, err := url.QueryUnescape(qp.Get("format")) + if err != nil { + return nil, err + } + formatParam := getOptional(armapimanagement.PolicyFragmentContentFormat(formatUnescaped)) + var options *armapimanagement.WorkspacePolicyFragmentClientGetOptions + if formatParam != nil { + options = &armapimanagement.WorkspacePolicyFragmentClientGetOptions{ + Format: formatParam, + } + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, idParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyFragmentContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspacePolicyFragmentServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyFragments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + idParam, err := url.PathUnescape(matches[regex.SubexpIndex("id")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, idParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspacePolicyFragmentServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyFragments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + orderbyUnescaped, err := url.QueryUnescape(qp.Get("$orderby")) + if err != nil { + return nil, err + } + orderbyParam := getOptional(orderbyUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspacePolicyFragmentClientListByServiceOptions + if filterParam != nil || orderbyParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspacePolicyFragmentClientListByServiceOptions{ + Filter: filterParam, + Orderby: orderbyParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspacePolicyFragmentClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +func (w *WorkspacePolicyFragmentServerTransport) dispatchListReferences(req *http.Request) (*http.Response, error) { + if w.srv.ListReferences == nil { + return nil, &nonRetriableError{errors.New("fake for method ListReferences not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policyFragments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listReferences` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + idParam, err := url.PathUnescape(matches[regex.SubexpIndex("id")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspacePolicyFragmentClientListReferencesOptions + if topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspacePolicyFragmentClientListReferencesOptions{ + Top: topParam, + Skip: skipParam, + } + } + respr, errRespr := w.srv.ListReferences(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, idParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ResourceCollection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspacePolicyFragmentServerTransport +var workspacePolicyFragmentServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproduct_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproduct_server.go new file mode 100644 index 000000000000..f910728c3ba7 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproduct_server.go @@ -0,0 +1,474 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceProductServer is a fake server for instances of the armapimanagement.WorkspaceProductClient type. +type WorkspaceProductServer struct { + // CreateOrUpdate is the fake for method WorkspaceProductClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, parameters armapimanagement.ProductContract, options *armapimanagement.WorkspaceProductClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceProductClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, ifMatch string, options *armapimanagement.WorkspaceProductClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceProductClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, options *armapimanagement.WorkspaceProductClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceProductClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, options *armapimanagement.WorkspaceProductClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceProductClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceProductClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceProductClientListByServiceResponse]) + + // Update is the fake for method WorkspaceProductClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, ifMatch string, parameters armapimanagement.ProductUpdateParameters, options *armapimanagement.WorkspaceProductClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceProductServerTransport creates a new instance of WorkspaceProductServerTransport with the provided implementation. +// The returned WorkspaceProductServerTransport instance is connected to an instance of armapimanagement.WorkspaceProductClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceProductServerTransport(srv *WorkspaceProductServer) *WorkspaceProductServerTransport { + return &WorkspaceProductServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceProductClientListByServiceResponse]](), + } +} + +// WorkspaceProductServerTransport connects instances of armapimanagement.WorkspaceProductClient to instances of WorkspaceProductServer. +// Don't use this type directly, use NewWorkspaceProductServerTransport instead. +type WorkspaceProductServerTransport struct { + srv *WorkspaceProductServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceProductClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceProductServerTransport. +func (w *WorkspaceProductServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceProductServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceProductServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceProductServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceProductClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceProductClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceProductClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceProductClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceProductClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + case "WorkspaceProductClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceProductServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.ProductContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceProductClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceProductClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceProductServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + deleteSubscriptionsUnescaped, err := url.QueryUnescape(qp.Get("deleteSubscriptions")) + if err != nil { + return nil, err + } + deleteSubscriptionsParam, err := parseOptional(deleteSubscriptionsUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceProductClientDeleteOptions + if deleteSubscriptionsParam != nil { + options = &armapimanagement.WorkspaceProductClientDeleteOptions{ + DeleteSubscriptions: deleteSubscriptionsParam, + } + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, getHeaderValue(req.Header, "If-Match"), options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceProductServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceProductServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceProductServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + expandGroupsUnescaped, err := url.QueryUnescape(qp.Get("expandGroups")) + if err != nil { + return nil, err + } + expandGroupsParam, err := parseOptional(expandGroupsUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + tagsUnescaped, err := url.QueryUnescape(qp.Get("tags")) + if err != nil { + return nil, err + } + tagsParam := getOptional(tagsUnescaped) + var options *armapimanagement.WorkspaceProductClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil || expandGroupsParam != nil || tagsParam != nil { + options = &armapimanagement.WorkspaceProductClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + ExpandGroups: expandGroupsParam, + Tags: tagsParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceProductClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceProductServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.ProductUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceProductServerTransport +var workspaceProductServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproductapilink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproductapilink_server.go new file mode 100644 index 000000000000..5d3ce7c6f314 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproductapilink_server.go @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceProductAPILinkServer is a fake server for instances of the armapimanagement.WorkspaceProductAPILinkClient type. +type WorkspaceProductAPILinkServer struct { + // CreateOrUpdate is the fake for method WorkspaceProductAPILinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, apiLinkID string, parameters armapimanagement.ProductAPILinkContract, options *armapimanagement.WorkspaceProductAPILinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductAPILinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceProductAPILinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, apiLinkID string, options *armapimanagement.WorkspaceProductAPILinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductAPILinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceProductAPILinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, apiLinkID string, options *armapimanagement.WorkspaceProductAPILinkClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductAPILinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method WorkspaceProductAPILinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, workspaceID string, productID string, options *armapimanagement.WorkspaceProductAPILinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceProductAPILinkClientListByProductResponse]) +} + +// NewWorkspaceProductAPILinkServerTransport creates a new instance of WorkspaceProductAPILinkServerTransport with the provided implementation. +// The returned WorkspaceProductAPILinkServerTransport instance is connected to an instance of armapimanagement.WorkspaceProductAPILinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceProductAPILinkServerTransport(srv *WorkspaceProductAPILinkServer) *WorkspaceProductAPILinkServerTransport { + return &WorkspaceProductAPILinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceProductAPILinkClientListByProductResponse]](), + } +} + +// WorkspaceProductAPILinkServerTransport connects instances of armapimanagement.WorkspaceProductAPILinkClient to instances of WorkspaceProductAPILinkServer. +// Don't use this type directly, use NewWorkspaceProductAPILinkServerTransport instead. +type WorkspaceProductAPILinkServerTransport struct { + srv *WorkspaceProductAPILinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceProductAPILinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceProductAPILinkServerTransport. +func (w *WorkspaceProductAPILinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceProductAPILinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceProductApiLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceProductApiLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceProductAPILinkClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceProductAPILinkClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceProductAPILinkClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceProductAPILinkClient.NewListByProductPager": + res.resp, res.err = w.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceProductAPILinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.ProductAPILinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, apiLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductAPILinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceProductAPILinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, apiLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceProductAPILinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, apiLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductAPILinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceProductAPILinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := w.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceProductAPILinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceProductAPILinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, options) + newListByProductPager = &resp + w.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.WorkspaceProductAPILinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + w.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceProductAPILinkServerTransport +var workspaceProductApiLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproductgrouplink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproductgrouplink_server.go new file mode 100644 index 000000000000..07687ae4f65e --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproductgrouplink_server.go @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceProductGroupLinkServer is a fake server for instances of the armapimanagement.WorkspaceProductGroupLinkClient type. +type WorkspaceProductGroupLinkServer struct { + // CreateOrUpdate is the fake for method WorkspaceProductGroupLinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, groupLinkID string, parameters armapimanagement.ProductGroupLinkContract, options *armapimanagement.WorkspaceProductGroupLinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductGroupLinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceProductGroupLinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, groupLinkID string, options *armapimanagement.WorkspaceProductGroupLinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductGroupLinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceProductGroupLinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, groupLinkID string, options *armapimanagement.WorkspaceProductGroupLinkClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductGroupLinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method WorkspaceProductGroupLinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, workspaceID string, productID string, options *armapimanagement.WorkspaceProductGroupLinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceProductGroupLinkClientListByProductResponse]) +} + +// NewWorkspaceProductGroupLinkServerTransport creates a new instance of WorkspaceProductGroupLinkServerTransport with the provided implementation. +// The returned WorkspaceProductGroupLinkServerTransport instance is connected to an instance of armapimanagement.WorkspaceProductGroupLinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceProductGroupLinkServerTransport(srv *WorkspaceProductGroupLinkServer) *WorkspaceProductGroupLinkServerTransport { + return &WorkspaceProductGroupLinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceProductGroupLinkClientListByProductResponse]](), + } +} + +// WorkspaceProductGroupLinkServerTransport connects instances of armapimanagement.WorkspaceProductGroupLinkClient to instances of WorkspaceProductGroupLinkServer. +// Don't use this type directly, use NewWorkspaceProductGroupLinkServerTransport instead. +type WorkspaceProductGroupLinkServerTransport struct { + srv *WorkspaceProductGroupLinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceProductGroupLinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceProductGroupLinkServerTransport. +func (w *WorkspaceProductGroupLinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceProductGroupLinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceProductGroupLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceProductGroupLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceProductGroupLinkClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceProductGroupLinkClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceProductGroupLinkClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceProductGroupLinkClient.NewListByProductPager": + res.resp, res.err = w.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceProductGroupLinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groupLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.ProductGroupLinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + groupLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, groupLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductGroupLinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceProductGroupLinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groupLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + groupLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, groupLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceProductGroupLinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groupLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + groupLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, groupLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ProductGroupLinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceProductGroupLinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := w.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/groupLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceProductGroupLinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceProductGroupLinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, options) + newListByProductPager = &resp + w.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.WorkspaceProductGroupLinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + w.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceProductGroupLinkServerTransport +var workspaceProductGroupLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproductpolicy_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproductpolicy_server.go new file mode 100644 index 000000000000..4feeaa47b6d7 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspaceproductpolicy_server.go @@ -0,0 +1,390 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// WorkspaceProductPolicyServer is a fake server for instances of the armapimanagement.WorkspaceProductPolicyClient type. +type WorkspaceProductPolicyServer struct { + // CreateOrUpdate is the fake for method WorkspaceProductPolicyClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID armapimanagement.PolicyIDName, parameters armapimanagement.PolicyContract, options *armapimanagement.WorkspaceProductPolicyClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductPolicyClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceProductPolicyClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID armapimanagement.PolicyIDName, ifMatch string, options *armapimanagement.WorkspaceProductPolicyClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductPolicyClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceProductPolicyClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID armapimanagement.PolicyIDName, options *armapimanagement.WorkspaceProductPolicyClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductPolicyClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceProductPolicyClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID armapimanagement.PolicyIDName, options *armapimanagement.WorkspaceProductPolicyClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductPolicyClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // ListByProduct is the fake for method WorkspaceProductPolicyClient.ListByProduct + // HTTP status codes to indicate success: http.StatusOK + ListByProduct func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, options *armapimanagement.WorkspaceProductPolicyClientListByProductOptions) (resp azfake.Responder[armapimanagement.WorkspaceProductPolicyClientListByProductResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceProductPolicyServerTransport creates a new instance of WorkspaceProductPolicyServerTransport with the provided implementation. +// The returned WorkspaceProductPolicyServerTransport instance is connected to an instance of armapimanagement.WorkspaceProductPolicyClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceProductPolicyServerTransport(srv *WorkspaceProductPolicyServer) *WorkspaceProductPolicyServerTransport { + return &WorkspaceProductPolicyServerTransport{srv: srv} +} + +// WorkspaceProductPolicyServerTransport connects instances of armapimanagement.WorkspaceProductPolicyClient to instances of WorkspaceProductPolicyServer. +// Don't use this type directly, use NewWorkspaceProductPolicyServerTransport instead. +type WorkspaceProductPolicyServerTransport struct { + srv *WorkspaceProductPolicyServer +} + +// Do implements the policy.Transporter interface for WorkspaceProductPolicyServerTransport. +func (w *WorkspaceProductPolicyServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceProductPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceProductPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceProductPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceProductPolicyClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceProductPolicyClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceProductPolicyClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceProductPolicyClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceProductPolicyClient.ListByProduct": + res.resp, res.err = w.dispatchListByProduct(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceProductPolicyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.PolicyContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceProductPolicyClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceProductPolicyClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, policyIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceProductPolicyServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, policyIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceProductPolicyServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + formatUnescaped, err := url.QueryUnescape(qp.Get("format")) + if err != nil { + return nil, err + } + formatParam := getOptional(armapimanagement.PolicyExportFormat(formatUnescaped)) + var options *armapimanagement.WorkspaceProductPolicyClientGetOptions + if formatParam != nil { + options = &armapimanagement.WorkspaceProductPolicyClientGetOptions{ + Format: formatParam, + } + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, policyIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceProductPolicyServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + policyIDParam, err := parseWithCast(matches[regex.SubexpIndex("policyId")], func(v string) (armapimanagement.PolicyIDName, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armapimanagement.PolicyIDName(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, policyIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceProductPolicyServerTransport) dispatchListByProduct(req *http.Request) (*http.Response, error) { + if w.srv.ListByProduct == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByProduct not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/products/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/policies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + productIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ListByProduct(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, productIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PolicyCollection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceProductPolicyServerTransport +var workspaceProductPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacesubscription_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacesubscription_server.go new file mode 100644 index 000000000000..2d0096f72c70 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacesubscription_server.go @@ -0,0 +1,625 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceSubscriptionServer is a fake server for instances of the armapimanagement.WorkspaceSubscriptionClient type. +type WorkspaceSubscriptionServer struct { + // CreateOrUpdate is the fake for method WorkspaceSubscriptionClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, parameters armapimanagement.SubscriptionCreateParameters, options *armapimanagement.WorkspaceSubscriptionClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceSubscriptionClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceSubscriptionClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, ifMatch string, options *armapimanagement.WorkspaceSubscriptionClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceSubscriptionClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceSubscriptionClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *armapimanagement.WorkspaceSubscriptionClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceSubscriptionClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityTag is the fake for method WorkspaceSubscriptionClient.GetEntityTag + // HTTP status codes to indicate success: http.StatusOK + GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *armapimanagement.WorkspaceSubscriptionClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceSubscriptionClientGetEntityTagResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkspaceSubscriptionClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceSubscriptionClientListOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceSubscriptionClientListResponse]) + + // ListSecrets is the fake for method WorkspaceSubscriptionClient.ListSecrets + // HTTP status codes to indicate success: http.StatusOK + ListSecrets func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *armapimanagement.WorkspaceSubscriptionClientListSecretsOptions) (resp azfake.Responder[armapimanagement.WorkspaceSubscriptionClientListSecretsResponse], errResp azfake.ErrorResponder) + + // RegeneratePrimaryKey is the fake for method WorkspaceSubscriptionClient.RegeneratePrimaryKey + // HTTP status codes to indicate success: http.StatusNoContent + RegeneratePrimaryKey func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *armapimanagement.WorkspaceSubscriptionClientRegeneratePrimaryKeyOptions) (resp azfake.Responder[armapimanagement.WorkspaceSubscriptionClientRegeneratePrimaryKeyResponse], errResp azfake.ErrorResponder) + + // RegenerateSecondaryKey is the fake for method WorkspaceSubscriptionClient.RegenerateSecondaryKey + // HTTP status codes to indicate success: http.StatusNoContent + RegenerateSecondaryKey func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *armapimanagement.WorkspaceSubscriptionClientRegenerateSecondaryKeyOptions) (resp azfake.Responder[armapimanagement.WorkspaceSubscriptionClientRegenerateSecondaryKeyResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method WorkspaceSubscriptionClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, ifMatch string, parameters armapimanagement.SubscriptionUpdateParameters, options *armapimanagement.WorkspaceSubscriptionClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceSubscriptionClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceSubscriptionServerTransport creates a new instance of WorkspaceSubscriptionServerTransport with the provided implementation. +// The returned WorkspaceSubscriptionServerTransport instance is connected to an instance of armapimanagement.WorkspaceSubscriptionClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceSubscriptionServerTransport(srv *WorkspaceSubscriptionServer) *WorkspaceSubscriptionServerTransport { + return &WorkspaceSubscriptionServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceSubscriptionClientListResponse]](), + } +} + +// WorkspaceSubscriptionServerTransport connects instances of armapimanagement.WorkspaceSubscriptionClient to instances of WorkspaceSubscriptionServer. +// Don't use this type directly, use NewWorkspaceSubscriptionServerTransport instead. +type WorkspaceSubscriptionServerTransport struct { + srv *WorkspaceSubscriptionServer + newListPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceSubscriptionClientListResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceSubscriptionServerTransport. +func (w *WorkspaceSubscriptionServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceSubscriptionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceSubscriptionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceSubscriptionClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceSubscriptionClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceSubscriptionClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceSubscriptionClient.GetEntityTag": + res.resp, res.err = w.dispatchGetEntityTag(req) + case "WorkspaceSubscriptionClient.NewListPager": + res.resp, res.err = w.dispatchNewListPager(req) + case "WorkspaceSubscriptionClient.ListSecrets": + res.resp, res.err = w.dispatchListSecrets(req) + case "WorkspaceSubscriptionClient.RegeneratePrimaryKey": + res.resp, res.err = w.dispatchRegeneratePrimaryKey(req) + case "WorkspaceSubscriptionClient.RegenerateSecondaryKey": + res.resp, res.err = w.dispatchRegenerateSecondaryKey(req) + case "WorkspaceSubscriptionClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + body, err := server.UnmarshalRequestAsJSON[armapimanagement.SubscriptionCreateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + sidParam, err := url.PathUnescape(matches[regex.SubexpIndex("sid")]) + if err != nil { + return nil, err + } + notifyUnescaped, err := url.QueryUnescape(qp.Get("notify")) + if err != nil { + return nil, err + } + notifyParam, err := parseOptional(notifyUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + appTypeUnescaped, err := url.QueryUnescape(qp.Get("appType")) + if err != nil { + return nil, err + } + appTypeParam := getOptional(armapimanagement.AppType(appTypeUnescaped)) + var options *armapimanagement.WorkspaceSubscriptionClientCreateOrUpdateOptions + if notifyParam != nil || ifMatchParam != nil || appTypeParam != nil { + options = &armapimanagement.WorkspaceSubscriptionClientCreateOrUpdateOptions{ + Notify: notifyParam, + IfMatch: ifMatchParam, + AppType: appTypeParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, sidParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SubscriptionContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + sidParam, err := url.PathUnescape(matches[regex.SubexpIndex("sid")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, sidParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + sidParam, err := url.PathUnescape(matches[regex.SubexpIndex("sid")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, sidParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SubscriptionContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityTag == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + sidParam, err := url.PathUnescape(matches[regex.SubexpIndex("sid")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, sidParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceSubscriptionClientListOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceSubscriptionClientListOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armapimanagement.WorkspaceSubscriptionClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchListSecrets(req *http.Request) (*http.Response, error) { + if w.srv.ListSecrets == nil { + return nil, &nonRetriableError{errors.New("fake for method ListSecrets not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listSecrets` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + sidParam, err := url.PathUnescape(matches[regex.SubexpIndex("sid")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ListSecrets(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, sidParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SubscriptionKeysContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchRegeneratePrimaryKey(req *http.Request) (*http.Response, error) { + if w.srv.RegeneratePrimaryKey == nil { + return nil, &nonRetriableError{errors.New("fake for method RegeneratePrimaryKey not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regeneratePrimaryKey` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + sidParam, err := url.PathUnescape(matches[regex.SubexpIndex("sid")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.RegeneratePrimaryKey(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, sidParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchRegenerateSecondaryKey(req *http.Request) (*http.Response, error) { + if w.srv.RegenerateSecondaryKey == nil { + return nil, &nonRetriableError{errors.New("fake for method RegenerateSecondaryKey not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regenerateSecondaryKey` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + sidParam, err := url.PathUnescape(matches[regex.SubexpIndex("sid")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.RegenerateSecondaryKey(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, sidParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceSubscriptionServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + body, err := server.UnmarshalRequestAsJSON[armapimanagement.SubscriptionUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + sidParam, err := url.PathUnescape(matches[regex.SubexpIndex("sid")]) + if err != nil { + return nil, err + } + notifyUnescaped, err := url.QueryUnescape(qp.Get("notify")) + if err != nil { + return nil, err + } + notifyParam, err := parseOptional(notifyUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + appTypeUnescaped, err := url.QueryUnescape(qp.Get("appType")) + if err != nil { + return nil, err + } + appTypeParam := getOptional(armapimanagement.AppType(appTypeUnescaped)) + var options *armapimanagement.WorkspaceSubscriptionClientUpdateOptions + if notifyParam != nil || appTypeParam != nil { + options = &armapimanagement.WorkspaceSubscriptionClientUpdateOptions{ + Notify: notifyParam, + AppType: appTypeParam, + } + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, sidParam, getHeaderValue(req.Header, "If-Match"), body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SubscriptionContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceSubscriptionServerTransport +var workspaceSubscriptionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetag_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetag_server.go new file mode 100644 index 000000000000..81f1d1dd3ff0 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetag_server.go @@ -0,0 +1,450 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceTagServer is a fake server for instances of the armapimanagement.WorkspaceTagClient type. +type WorkspaceTagServer struct { + // CreateOrUpdate is the fake for method WorkspaceTagClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, parameters armapimanagement.TagCreateUpdateParameters, options *armapimanagement.WorkspaceTagClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceTagClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, ifMatch string, options *armapimanagement.WorkspaceTagClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceTagClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, options *armapimanagement.WorkspaceTagClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagClientGetResponse], errResp azfake.ErrorResponder) + + // GetEntityState is the fake for method WorkspaceTagClient.GetEntityState + // HTTP status codes to indicate success: http.StatusOK + GetEntityState func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, options *armapimanagement.WorkspaceTagClientGetEntityStateOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagClientGetEntityStateResponse], errResp azfake.ErrorResponder) + + // NewListByServicePager is the fake for method WorkspaceTagClient.NewListByServicePager + // HTTP status codes to indicate success: http.StatusOK + NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceTagClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceTagClientListByServiceResponse]) + + // Update is the fake for method WorkspaceTagClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, ifMatch string, parameters armapimanagement.TagCreateUpdateParameters, options *armapimanagement.WorkspaceTagClientUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspaceTagServerTransport creates a new instance of WorkspaceTagServerTransport with the provided implementation. +// The returned WorkspaceTagServerTransport instance is connected to an instance of armapimanagement.WorkspaceTagClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceTagServerTransport(srv *WorkspaceTagServer) *WorkspaceTagServerTransport { + return &WorkspaceTagServerTransport{ + srv: srv, + newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceTagClientListByServiceResponse]](), + } +} + +// WorkspaceTagServerTransport connects instances of armapimanagement.WorkspaceTagClient to instances of WorkspaceTagServer. +// Don't use this type directly, use NewWorkspaceTagServerTransport instead. +type WorkspaceTagServerTransport struct { + srv *WorkspaceTagServer + newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceTagClientListByServiceResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceTagServerTransport. +func (w *WorkspaceTagServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceTagServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceTagServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceTagServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceTagClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceTagClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceTagClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceTagClient.GetEntityState": + res.resp, res.err = w.dispatchGetEntityState(req) + case "WorkspaceTagClient.NewListByServicePager": + res.resp, res.err = w.dispatchNewListByServicePager(req) + case "WorkspaceTagClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceTagServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.TagCreateUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armapimanagement.WorkspaceTagClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armapimanagement.WorkspaceTagClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceTagServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceTagServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceTagServerTransport) dispatchGetEntityState(req *http.Request) (*http.Response, error) { + if w.srv.GetEntityState == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEntityState not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetEntityState(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceTagServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByServicePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} + } + newListByServicePager := w.newListByServicePager.get(req) + if newListByServicePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + scopeUnescaped, err := url.QueryUnescape(qp.Get("scope")) + if err != nil { + return nil, err + } + scopeParam := getOptional(scopeUnescaped) + var options *armapimanagement.WorkspaceTagClientListByServiceOptions + if filterParam != nil || topParam != nil || skipParam != nil || scopeParam != nil { + options = &armapimanagement.WorkspaceTagClientListByServiceOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + Scope: scopeParam, + } + } + resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) + newListByServicePager = &resp + w.newListByServicePager.add(req, newListByServicePager) + server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceTagClientListByServiceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByServicePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByServicePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByServicePager) { + w.newListByServicePager.remove(req) + } + return resp, nil +} + +func (w *WorkspaceTagServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.TagCreateUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceTagServerTransport +var workspaceTagServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetagapilink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetagapilink_server.go new file mode 100644 index 000000000000..b8a7df53b943 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetagapilink_server.go @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceTagAPILinkServer is a fake server for instances of the armapimanagement.WorkspaceTagAPILinkClient type. +type WorkspaceTagAPILinkServer struct { + // CreateOrUpdate is the fake for method WorkspaceTagAPILinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, apiLinkID string, parameters armapimanagement.TagAPILinkContract, options *armapimanagement.WorkspaceTagAPILinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagAPILinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceTagAPILinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, apiLinkID string, options *armapimanagement.WorkspaceTagAPILinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagAPILinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceTagAPILinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, apiLinkID string, options *armapimanagement.WorkspaceTagAPILinkClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagAPILinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method WorkspaceTagAPILinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, workspaceID string, tagID string, options *armapimanagement.WorkspaceTagAPILinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceTagAPILinkClientListByProductResponse]) +} + +// NewWorkspaceTagAPILinkServerTransport creates a new instance of WorkspaceTagAPILinkServerTransport with the provided implementation. +// The returned WorkspaceTagAPILinkServerTransport instance is connected to an instance of armapimanagement.WorkspaceTagAPILinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceTagAPILinkServerTransport(srv *WorkspaceTagAPILinkServer) *WorkspaceTagAPILinkServerTransport { + return &WorkspaceTagAPILinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceTagAPILinkClientListByProductResponse]](), + } +} + +// WorkspaceTagAPILinkServerTransport connects instances of armapimanagement.WorkspaceTagAPILinkClient to instances of WorkspaceTagAPILinkServer. +// Don't use this type directly, use NewWorkspaceTagAPILinkServerTransport instead. +type WorkspaceTagAPILinkServerTransport struct { + srv *WorkspaceTagAPILinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceTagAPILinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceTagAPILinkServerTransport. +func (w *WorkspaceTagAPILinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceTagAPILinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceTagApiLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceTagApiLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceTagAPILinkClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceTagAPILinkClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceTagAPILinkClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceTagAPILinkClient.NewListByProductPager": + res.resp, res.err = w.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceTagAPILinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.TagAPILinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, apiLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagAPILinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceTagAPILinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, apiLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceTagAPILinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + apiLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, apiLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagAPILinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceTagAPILinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := w.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceTagAPILinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceTagAPILinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, options) + newListByProductPager = &resp + w.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.WorkspaceTagAPILinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + w.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceTagAPILinkServerTransport +var workspaceTagApiLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetagoperationlink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetagoperationlink_server.go new file mode 100644 index 000000000000..931a5ee3da69 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetagoperationlink_server.go @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceTagOperationLinkServer is a fake server for instances of the armapimanagement.WorkspaceTagOperationLinkClient type. +type WorkspaceTagOperationLinkServer struct { + // CreateOrUpdate is the fake for method WorkspaceTagOperationLinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, operationLinkID string, parameters armapimanagement.TagOperationLinkContract, options *armapimanagement.WorkspaceTagOperationLinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagOperationLinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceTagOperationLinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, operationLinkID string, options *armapimanagement.WorkspaceTagOperationLinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagOperationLinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceTagOperationLinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, operationLinkID string, options *armapimanagement.WorkspaceTagOperationLinkClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagOperationLinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method WorkspaceTagOperationLinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, workspaceID string, tagID string, options *armapimanagement.WorkspaceTagOperationLinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceTagOperationLinkClientListByProductResponse]) +} + +// NewWorkspaceTagOperationLinkServerTransport creates a new instance of WorkspaceTagOperationLinkServerTransport with the provided implementation. +// The returned WorkspaceTagOperationLinkServerTransport instance is connected to an instance of armapimanagement.WorkspaceTagOperationLinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceTagOperationLinkServerTransport(srv *WorkspaceTagOperationLinkServer) *WorkspaceTagOperationLinkServerTransport { + return &WorkspaceTagOperationLinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceTagOperationLinkClientListByProductResponse]](), + } +} + +// WorkspaceTagOperationLinkServerTransport connects instances of armapimanagement.WorkspaceTagOperationLinkClient to instances of WorkspaceTagOperationLinkServer. +// Don't use this type directly, use NewWorkspaceTagOperationLinkServerTransport instead. +type WorkspaceTagOperationLinkServerTransport struct { + srv *WorkspaceTagOperationLinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceTagOperationLinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceTagOperationLinkServerTransport. +func (w *WorkspaceTagOperationLinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceTagOperationLinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceTagOperationLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceTagOperationLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceTagOperationLinkClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceTagOperationLinkClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceTagOperationLinkClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceTagOperationLinkClient.NewListByProductPager": + res.resp, res.err = w.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceTagOperationLinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.TagOperationLinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + operationLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, operationLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagOperationLinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceTagOperationLinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + operationLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, operationLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceTagOperationLinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + operationLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, operationLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagOperationLinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceTagOperationLinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := w.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceTagOperationLinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceTagOperationLinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, options) + newListByProductPager = &resp + w.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.WorkspaceTagOperationLinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + w.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceTagOperationLinkServerTransport +var workspaceTagOperationLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetagproductlink_server.go b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetagproductlink_server.go new file mode 100644 index 000000000000..c0e6bc7ac277 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacetagproductlink_server.go @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkspaceTagProductLinkServer is a fake server for instances of the armapimanagement.WorkspaceTagProductLinkClient type. +type WorkspaceTagProductLinkServer struct { + // CreateOrUpdate is the fake for method WorkspaceTagProductLinkClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, productLinkID string, parameters armapimanagement.TagProductLinkContract, options *armapimanagement.WorkspaceTagProductLinkClientCreateOrUpdateOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagProductLinkClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkspaceTagProductLinkClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, productLinkID string, options *armapimanagement.WorkspaceTagProductLinkClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagProductLinkClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspaceTagProductLinkClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, productLinkID string, options *armapimanagement.WorkspaceTagProductLinkClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceTagProductLinkClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByProductPager is the fake for method WorkspaceTagProductLinkClient.NewListByProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByProductPager func(resourceGroupName string, serviceName string, workspaceID string, tagID string, options *armapimanagement.WorkspaceTagProductLinkClientListByProductOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceTagProductLinkClientListByProductResponse]) +} + +// NewWorkspaceTagProductLinkServerTransport creates a new instance of WorkspaceTagProductLinkServerTransport with the provided implementation. +// The returned WorkspaceTagProductLinkServerTransport instance is connected to an instance of armapimanagement.WorkspaceTagProductLinkClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspaceTagProductLinkServerTransport(srv *WorkspaceTagProductLinkServer) *WorkspaceTagProductLinkServerTransport { + return &WorkspaceTagProductLinkServerTransport{ + srv: srv, + newListByProductPager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceTagProductLinkClientListByProductResponse]](), + } +} + +// WorkspaceTagProductLinkServerTransport connects instances of armapimanagement.WorkspaceTagProductLinkClient to instances of WorkspaceTagProductLinkServer. +// Don't use this type directly, use NewWorkspaceTagProductLinkServerTransport instead. +type WorkspaceTagProductLinkServerTransport struct { + srv *WorkspaceTagProductLinkServer + newListByProductPager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceTagProductLinkClientListByProductResponse]] +} + +// Do implements the policy.Transporter interface for WorkspaceTagProductLinkServerTransport. +func (w *WorkspaceTagProductLinkServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspaceTagProductLinkServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspaceTagProductLinkServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspaceTagProductLinkServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspaceTagProductLinkClient.CreateOrUpdate": + res.resp, res.err = w.dispatchCreateOrUpdate(req) + case "WorkspaceTagProductLinkClient.Delete": + res.resp, res.err = w.dispatchDelete(req) + case "WorkspaceTagProductLinkClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspaceTagProductLinkClient.NewListByProductPager": + res.resp, res.err = w.dispatchNewListByProductPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspaceTagProductLinkServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/productLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armapimanagement.TagProductLinkContract](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + productLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, productLinkIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagProductLinkContract, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceTagProductLinkServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/productLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + productLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, productLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspaceTagProductLinkServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/productLinks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + productLinkIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("productLinkId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, productLinkIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagProductLinkContract, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (w *WorkspaceTagProductLinkServerTransport) dispatchNewListByProductPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByProductPager not implemented")} + } + newListByProductPager := w.newListByProductPager.get(req) + if newListByProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tags/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/productLinks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) + if err != nil { + return nil, err + } + workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) + if err != nil { + return nil, err + } + tagIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("tagId")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armapimanagement.WorkspaceTagProductLinkClientListByProductOptions + if filterParam != nil || topParam != nil || skipParam != nil { + options = &armapimanagement.WorkspaceTagProductLinkClientListByProductOptions{ + Filter: filterParam, + Top: topParam, + Skip: skipParam, + } + } + resp := w.srv.NewListByProductPager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, tagIDParam, options) + newListByProductPager = &resp + w.newListByProductPager.add(req, newListByProductPager) + server.PagerResponderInjectNextLinks(newListByProductPager, req, func(page *armapimanagement.WorkspaceTagProductLinkClientListByProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByProductPager) { + w.newListByProductPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspaceTagProductLinkServerTransport +var workspaceTagProductLinkServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/gateway_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/gateway_client.go index 8bb51204bbe4..7fb9cc4eb9cf 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/gateway_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/gateway_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type GatewayClient struct { } // NewGatewayClient creates a new instance of GatewayClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewGatewayClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GatewayClient, error) { @@ -47,7 +44,7 @@ func NewGatewayClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Creates or updates a Gateway to be used in Api Management instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -99,12 +96,12 @@ func (client *GatewayClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -126,7 +123,7 @@ func (client *GatewayClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - Deletes specific Gateway. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -156,7 +153,7 @@ func (client *GatewayClient) Delete(ctx context.Context, resourceGroupName strin } // deleteCreateRequest creates the Delete request. -func (client *GatewayClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string, options *GatewayClientDeleteOptions) (*policy.Request, error) { +func (client *GatewayClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string, _ *GatewayClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -179,17 +176,17 @@ func (client *GatewayClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // GenerateToken - Gets the Shared Access Authorization Token for the gateway. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -218,7 +215,7 @@ func (client *GatewayClient) GenerateToken(ctx context.Context, resourceGroupNam } // generateTokenCreateRequest creates the GenerateToken request. -func (client *GatewayClient) generateTokenCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayTokenRequestContract, options *GatewayClientGenerateTokenOptions) (*policy.Request, error) { +func (client *GatewayClient) generateTokenCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayTokenRequestContract, _ *GatewayClientGenerateTokenOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -241,7 +238,7 @@ func (client *GatewayClient) generateTokenCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -262,7 +259,7 @@ func (client *GatewayClient) generateTokenHandleResponse(resp *http.Response) (G // Get - Gets the details of the Gateway specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -291,7 +288,7 @@ func (client *GatewayClient) Get(ctx context.Context, resourceGroupName string, } // getCreateRequest creates the Get request. -func (client *GatewayClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayClientGetOptions) (*policy.Request, error) { +func (client *GatewayClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, _ *GatewayClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -314,7 +311,7 @@ func (client *GatewayClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -334,7 +331,7 @@ func (client *GatewayClient) getHandleResponse(resp *http.Response) (GatewayClie // GetEntityTag - Gets the entity state (Etag) version of the Gateway specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -363,7 +360,7 @@ func (client *GatewayClient) GetEntityTag(ctx context.Context, resourceGroupName } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *GatewayClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayClientGetEntityTagOptions) (*policy.Request, error) { +func (client *GatewayClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, _ *GatewayClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -386,7 +383,7 @@ func (client *GatewayClient) getEntityTagCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -401,9 +398,70 @@ func (client *GatewayClient) getEntityTagHandleResponse(resp *http.Response) (Ga return result, nil } +// InvalidateDebugCredentials - Action is invalidating all debug credentials issued for gateway. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value +// 'managed' +// - options - GatewayClientInvalidateDebugCredentialsOptions contains the optional parameters for the GatewayClient.InvalidateDebugCredentials +// method. +func (client *GatewayClient) InvalidateDebugCredentials(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayClientInvalidateDebugCredentialsOptions) (GatewayClientInvalidateDebugCredentialsResponse, error) { + var err error + const operationName = "GatewayClient.InvalidateDebugCredentials" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.invalidateDebugCredentialsCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, options) + if err != nil { + return GatewayClientInvalidateDebugCredentialsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return GatewayClientInvalidateDebugCredentialsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return GatewayClientInvalidateDebugCredentialsResponse{}, err + } + return GatewayClientInvalidateDebugCredentialsResponse{}, nil +} + +// invalidateDebugCredentialsCreateRequest creates the InvalidateDebugCredentials request. +func (client *GatewayClient) invalidateDebugCredentialsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, _ *GatewayClientInvalidateDebugCredentialsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/invalidateDebugCredentials" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + // NewListByServicePager - Lists a collection of gateways registered with service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - GatewayClientListByServiceOptions contains the optional parameters for the GatewayClient.NewListByServicePager @@ -454,13 +512,13 @@ func (client *GatewayClient) listByServiceCreateRequest(ctx context.Context, res if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -475,10 +533,85 @@ func (client *GatewayClient) listByServiceHandleResponse(resp *http.Response) (G return result, nil } +// ListDebugCredentials - Create new debug credentials for gateway. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value +// 'managed' +// - parameters - List debug credentials properties. +// - options - GatewayClientListDebugCredentialsOptions contains the optional parameters for the GatewayClient.ListDebugCredentials +// method. +func (client *GatewayClient) ListDebugCredentials(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayListDebugCredentialsContract, options *GatewayClientListDebugCredentialsOptions) (GatewayClientListDebugCredentialsResponse, error) { + var err error + const operationName = "GatewayClient.ListDebugCredentials" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listDebugCredentialsCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, parameters, options) + if err != nil { + return GatewayClientListDebugCredentialsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return GatewayClientListDebugCredentialsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return GatewayClientListDebugCredentialsResponse{}, err + } + resp, err := client.listDebugCredentialsHandleResponse(httpResp) + return resp, err +} + +// listDebugCredentialsCreateRequest creates the ListDebugCredentials request. +func (client *GatewayClient) listDebugCredentialsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayListDebugCredentialsContract, _ *GatewayClientListDebugCredentialsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listDebugCredentials" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// listDebugCredentialsHandleResponse handles the ListDebugCredentials response. +func (client *GatewayClient) listDebugCredentialsHandleResponse(resp *http.Response) (GatewayClientListDebugCredentialsResponse, error) { + result := GatewayClientListDebugCredentialsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GatewayDebugCredentialsContract); err != nil { + return GatewayClientListDebugCredentialsResponse{}, err + } + return result, nil +} + // ListKeys - Retrieves gateway keys. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -507,7 +640,7 @@ func (client *GatewayClient) ListKeys(ctx context.Context, resourceGroupName str } // listKeysCreateRequest creates the ListKeys request. -func (client *GatewayClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayClientListKeysOptions) (*policy.Request, error) { +func (client *GatewayClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, _ *GatewayClientListKeysOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -530,7 +663,7 @@ func (client *GatewayClient) listKeysCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -548,10 +681,84 @@ func (client *GatewayClient) listKeysHandleResponse(resp *http.Response) (Gatewa return result, nil } +// ListTrace - Fetches trace collected by gateway. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value +// 'managed' +// - parameters - List trace properties. +// - options - GatewayClientListTraceOptions contains the optional parameters for the GatewayClient.ListTrace method. +func (client *GatewayClient) ListTrace(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayListTraceContract, options *GatewayClientListTraceOptions) (GatewayClientListTraceResponse, error) { + var err error + const operationName = "GatewayClient.ListTrace" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listTraceCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, parameters, options) + if err != nil { + return GatewayClientListTraceResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return GatewayClientListTraceResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return GatewayClientListTraceResponse{}, err + } + resp, err := client.listTraceHandleResponse(httpResp) + return resp, err +} + +// listTraceCreateRequest creates the ListTrace request. +func (client *GatewayClient) listTraceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayListTraceContract, _ *GatewayClientListTraceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listTrace" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// listTraceHandleResponse handles the ListTrace response. +func (client *GatewayClient) listTraceHandleResponse(resp *http.Response) (GatewayClientListTraceResponse, error) { + result := GatewayClientListTraceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Value); err != nil { + return GatewayClientListTraceResponse{}, err + } + return result, nil +} + // RegenerateKey - Regenerates specified gateway key invalidating any tokens created with it. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -579,7 +786,7 @@ func (client *GatewayClient) RegenerateKey(ctx context.Context, resourceGroupNam } // regenerateKeyCreateRequest creates the RegenerateKey request. -func (client *GatewayClient) regenerateKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayKeyRegenerationRequestContract, options *GatewayClientRegenerateKeyOptions) (*policy.Request, error) { +func (client *GatewayClient) regenerateKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayKeyRegenerationRequestContract, _ *GatewayClientRegenerateKeyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -602,7 +809,7 @@ func (client *GatewayClient) regenerateKeyCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -614,7 +821,7 @@ func (client *GatewayClient) regenerateKeyCreateRequest(ctx context.Context, res // Update - Updates the details of the gateway specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -645,7 +852,7 @@ func (client *GatewayClient) Update(ctx context.Context, resourceGroupName strin } // updateCreateRequest creates the Update request. -func (client *GatewayClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string, parameters GatewayContract, options *GatewayClientUpdateOptions) (*policy.Request, error) { +func (client *GatewayClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string, parameters GatewayContract, _ *GatewayClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -668,10 +875,10 @@ func (client *GatewayClient) updateCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/gateway_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/gateway_client_example_test.go deleted file mode 100644 index c857ecde899b..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/gateway_client_example_test.go +++ /dev/null @@ -1,285 +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 armapimanagement_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGateways.json -func ExampleGatewayClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGatewayClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.GatewayClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.GatewayCollection = armapimanagement.GatewayCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.GatewayContract{ - // { - // Name: to.Ptr("a1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1"), - // Properties: &armapimanagement.GatewayContractProperties{ - // Description: to.Ptr("my gateway 1"), - // LocationData: &armapimanagement.ResourceLocationDataContract{ - // Name: to.Ptr("my location 1"), - // }, - // }, - // }, - // { - // Name: to.Ptr("5a73933b8f27f7cc82a2d533"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw2"), - // Properties: &armapimanagement.GatewayContractProperties{ - // Description: to.Ptr("my gateway 2"), - // LocationData: &armapimanagement.ResourceLocationDataContract{ - // Name: to.Ptr("my location 2"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGateway.json -func ExampleGatewayClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGatewayClient().GetEntityTag(ctx, "rg1", "apimService1", "mygateway", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGateway.json -func ExampleGatewayClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayClient().Get(ctx, "rg1", "apimService1", "gw1", 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.GatewayContract = armapimanagement.GatewayContract{ - // Name: to.Ptr("a1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1"), - // Properties: &armapimanagement.GatewayContractProperties{ - // Description: to.Ptr("my gateway 1"), - // LocationData: &armapimanagement.ResourceLocationDataContract{ - // Name: to.Ptr("my location"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGateway.json -func ExampleGatewayClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayClient().CreateOrUpdate(ctx, "rg1", "apimService1", "gw1", armapimanagement.GatewayContract{ - Properties: &armapimanagement.GatewayContractProperties{ - Description: to.Ptr("my gateway 1"), - LocationData: &armapimanagement.ResourceLocationDataContract{ - Name: to.Ptr("my location"), - }, - }, - }, &armapimanagement.GatewayClientCreateOrUpdateOptions{IfMatch: 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.GatewayContract = armapimanagement.GatewayContract{ - // Name: to.Ptr("a1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1"), - // Properties: &armapimanagement.GatewayContractProperties{ - // Description: to.Ptr("my gateway 1"), - // LocationData: &armapimanagement.ResourceLocationDataContract{ - // Name: to.Ptr("my location"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateGateway.json -func ExampleGatewayClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayClient().Update(ctx, "rg1", "apimService1", "gw1", "*", armapimanagement.GatewayContract{ - Properties: &armapimanagement.GatewayContractProperties{ - Description: to.Ptr("my gateway 1"), - LocationData: &armapimanagement.ResourceLocationDataContract{ - Name: to.Ptr("my location"), - }, - }, - }, 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.GatewayContract = armapimanagement.GatewayContract{ - // Name: to.Ptr("a1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1"), - // Properties: &armapimanagement.GatewayContractProperties{ - // Description: to.Ptr("my gateway 1"), - // LocationData: &armapimanagement.ResourceLocationDataContract{ - // Name: to.Ptr("my location"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGateway.json -func ExampleGatewayClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGatewayClient().Delete(ctx, "rg1", "apimService1", "gw1", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGatewayListKeys.json -func ExampleGatewayClient_ListKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayClient().ListKeys(ctx, "rg1", "apimService1", "gw1", 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.GatewayKeysContract = armapimanagement.GatewayKeysContract{ - // Primary: to.Ptr("primary_key_value"), - // Secondary: to.Ptr("secondary_key_value"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGatewayRegenerateKey.json -func ExampleGatewayClient_RegenerateKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGatewayClient().RegenerateKey(ctx, "rg1", "apimService1", "gwId", armapimanagement.GatewayKeyRegenerationRequestContract{ - KeyType: to.Ptr(armapimanagement.KeyTypePrimary), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGatewayGenerateToken.json -func ExampleGatewayClient_GenerateToken() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayClient().GenerateToken(ctx, "rg1", "apimService1", "gw1", armapimanagement.GatewayTokenRequestContract{ - Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-21T00:44:24.284Z"); return t }()), - KeyType: to.Ptr(armapimanagement.KeyTypePrimary), - }, 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.GatewayTokenContract = armapimanagement.GatewayTokenContract{ - // Value: to.Ptr("gw1&201904210044&9A1GR1f5WIhFvFmzQG+xxxxxxxxxxx/kBeu87DWad3tkasUXuvPL+MgzlwUHyg=="), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/gatewayapi_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/gatewayapi_client.go index 79958d27c361..600aff5ac0ef 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/gatewayapi_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/gatewayapi_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type GatewayAPIClient struct { } // NewGatewayAPIClient creates a new instance of GatewayAPIClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewGatewayAPIClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GatewayAPIClient, error) { @@ -47,7 +44,7 @@ func NewGatewayAPIClient(subscriptionID string, credential azcore.TokenCredentia // CreateOrUpdate - Adds an API to the specified Gateway. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -105,7 +102,7 @@ func (client *GatewayAPIClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { @@ -129,7 +126,7 @@ func (client *GatewayAPIClient) createOrUpdateHandleResponse(resp *http.Response // Delete - Deletes the specified API from the specified Gateway. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -158,7 +155,7 @@ func (client *GatewayAPIClient) Delete(ctx context.Context, resourceGroupName st } // deleteCreateRequest creates the Delete request. -func (client *GatewayAPIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, options *GatewayAPIClientDeleteOptions) (*policy.Request, error) { +func (client *GatewayAPIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, _ *GatewayAPIClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -185,7 +182,7 @@ func (client *GatewayAPIClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -193,7 +190,7 @@ func (client *GatewayAPIClient) deleteCreateRequest(ctx context.Context, resourc // GetEntityTag - Checks that API entity specified by identifier is associated with the Gateway entity. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -223,7 +220,7 @@ func (client *GatewayAPIClient) GetEntityTag(ctx context.Context, resourceGroupN } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *GatewayAPIClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, options *GatewayAPIClientGetEntityTagOptions) (*policy.Request, error) { +func (client *GatewayAPIClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, _ *GatewayAPIClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -250,7 +247,7 @@ func (client *GatewayAPIClient) getEntityTagCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -267,7 +264,7 @@ func (client *GatewayAPIClient) getEntityTagHandleResponse(resp *http.Response) // NewListByServicePager - Lists a collection of the APIs associated with a gateway. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -324,13 +321,13 @@ func (client *GatewayAPIClient) listByServiceCreateRequest(ctx context.Context, if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/gatewayapi_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/gatewayapi_client_example_test.go deleted file mode 100644 index a1be09a3107b..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/gatewayapi_client_example_test.go +++ /dev/null @@ -1,144 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGatewayApis.json -func ExampleGatewayAPIClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGatewayAPIClient().NewListByServicePager("rg1", "apimService1", "gw1", &armapimanagement.GatewayAPIClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.APICollection = armapimanagement.APICollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.APIContract{ - // { - // Name: to.Ptr("57681820a40f7eb6c49f6aca"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/apis/57681820a40f7eb6c49f6aca"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("description_57681820a40f7eb6c49f6acc"), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // Path: to.Ptr("suffix_57681820a40f7eb6c49f6ace"), - // DisplayName: to.Ptr("api_57681820a40f7eb6c49f6acb"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://contoso/57681820a40f7eb6c49f6acd"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGatewayApi.json -func ExampleGatewayAPIClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGatewayAPIClient().GetEntityTag(ctx, "rg1", "apimService1", "gw1", "api1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGatewayApi.json -func ExampleGatewayAPIClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayAPIClient().CreateOrUpdate(ctx, "rg1", "apimService1", "gw1", "echo-api", &armapimanagement.GatewayAPIClientCreateOrUpdateOptions{Parameters: &armapimanagement.AssociationContract{ - Properties: &armapimanagement.AssociationContractProperties{ - ProvisioningState: to.Ptr("created"), - }, - }, - }) - 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.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("echo-api"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/apis/echo-api"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr(""), - // DisplayName: to.Ptr("EchoApi"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTP), - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("https://contoso.com/apis/echo"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGatewayApi.json -func ExampleGatewayAPIClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGatewayAPIClient().Delete(ctx, "rg1", "apimService1", "gw1", "echo-api", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/gatewaycertificateauthority_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/gatewaycertificateauthority_client.go index d55f5f3c6e37..5608dd7249c5 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/gatewaycertificateauthority_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/gatewaycertificateauthority_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type GatewayCertificateAuthorityClient struct { } // NewGatewayCertificateAuthorityClient creates a new instance of GatewayCertificateAuthorityClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewGatewayCertificateAuthorityClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GatewayCertificateAuthorityClient, error) { @@ -47,7 +44,7 @@ func NewGatewayCertificateAuthorityClient(subscriptionID string, credential azco // CreateOrUpdate - Assign Certificate entity to Gateway entity as Certificate Authority. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -105,12 +102,12 @@ func (client *GatewayCertificateAuthorityClient) createOrUpdateCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -132,7 +129,7 @@ func (client *GatewayCertificateAuthorityClient) createOrUpdateHandleResponse(re // Delete - Remove relationship between Certificate Authority and Gateway entity. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -164,7 +161,7 @@ func (client *GatewayCertificateAuthorityClient) Delete(ctx context.Context, res } // deleteCreateRequest creates the Delete request. -func (client *GatewayCertificateAuthorityClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, ifMatch string, options *GatewayCertificateAuthorityClientDeleteOptions) (*policy.Request, error) { +func (client *GatewayCertificateAuthorityClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, ifMatch string, _ *GatewayCertificateAuthorityClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -191,17 +188,17 @@ func (client *GatewayCertificateAuthorityClient) deleteCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Get assigned Gateway Certificate Authority details. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -232,7 +229,7 @@ func (client *GatewayCertificateAuthorityClient) Get(ctx context.Context, resour } // getCreateRequest creates the Get request. -func (client *GatewayCertificateAuthorityClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, options *GatewayCertificateAuthorityClientGetOptions) (*policy.Request, error) { +func (client *GatewayCertificateAuthorityClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, _ *GatewayCertificateAuthorityClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -259,7 +256,7 @@ func (client *GatewayCertificateAuthorityClient) getCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -279,7 +276,7 @@ func (client *GatewayCertificateAuthorityClient) getHandleResponse(resp *http.Re // GetEntityTag - Checks if Certificate entity is assigned to Gateway entity as Certificate Authority. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -310,7 +307,7 @@ func (client *GatewayCertificateAuthorityClient) GetEntityTag(ctx context.Contex } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *GatewayCertificateAuthorityClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, options *GatewayCertificateAuthorityClientGetEntityTagOptions) (*policy.Request, error) { +func (client *GatewayCertificateAuthorityClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, _ *GatewayCertificateAuthorityClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -337,7 +334,7 @@ func (client *GatewayCertificateAuthorityClient) getEntityTagCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -354,7 +351,7 @@ func (client *GatewayCertificateAuthorityClient) getEntityTagHandleResponse(resp // NewListByServicePager - Lists the collection of Certificate Authorities for the specified Gateway entity. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -411,13 +408,13 @@ func (client *GatewayCertificateAuthorityClient) listByServiceCreateRequest(ctx if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/gatewaycertificateauthority_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/gatewaycertificateauthority_client_example_test.go deleted file mode 100644 index c09f61ff8fa8..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/gatewaycertificateauthority_client_example_test.go +++ /dev/null @@ -1,160 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGatewayCertificateAuthorities.json -func ExampleGatewayCertificateAuthorityClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGatewayCertificateAuthorityClient().NewListByServicePager("rg1", "apimService1", "gw1", &armapimanagement.GatewayCertificateAuthorityClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.GatewayCertificateAuthorityCollection = armapimanagement.GatewayCertificateAuthorityCollection{ - // Value: []*armapimanagement.GatewayCertificateAuthorityContract{ - // { - // Name: to.Ptr("cert1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/certificateAuthorities"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/certificateAuthorities/cert1"), - // Properties: &armapimanagement.GatewayCertificateAuthorityContractProperties{ - // IsTrusted: to.Ptr(false), - // }, - // }, - // { - // Name: to.Ptr("cert2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/certificateAuthorities"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/certificateAuthorities/cert2"), - // Properties: &armapimanagement.GatewayCertificateAuthorityContractProperties{ - // IsTrusted: to.Ptr(true), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGatewayCertificateAuthority.json -func ExampleGatewayCertificateAuthorityClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGatewayCertificateAuthorityClient().GetEntityTag(ctx, "rg1", "apimService1", "gw1", "cert1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGatewayCertificateAuthority.json -func ExampleGatewayCertificateAuthorityClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayCertificateAuthorityClient().Get(ctx, "rg1", "apimService1", "gw1", "cert1", 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.GatewayCertificateAuthorityContract = armapimanagement.GatewayCertificateAuthorityContract{ - // Name: to.Ptr("cert1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/certificateAuthorities"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/certificateAuthorities/cert1"), - // Properties: &armapimanagement.GatewayCertificateAuthorityContractProperties{ - // IsTrusted: to.Ptr(true), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGatewayCertificateAuthority.json -func ExampleGatewayCertificateAuthorityClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayCertificateAuthorityClient().CreateOrUpdate(ctx, "rg1", "apimService1", "gw1", "cert1", armapimanagement.GatewayCertificateAuthorityContract{ - Properties: &armapimanagement.GatewayCertificateAuthorityContractProperties{ - IsTrusted: to.Ptr(false), - }, - }, &armapimanagement.GatewayCertificateAuthorityClientCreateOrUpdateOptions{IfMatch: 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.GatewayCertificateAuthorityContract = armapimanagement.GatewayCertificateAuthorityContract{ - // Name: to.Ptr("cert1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/certificateAuthorities"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/certificateAuthorities/cert1"), - // Properties: &armapimanagement.GatewayCertificateAuthorityContractProperties{ - // IsTrusted: to.Ptr(false), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGatewayCertificateAuthority.json -func ExampleGatewayCertificateAuthorityClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGatewayCertificateAuthorityClient().Delete(ctx, "rg1", "apimService1", "gw1", "default", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/gatewayhostnameconfiguration_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/gatewayhostnameconfiguration_client.go index ba2b20a9ad45..8481ab87f77d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/gatewayhostnameconfiguration_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/gatewayhostnameconfiguration_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type GatewayHostnameConfigurationClient struct { } // NewGatewayHostnameConfigurationClient creates a new instance of GatewayHostnameConfigurationClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewGatewayHostnameConfigurationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GatewayHostnameConfigurationClient, error) { @@ -47,7 +44,7 @@ func NewGatewayHostnameConfigurationClient(subscriptionID string, credential azc // CreateOrUpdate - Creates of updates hostname configuration for a Gateway. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -105,12 +102,12 @@ func (client *GatewayHostnameConfigurationClient) createOrUpdateCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -132,7 +129,7 @@ func (client *GatewayHostnameConfigurationClient) createOrUpdateHandleResponse(r // Delete - Deletes the specified hostname configuration from the specified Gateway. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -164,7 +161,7 @@ func (client *GatewayHostnameConfigurationClient) Delete(ctx context.Context, re } // deleteCreateRequest creates the Delete request. -func (client *GatewayHostnameConfigurationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, ifMatch string, options *GatewayHostnameConfigurationClientDeleteOptions) (*policy.Request, error) { +func (client *GatewayHostnameConfigurationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, ifMatch string, _ *GatewayHostnameConfigurationClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -191,17 +188,17 @@ func (client *GatewayHostnameConfigurationClient) deleteCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Get details of a hostname configuration // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -232,7 +229,7 @@ func (client *GatewayHostnameConfigurationClient) Get(ctx context.Context, resou } // getCreateRequest creates the Get request. -func (client *GatewayHostnameConfigurationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, options *GatewayHostnameConfigurationClientGetOptions) (*policy.Request, error) { +func (client *GatewayHostnameConfigurationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, _ *GatewayHostnameConfigurationClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -259,7 +256,7 @@ func (client *GatewayHostnameConfigurationClient) getCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -279,7 +276,7 @@ func (client *GatewayHostnameConfigurationClient) getHandleResponse(resp *http.R // GetEntityTag - Checks that hostname configuration entity specified by identifier exists for specified Gateway entity. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -310,7 +307,7 @@ func (client *GatewayHostnameConfigurationClient) GetEntityTag(ctx context.Conte } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *GatewayHostnameConfigurationClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, options *GatewayHostnameConfigurationClientGetEntityTagOptions) (*policy.Request, error) { +func (client *GatewayHostnameConfigurationClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, _ *GatewayHostnameConfigurationClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -337,7 +334,7 @@ func (client *GatewayHostnameConfigurationClient) getEntityTagCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -354,7 +351,7 @@ func (client *GatewayHostnameConfigurationClient) getEntityTagHandleResponse(res // NewListByServicePager - Lists the collection of hostname configurations for the specified gateway. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - gatewayID - Gateway entity identifier. Must be unique in the current API Management service instance. Must not have value @@ -411,13 +408,13 @@ func (client *GatewayHostnameConfigurationClient) listByServiceCreateRequest(ctx if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/gatewayhostnameconfiguration_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/gatewayhostnameconfiguration_client_example_test.go deleted file mode 100644 index c40d3c690f86..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/gatewayhostnameconfiguration_client_example_test.go +++ /dev/null @@ -1,176 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGatewayHostnameConfigurations.json -func ExampleGatewayHostnameConfigurationClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGatewayHostnameConfigurationClient().NewListByServicePager("rg1", "apimService1", "gw1", &armapimanagement.GatewayHostnameConfigurationClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.GatewayHostnameConfigurationCollection = armapimanagement.GatewayHostnameConfigurationCollection{ - // Value: []*armapimanagement.GatewayHostnameConfigurationContract{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/hostnameConfigurations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/hostnameConfigurations/default"), - // Properties: &armapimanagement.GatewayHostnameConfigurationContractProperties{ - // CertificateID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1"), - // Hostname: to.Ptr("*"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // }, - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/hostnameConfigurations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/hostnameConfigurations/hostname1"), - // Properties: &armapimanagement.GatewayHostnameConfigurationContractProperties{ - // CertificateID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert2"), - // Hostname: to.Ptr("foo.bar.com"), - // NegotiateClientCertificate: to.Ptr(true), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGatewayHostnameConfiguration.json -func ExampleGatewayHostnameConfigurationClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGatewayHostnameConfigurationClient().GetEntityTag(ctx, "rg1", "apimService1", "gw1", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGatewayHostnameConfiguration.json -func ExampleGatewayHostnameConfigurationClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayHostnameConfigurationClient().Get(ctx, "rg1", "apimService1", "gw1", "default", 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.GatewayHostnameConfigurationContract = armapimanagement.GatewayHostnameConfigurationContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/hostnameConfigurations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/hostnameConfigurations/default"), - // Properties: &armapimanagement.GatewayHostnameConfigurationContractProperties{ - // CertificateID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1"), - // Hostname: to.Ptr("*"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGatewayHostnameConfiguration.json -func ExampleGatewayHostnameConfigurationClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGatewayHostnameConfigurationClient().CreateOrUpdate(ctx, "rg1", "apimService1", "gw1", "default", armapimanagement.GatewayHostnameConfigurationContract{ - Properties: &armapimanagement.GatewayHostnameConfigurationContractProperties{ - CertificateID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1"), - Hostname: to.Ptr("*"), - HTTP2Enabled: to.Ptr(true), - NegotiateClientCertificate: to.Ptr(false), - Tls10Enabled: to.Ptr(false), - Tls11Enabled: to.Ptr(false), - }, - }, &armapimanagement.GatewayHostnameConfigurationClientCreateOrUpdateOptions{IfMatch: 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.GatewayHostnameConfigurationContract = armapimanagement.GatewayHostnameConfigurationContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/gateways/hostnameConfigurations"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/gateways/gw1/hostnameConfigurations/default"), - // Properties: &armapimanagement.GatewayHostnameConfigurationContractProperties{ - // CertificateID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1"), - // Hostname: to.Ptr("*"), - // HTTP2Enabled: to.Ptr(true), - // NegotiateClientCertificate: to.Ptr(false), - // Tls10Enabled: to.Ptr(false), - // Tls11Enabled: to.Ptr(false), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGatewayHostnameConfiguration.json -func ExampleGatewayHostnameConfigurationClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGatewayHostnameConfigurationClient().Delete(ctx, "rg1", "apimService1", "gw1", "default", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/gatewayskus_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/gatewayskus_client.go new file mode 100644 index 000000000000..a56d5d91b98c --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/gatewayskus_client.go @@ -0,0 +1,106 @@ +// 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 armapimanagement + +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" +) + +// GatewaySKUsClient contains the methods for the APIManagementGatewaySKUs group. +// Don't use this type directly, use NewGatewaySKUsClient() instead. +type GatewaySKUsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewGatewaySKUsClient creates a new instance of GatewaySKUsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewGatewaySKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GatewaySKUsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &GatewaySKUsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListAvailableSKUsPager - Gets all available SKU for a given API Management gateway +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - gatewayName - The name of the API Management gateway. +// - options - GatewaySKUsClientListAvailableSKUsOptions contains the optional parameters for the GatewaySKUsClient.NewListAvailableSKUsPager +// method. +func (client *GatewaySKUsClient) NewListAvailableSKUsPager(resourceGroupName string, gatewayName string, options *GatewaySKUsClientListAvailableSKUsOptions) *runtime.Pager[GatewaySKUsClientListAvailableSKUsResponse] { + return runtime.NewPager(runtime.PagingHandler[GatewaySKUsClientListAvailableSKUsResponse]{ + More: func(page GatewaySKUsClientListAvailableSKUsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *GatewaySKUsClientListAvailableSKUsResponse) (GatewaySKUsClientListAvailableSKUsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "GatewaySKUsClient.NewListAvailableSKUsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listAvailableSKUsCreateRequest(ctx, resourceGroupName, gatewayName, options) + }, nil) + if err != nil { + return GatewaySKUsClientListAvailableSKUsResponse{}, err + } + return client.listAvailableSKUsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listAvailableSKUsCreateRequest creates the ListAvailableSKUs request. +func (client *GatewaySKUsClient) listAvailableSKUsCreateRequest(ctx context.Context, resourceGroupName string, gatewayName string, _ *GatewaySKUsClientListAvailableSKUsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/skus" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAvailableSKUsHandleResponse handles the ListAvailableSKUs response. +func (client *GatewaySKUsClient) listAvailableSKUsHandleResponse(resp *http.Response) (GatewaySKUsClientListAvailableSKUsResponse, error) { + result := GatewaySKUsClientListAvailableSKUsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GatewayResourceSKUResults); err != nil { + return GatewaySKUsClientListAvailableSKUsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/globalschema_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/globalschema_client.go index e799dddd5348..0a37969657e1 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/globalschema_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/globalschema_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type GlobalSchemaClient struct { } // NewGlobalSchemaClient creates a new instance of GlobalSchemaClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewGlobalSchemaClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GlobalSchemaClient, error) { @@ -47,7 +44,7 @@ func NewGlobalSchemaClient(subscriptionID string, credential azcore.TokenCredent // BeginCreateOrUpdate - Creates new or updates existing specified Schema of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - schemaID - Schema id identifier. Must be unique in the current API Management service instance. @@ -75,7 +72,7 @@ func (client *GlobalSchemaClient) BeginCreateOrUpdate(ctx context.Context, resou // CreateOrUpdate - Creates new or updates existing specified Schema of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *GlobalSchemaClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, schemaID string, parameters GlobalSchemaContract, options *GlobalSchemaClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "GlobalSchemaClient.BeginCreateOrUpdate" @@ -90,7 +87,7 @@ func (client *GlobalSchemaClient) createOrUpdate(ctx context.Context, resourceGr if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -121,12 +118,12 @@ func (client *GlobalSchemaClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -136,7 +133,7 @@ func (client *GlobalSchemaClient) createOrUpdateCreateRequest(ctx context.Contex // Delete - Deletes specific Schema. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - schemaID - Schema id identifier. Must be unique in the current API Management service instance. @@ -165,7 +162,7 @@ func (client *GlobalSchemaClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *GlobalSchemaClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, schemaID string, ifMatch string, options *GlobalSchemaClientDeleteOptions) (*policy.Request, error) { +func (client *GlobalSchemaClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, schemaID string, ifMatch string, _ *GlobalSchemaClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -188,17 +185,17 @@ func (client *GlobalSchemaClient) deleteCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the Schema specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - schemaID - Schema id identifier. Must be unique in the current API Management service instance. @@ -226,7 +223,7 @@ func (client *GlobalSchemaClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *GlobalSchemaClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, schemaID string, options *GlobalSchemaClientGetOptions) (*policy.Request, error) { +func (client *GlobalSchemaClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, schemaID string, _ *GlobalSchemaClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -249,7 +246,7 @@ func (client *GlobalSchemaClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -269,7 +266,7 @@ func (client *GlobalSchemaClient) getHandleResponse(resp *http.Response) (Global // GetEntityTag - Gets the entity state (Etag) version of the Schema specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - schemaID - Schema id identifier. Must be unique in the current API Management service instance. @@ -298,7 +295,7 @@ func (client *GlobalSchemaClient) GetEntityTag(ctx context.Context, resourceGrou } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *GlobalSchemaClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, schemaID string, options *GlobalSchemaClientGetEntityTagOptions) (*policy.Request, error) { +func (client *GlobalSchemaClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, schemaID string, _ *GlobalSchemaClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -321,7 +318,7 @@ func (client *GlobalSchemaClient) getEntityTagCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -338,7 +335,7 @@ func (client *GlobalSchemaClient) getEntityTagHandleResponse(resp *http.Response // NewListByServicePager - Lists a collection of schemas registered with service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - GlobalSchemaClientListByServiceOptions contains the optional parameters for the GlobalSchemaClient.NewListByServicePager @@ -389,13 +386,13 @@ func (client *GlobalSchemaClient) listByServiceCreateRequest(ctx context.Context if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/globalschema_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/globalschema_client_example_test.go deleted file mode 100644 index 47fab3012569..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/globalschema_client_example_test.go +++ /dev/null @@ -1,325 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGlobalSchemas.json -func ExampleGlobalSchemaClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGlobalSchemaClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.GlobalSchemaClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.GlobalSchemaCollection = armapimanagement.GlobalSchemaCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.GlobalSchemaContract{ - // { - // Name: to.Ptr("schema1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/schemas"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/schemas/schema1"), - // Properties: &armapimanagement.GlobalSchemaContractProperties{ - // Description: to.Ptr("sample schema description"), - // SchemaType: to.Ptr(armapimanagement.SchemaTypeXML), - // Value: "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", - // }, - // }, - // { - // Name: to.Ptr("schema2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/schemas"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/schemas/schema2"), - // Properties: &armapimanagement.GlobalSchemaContractProperties{ - // Description: to.Ptr("sample schema description"), - // Document: map[string]any{ - // "type": "object", - // "$id": "https://example.com/person.schema.json", - // "$schema": "https://json-schema.org/draft/2020-12/schema", - // "properties":map[string]any{ - // "age":map[string]any{ - // "type": "integer", - // "description": "Age in years which must be equal to or greater than zero.", - // "minimum": float64(0), - // }, - // "firstName":map[string]any{ - // "type": "string", - // "description": "The person's first name.", - // }, - // "lastName":map[string]any{ - // "type": "string", - // "description": "The person's last name.", - // }, - // }, - // "title": "Person", - // }, - // SchemaType: to.Ptr(armapimanagement.SchemaTypeJSON), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGlobalSchema.json -func ExampleGlobalSchemaClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGlobalSchemaClient().GetEntityTag(ctx, "rg1", "apimService1", "myschema", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGlobalSchema1.json -func ExampleGlobalSchemaClient_Get_apiManagementGetSchema1() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGlobalSchemaClient().Get(ctx, "rg1", "apimService1", "schema1", 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.GlobalSchemaContract = armapimanagement.GlobalSchemaContract{ - // Name: to.Ptr("schema1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/schemas"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/schemas/schema1"), - // Properties: &armapimanagement.GlobalSchemaContractProperties{ - // Description: to.Ptr("sample schema description"), - // SchemaType: to.Ptr(armapimanagement.SchemaTypeXML), - // Value: "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGlobalSchema2.json -func ExampleGlobalSchemaClient_Get_apiManagementGetSchema2() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGlobalSchemaClient().Get(ctx, "rg1", "apimService1", "schema2", 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.GlobalSchemaContract = armapimanagement.GlobalSchemaContract{ - // Name: to.Ptr("schema2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/schemas"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/schemas/schema2"), - // Properties: &armapimanagement.GlobalSchemaContractProperties{ - // Description: to.Ptr("sample schema description"), - // Document: map[string]any{ - // "type": "object", - // "$id": "https://example.com/person.schema.json", - // "$schema": "https://json-schema.org/draft/2020-12/schema", - // "properties":map[string]any{ - // "age":map[string]any{ - // "type": "integer", - // "description": "Age in years which must be equal to or greater than zero.", - // "minimum": float64(0), - // }, - // "firstName":map[string]any{ - // "type": "string", - // "description": "The person's first name.", - // }, - // "lastName":map[string]any{ - // "type": "string", - // "description": "The person's last name.", - // }, - // }, - // "title": "Person", - // }, - // SchemaType: to.Ptr(armapimanagement.SchemaTypeJSON), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGlobalSchema1.json -func ExampleGlobalSchemaClient_BeginCreateOrUpdate_apiManagementCreateSchema1() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGlobalSchemaClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "schema1", armapimanagement.GlobalSchemaContract{ - Properties: &armapimanagement.GlobalSchemaContractProperties{ - Description: to.Ptr("sample schema description"), - SchemaType: to.Ptr(armapimanagement.SchemaTypeXML), - Value: "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", - }, - }, &armapimanagement.GlobalSchemaClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GlobalSchemaContract = armapimanagement.GlobalSchemaContract{ - // Name: to.Ptr("schema1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/schemas"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/schemas/schema1"), - // Properties: &armapimanagement.GlobalSchemaContractProperties{ - // Description: to.Ptr("sample schema description"), - // SchemaType: to.Ptr(armapimanagement.SchemaTypeXML), - // Value: "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGlobalSchema2.json -func ExampleGlobalSchemaClient_BeginCreateOrUpdate_apiManagementCreateSchema2() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGlobalSchemaClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "schema1", armapimanagement.GlobalSchemaContract{ - Properties: &armapimanagement.GlobalSchemaContractProperties{ - Description: to.Ptr("sample schema description"), - Document: map[string]any{ - "type": "object", - "$id": "https://example.com/person.schema.json", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "properties": map[string]any{ - "age": map[string]any{ - "type": "integer", - "description": "Age in years which must be equal to or greater than zero.", - "minimum": float64(0), - }, - "firstName": map[string]any{ - "type": "string", - "description": "The person's first name.", - }, - "lastName": map[string]any{ - "type": "string", - "description": "The person's last name.", - }, - }, - "title": "Person", - }, - SchemaType: to.Ptr(armapimanagement.SchemaTypeJSON), - }, - }, &armapimanagement.GlobalSchemaClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GlobalSchemaContract = armapimanagement.GlobalSchemaContract{ - // Name: to.Ptr("schema1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/schemas"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/schemas/schema1"), - // Properties: &armapimanagement.GlobalSchemaContractProperties{ - // Description: to.Ptr("sample schema description"), - // Document: map[string]any{ - // "type": "object", - // "$id": "https://example.com/person.schema.json", - // "$schema": "https://json-schema.org/draft/2020-12/schema", - // "properties":map[string]any{ - // "age":map[string]any{ - // "type": "integer", - // "description": "Age in years which must be equal to or greater than zero.", - // "minimum": float64(0), - // }, - // "firstName":map[string]any{ - // "type": "string", - // "description": "The person's first name.", - // }, - // "lastName":map[string]any{ - // "type": "string", - // "description": "The person's last name.", - // }, - // }, - // "title": "Person", - // }, - // SchemaType: to.Ptr(armapimanagement.SchemaTypeJSON), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGlobalSchema.json -func ExampleGlobalSchemaClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGlobalSchemaClient().Delete(ctx, "rg1", "apimService1", "schema1", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/go.mod b/sdk/resourcemanager/apimanagement/armapimanagement/go.mod index b93be8da6b62..08638161e7ba 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/go.mod +++ b/sdk/resourcemanager/apimanagement/armapimanagement/go.mod @@ -1,10 +1,9 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2 +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v3 go 1.23.0 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 @@ -12,6 +11,7 @@ require ( ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang-jwt/jwt/v5 v5.2.2 // indirect diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolver_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolver_client.go index 24344cdae950..bdc13f4dec1d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolver_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolver_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type GraphQLAPIResolverClient struct { } // NewGraphQLAPIResolverClient creates a new instance of GraphQLAPIResolverClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewGraphQLAPIResolverClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GraphQLAPIResolverClient, error) { @@ -47,7 +44,7 @@ func NewGraphQLAPIResolverClient(subscriptionID string, credential azcore.TokenC // CreateOrUpdate - Creates a new resolver in the GraphQL API or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -106,12 +103,12 @@ func (client *GraphQLAPIResolverClient) createOrUpdateCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -133,7 +130,7 @@ func (client *GraphQLAPIResolverClient) createOrUpdateHandleResponse(resp *http. // Delete - Deletes the specified resolver in the GraphQL API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -165,7 +162,7 @@ func (client *GraphQLAPIResolverClient) Delete(ctx context.Context, resourceGrou } // deleteCreateRequest creates the Delete request. -func (client *GraphQLAPIResolverClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, ifMatch string, options *GraphQLAPIResolverClientDeleteOptions) (*policy.Request, error) { +func (client *GraphQLAPIResolverClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, ifMatch string, _ *GraphQLAPIResolverClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -192,17 +189,17 @@ func (client *GraphQLAPIResolverClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the GraphQL API Resolver specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -232,7 +229,7 @@ func (client *GraphQLAPIResolverClient) Get(ctx context.Context, resourceGroupNa } // getCreateRequest creates the Get request. -func (client *GraphQLAPIResolverClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, options *GraphQLAPIResolverClientGetOptions) (*policy.Request, error) { +func (client *GraphQLAPIResolverClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, _ *GraphQLAPIResolverClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -259,7 +256,7 @@ func (client *GraphQLAPIResolverClient) getCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -279,7 +276,7 @@ func (client *GraphQLAPIResolverClient) getHandleResponse(resp *http.Response) ( // GetEntityTag - Gets the entity state (Etag) version of the GraphQL API resolver specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -310,7 +307,7 @@ func (client *GraphQLAPIResolverClient) GetEntityTag(ctx context.Context, resour } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *GraphQLAPIResolverClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, options *GraphQLAPIResolverClientGetEntityTagOptions) (*policy.Request, error) { +func (client *GraphQLAPIResolverClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, _ *GraphQLAPIResolverClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -337,7 +334,7 @@ func (client *GraphQLAPIResolverClient) getEntityTagCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -354,7 +351,7 @@ func (client *GraphQLAPIResolverClient) getEntityTagHandleResponse(resp *http.Re // NewListByAPIPager - Lists a collection of the resolvers for the specified GraphQL API. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -411,13 +408,13 @@ func (client *GraphQLAPIResolverClient) listByAPICreateRequest(ctx context.Conte if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -435,7 +432,7 @@ func (client *GraphQLAPIResolverClient) listByAPIHandleResponse(resp *http.Respo // Update - Updates the details of the resolver in the GraphQL API specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -469,7 +466,7 @@ func (client *GraphQLAPIResolverClient) Update(ctx context.Context, resourceGrou } // updateCreateRequest creates the Update request. -func (client *GraphQLAPIResolverClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, ifMatch string, parameters ResolverUpdateContract, options *GraphQLAPIResolverClientUpdateOptions) (*policy.Request, error) { +func (client *GraphQLAPIResolverClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, ifMatch string, parameters ResolverUpdateContract, _ *GraphQLAPIResolverClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -496,10 +493,10 @@ func (client *GraphQLAPIResolverClient) updateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolver_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolver_client_example_test.go deleted file mode 100644 index db4a11d5b476..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolver_client_example_test.go +++ /dev/null @@ -1,217 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGraphQLApiResolvers.json -func ExampleGraphQLAPIResolverClient_NewListByAPIPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGraphQLAPIResolverClient().NewListByAPIPager("rg1", "apimService1", "57d2ef278aa04f0888cba3f3", &armapimanagement.GraphQLAPIResolverClientListByAPIOptions{Filter: nil, - Top: nil, - Skip: 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.ResolverCollection = armapimanagement.ResolverCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.ResolverContract{ - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/resolvers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/resolvers/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.ResolverEntityBaseContract{ - // Path: to.Ptr("Query/users"), - // Description: to.Ptr("A GraphQL Resolver example"), - // DisplayName: to.Ptr("Query Users"), - // }, - // }, - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cda"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/resolvers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/resolvers/57d2ef278aa04f0ad01d6cda"), - // Properties: &armapimanagement.ResolverEntityBaseContract{ - // Path: to.Ptr("Mutation/makeUser"), - // Description: to.Ptr("A GraphQL Resolver example"), - // DisplayName: to.Ptr("Mutation makeUser"), - // }, - // }, - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cd9"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/resolvers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/resolvers/57d2ef278aa04f0ad01d6cd9"), - // Properties: &armapimanagement.ResolverEntityBaseContract{ - // Path: to.Ptr("User/id"), - // Description: to.Ptr("A GraphQL Resolver example"), - // DisplayName: to.Ptr("Query for User Id field"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGraphQLApiResolver.json -func ExampleGraphQLAPIResolverClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGraphQLAPIResolverClient().GetEntityTag(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGraphQLApiResolver.json -func ExampleGraphQLAPIResolverClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGraphQLAPIResolverClient().Get(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", 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.ResolverContract = armapimanagement.ResolverContract{ - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/resolvers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/resolvers/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.ResolverEntityBaseContract{ - // Path: to.Ptr("Query/users"), - // Description: to.Ptr("A GraphQL Resolver example"), - // DisplayName: to.Ptr("Query Users"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGraphQLApiResolver.json -func ExampleGraphQLAPIResolverClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGraphQLAPIResolverClient().CreateOrUpdate(ctx, "rg1", "apimService1", "someAPI", "newResolver", armapimanagement.ResolverContract{ - Properties: &armapimanagement.ResolverEntityBaseContract{ - Path: to.Ptr("Query/users"), - Description: to.Ptr("A GraphQL Resolver example"), - DisplayName: to.Ptr("Query Users"), - }, - }, &armapimanagement.GraphQLAPIResolverClientCreateOrUpdateOptions{IfMatch: 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.ResolverContract = armapimanagement.ResolverContract{ - // Name: to.Ptr("newResolver"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/resolvers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/someAPI/resolvers/newResolver"), - // Properties: &armapimanagement.ResolverEntityBaseContract{ - // Path: to.Ptr("Query/users"), - // Description: to.Ptr("A GraphQL Resolver example"), - // DisplayName: to.Ptr("Query Users"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateGraphQLApiResolver.json -func ExampleGraphQLAPIResolverClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGraphQLAPIResolverClient().Update(ctx, "rg1", "apimService1", "echo-api", "resolverId", "*", armapimanagement.ResolverUpdateContract{ - Properties: &armapimanagement.ResolverUpdateContractProperties{ - Path: to.Ptr("Query/adminUsers"), - Description: to.Ptr("A GraphQL Resolver example"), - DisplayName: to.Ptr("Query AdminUsers"), - }, - }, 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.ResolverContract = armapimanagement.ResolverContract{ - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/resolvers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d2ef278aa04f0888cba3f3/resolvers/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.ResolverEntityBaseContract{ - // Path: to.Ptr("Query/adminUsers"), - // Description: to.Ptr("A GraphQL Resolver example"), - // DisplayName: to.Ptr("Query AdminUsers"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGraphQLApiResolver.json -func ExampleGraphQLAPIResolverClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGraphQLAPIResolverClient().Delete(ctx, "rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0ad01d6cdc", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolverpolicy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolverpolicy_client.go index 8a61760e940d..9c497959a6f1 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolverpolicy_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolverpolicy_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type GraphQLAPIResolverPolicyClient struct { } // NewGraphQLAPIResolverPolicyClient creates a new instance of GraphQLAPIResolverPolicyClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewGraphQLAPIResolverPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GraphQLAPIResolverPolicyClient, error) { @@ -46,7 +43,7 @@ func NewGraphQLAPIResolverPolicyClient(subscriptionID string, credential azcore. // CreateOrUpdate - Creates or updates policy configuration for the GraphQL API Resolver level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -110,12 +107,12 @@ func (client *GraphQLAPIResolverPolicyClient) createOrUpdateCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -137,7 +134,7 @@ func (client *GraphQLAPIResolverPolicyClient) createOrUpdateHandleResponse(resp // Delete - Deletes the policy configuration at the GraphQL Api Resolver. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -170,7 +167,7 @@ func (client *GraphQLAPIResolverPolicyClient) Delete(ctx context.Context, resour } // deleteCreateRequest creates the Delete request. -func (client *GraphQLAPIResolverPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, policyID PolicyIDName, ifMatch string, options *GraphQLAPIResolverPolicyClientDeleteOptions) (*policy.Request, error) { +func (client *GraphQLAPIResolverPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, policyID PolicyIDName, ifMatch string, _ *GraphQLAPIResolverPolicyClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -201,17 +198,17 @@ func (client *GraphQLAPIResolverPolicyClient) deleteCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Get the policy configuration at the GraphQL API Resolver level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -274,10 +271,10 @@ func (client *GraphQLAPIResolverPolicyClient) getCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Format != nil { reqQP.Set("format", string(*options.Format)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -297,7 +294,7 @@ func (client *GraphQLAPIResolverPolicyClient) getHandleResponse(resp *http.Respo // GetEntityTag - Gets the entity state (Etag) version of the GraphQL API resolver policy specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -329,7 +326,7 @@ func (client *GraphQLAPIResolverPolicyClient) GetEntityTag(ctx context.Context, } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *GraphQLAPIResolverPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, policyID PolicyIDName, options *GraphQLAPIResolverPolicyClientGetEntityTagOptions) (*policy.Request, error) { +func (client *GraphQLAPIResolverPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, policyID PolicyIDName, _ *GraphQLAPIResolverPolicyClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -360,7 +357,7 @@ func (client *GraphQLAPIResolverPolicyClient) getEntityTagCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -377,7 +374,7 @@ func (client *GraphQLAPIResolverPolicyClient) getEntityTagHandleResponse(resp *h // NewListByResolverPager - Get the list of policy configuration at the GraphQL API Resolver level. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -409,7 +406,7 @@ func (client *GraphQLAPIResolverPolicyClient) NewListByResolverPager(resourceGro } // listByResolverCreateRequest creates the ListByResolver request. -func (client *GraphQLAPIResolverPolicyClient) listByResolverCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, options *GraphQLAPIResolverPolicyClientListByResolverOptions) (*policy.Request, error) { +func (client *GraphQLAPIResolverPolicyClient) listByResolverCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, resolverID string, _ *GraphQLAPIResolverPolicyClientListByResolverOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/policies" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -436,7 +433,7 @@ func (client *GraphQLAPIResolverPolicyClient) listByResolverCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolverpolicy_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolverpolicy_client_example_test.go deleted file mode 100644 index 01b22f96bf1d..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/graphqlapiresolverpolicy_client_example_test.go +++ /dev/null @@ -1,151 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGraphQLApiResolverPolicies.json -func ExampleGraphQLAPIResolverPolicyClient_NewListByResolverPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGraphQLAPIResolverPolicyClient().NewListByResolverPager("rg1", "apimService1", "599e2953193c3c0bd0b3e2fa", "599e29ab193c3c0bd0b3e2fb", 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.PolicyCollection = armapimanagement.PolicyCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.PolicyContract{ - // { - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/resolvers/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/599e2953193c3c0bd0b3e2fa/resolvers/599e29ab193c3c0bd0b3e2fb/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n\r\n \r\n GET\r\n\r\n/api/users \r\n \r\n \r\n \r\n \r\n \r\n { \"id\": \"{{body.id}}\" } \r\n"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGraphQLApiResolverPolicy.json -func ExampleGraphQLAPIResolverPolicyClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGraphQLAPIResolverPolicyClient().GetEntityTag(ctx, "rg1", "apimService1", "5600b539c53f5b0062040001", "5600b53ac53f5b0062080006", armapimanagement.PolicyIDNamePolicy, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGraphQLApiResolverPolicy.json -func ExampleGraphQLAPIResolverPolicyClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGraphQLAPIResolverPolicyClient().Get(ctx, "rg1", "apimService1", "5600b539c53f5b0062040001", "5600b53ac53f5b0062080006", armapimanagement.PolicyIDNamePolicy, &armapimanagement.GraphQLAPIResolverPolicyClientGetOptions{Format: 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/resolvers/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b539c53f5b0062040001/resolvers/5600b53ac53f5b0062080006/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n GET\r\n\r\n/api/users\r\n\r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGraphQLApiResolverPolicy.json -func ExampleGraphQLAPIResolverPolicyClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGraphQLAPIResolverPolicyClient().CreateOrUpdate(ctx, "rg1", "apimService1", "5600b57e7e8880006a040001", "5600b57e7e8880006a080001", armapimanagement.PolicyIDNamePolicy, armapimanagement.PolicyContract{ - Properties: &armapimanagement.PolicyContractProperties{ - Format: to.Ptr(armapimanagement.PolicyContentFormatXML), - Value: to.Ptr("GET/api/users"), - }, - }, &armapimanagement.GraphQLAPIResolverPolicyClientCreateOrUpdateOptions{IfMatch: to.Ptr("*")}) - 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis/resolvers/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b57e7e8880006a040001/resolvers/5600b57e7e8880006a080001/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n GET\r\n\r\n/api/users\r\n\r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGraphQLApiResolverPolicy.json -func ExampleGraphQLAPIResolverPolicyClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGraphQLAPIResolverPolicyClient().Delete(ctx, "rg1", "apimService1", "testapi", "testResolver", armapimanagement.PolicyIDNamePolicy, "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/group_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/group_client.go index 4a36cdb6141c..d8b88e62c754 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/group_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/group_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type GroupClient struct { } // NewGroupClient creates a new instance of GroupClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GroupClient, error) { @@ -47,7 +44,7 @@ func NewGroupClient(subscriptionID string, credential azcore.TokenCredential, op // CreateOrUpdate - Creates or Updates a group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - groupID - Group identifier. Must be unique in the current API Management service instance. @@ -99,12 +96,12 @@ func (client *GroupClient) createOrUpdateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -126,7 +123,7 @@ func (client *GroupClient) createOrUpdateHandleResponse(resp *http.Response) (Gr // Delete - Deletes specific group of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - groupID - Group identifier. Must be unique in the current API Management service instance. @@ -155,7 +152,7 @@ func (client *GroupClient) Delete(ctx context.Context, resourceGroupName string, } // deleteCreateRequest creates the Delete request. -func (client *GroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, options *GroupClientDeleteOptions) (*policy.Request, error) { +func (client *GroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, _ *GroupClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -178,17 +175,17 @@ func (client *GroupClient) deleteCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the group specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - groupID - Group identifier. Must be unique in the current API Management service instance. @@ -216,7 +213,7 @@ func (client *GroupClient) Get(ctx context.Context, resourceGroupName string, se } // getCreateRequest creates the Get request. -func (client *GroupClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, options *GroupClientGetOptions) (*policy.Request, error) { +func (client *GroupClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, _ *GroupClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -239,7 +236,7 @@ func (client *GroupClient) getCreateRequest(ctx context.Context, resourceGroupNa return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -259,7 +256,7 @@ func (client *GroupClient) getHandleResponse(resp *http.Response) (GroupClientGe // GetEntityTag - Gets the entity state (Etag) version of the group specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - groupID - Group identifier. Must be unique in the current API Management service instance. @@ -287,7 +284,7 @@ func (client *GroupClient) GetEntityTag(ctx context.Context, resourceGroupName s } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *GroupClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, options *GroupClientGetEntityTagOptions) (*policy.Request, error) { +func (client *GroupClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, _ *GroupClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -310,7 +307,7 @@ func (client *GroupClient) getEntityTagCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -327,7 +324,7 @@ func (client *GroupClient) getEntityTagHandleResponse(resp *http.Response) (Grou // NewListByServicePager - Lists a collection of groups defined within a service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - GroupClientListByServiceOptions contains the optional parameters for the GroupClient.NewListByServicePager method. @@ -377,13 +374,13 @@ func (client *GroupClient) listByServiceCreateRequest(ctx context.Context, resou if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -401,7 +398,7 @@ func (client *GroupClient) listByServiceHandleResponse(resp *http.Response) (Gro // Update - Updates the details of the group specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - groupID - Group identifier. Must be unique in the current API Management service instance. @@ -432,7 +429,7 @@ func (client *GroupClient) Update(ctx context.Context, resourceGroupName string, } // updateCreateRequest creates the Update request. -func (client *GroupClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, parameters GroupUpdateParameters, options *GroupClientUpdateOptions) (*policy.Request, error) { +func (client *GroupClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, parameters GroupUpdateParameters, _ *GroupClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -455,10 +452,10 @@ func (client *GroupClient) updateCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/group_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/group_client_example_test.go deleted file mode 100644 index 1ad7bd641806..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/group_client_example_test.go +++ /dev/null @@ -1,269 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGroups.json -func ExampleGroupClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGroupClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.GroupClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.GroupCollection = armapimanagement.GroupCollection{ - // Count: to.Ptr[int64](4), - // Value: []*armapimanagement.GroupContract{ - // { - // Name: to.Ptr("5600b59375ff190048020001"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/5600b59375ff190048020001"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeSystem), - // Description: to.Ptr("Administrators is a built-in group. Its membership is managed by the system. Microsoft Azure subscription administrators fall into this group."), - // BuiltIn: to.Ptr(true), - // DisplayName: to.Ptr("Administrators"), - // }, - // }, - // { - // Name: to.Ptr("59306a29e4bbd510dc24e5f9"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/59306a29e4bbd510dc24e5f9"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeExternal), - // Description: to.Ptr("awesome group of people"), - // BuiltIn: to.Ptr(false), - // DisplayName: to.Ptr("AwesomeGroup (samiraad.onmicrosoft.com)"), - // ExternalID: to.Ptr("aad://samiraad.onmicrosoft.com/groups/3773adf4-032e-4d25-9988-eaff9ca72eca"), - // }, - // }, - // { - // Name: to.Ptr("5600b59375ff190048020002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/5600b59375ff190048020002"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeSystem), - // Description: to.Ptr("Developers is a built-in group. Its membership is managed by the system. Signed-in users fall into this group."), - // BuiltIn: to.Ptr(true), - // DisplayName: to.Ptr("Developers"), - // }, - // }, - // { - // Name: to.Ptr("5600b59375ff190048020003"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/5600b59375ff190048020003"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeSystem), - // Description: to.Ptr("Guests is a built-in group. Its membership is managed by the system. Unauthenticated users visiting the developer portal fall into this group."), - // BuiltIn: to.Ptr(true), - // DisplayName: to.Ptr("Guests"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGroup.json -func ExampleGroupClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGroupClient().GetEntityTag(ctx, "rg1", "apimService1", "59306a29e4bbd510dc24e5f9", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetGroup.json -func ExampleGroupClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGroupClient().Get(ctx, "rg1", "apimService1", "59306a29e4bbd510dc24e5f9", 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.GroupContract = armapimanagement.GroupContract{ - // Name: to.Ptr("59306a29e4bbd510dc24e5f9"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/59306a29e4bbd510dc24e5f9"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeExternal), - // Description: to.Ptr("awesome group of people"), - // BuiltIn: to.Ptr(false), - // DisplayName: to.Ptr("AwesomeGroup (samiraad.onmicrosoft.com)"), - // ExternalID: to.Ptr("aad://samiraad.onmicrosoft.com/groups/3773adf4-032e-4d25-9988-eaff9ca72eca"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGroup.json -func ExampleGroupClient_CreateOrUpdate_apiManagementCreateGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGroupClient().CreateOrUpdate(ctx, "rg1", "apimService1", "tempgroup", armapimanagement.GroupCreateParameters{ - Properties: &armapimanagement.GroupCreateParametersProperties{ - DisplayName: to.Ptr("temp group"), - }, - }, &armapimanagement.GroupClientCreateOrUpdateOptions{IfMatch: 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.GroupContract = armapimanagement.GroupContract{ - // Name: to.Ptr("tempgroup"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/tempgroup"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeCustom), - // DisplayName: to.Ptr("temp group"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGroupExternal.json -func ExampleGroupClient_CreateOrUpdate_apiManagementCreateGroupExternal() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGroupClient().CreateOrUpdate(ctx, "rg1", "apimService1", "aadGroup", armapimanagement.GroupCreateParameters{ - Properties: &armapimanagement.GroupCreateParametersProperties{ - Type: to.Ptr(armapimanagement.GroupTypeExternal), - Description: to.Ptr("new group to test"), - DisplayName: to.Ptr("NewGroup (samiraad.onmicrosoft.com)"), - ExternalID: to.Ptr("aad://samiraad.onmicrosoft.com/groups/83cf2753-5831-4675-bc0e-2f8dc067c58d"), - }, - }, &armapimanagement.GroupClientCreateOrUpdateOptions{IfMatch: 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.GroupContract = armapimanagement.GroupContract{ - // Name: to.Ptr("aadGroup"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/aadGroup"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeExternal), - // Description: to.Ptr("new group to test"), - // DisplayName: to.Ptr("NewGroup (samiraad.onmicrosoft.com)"), - // ExternalID: to.Ptr("aad://samiraad.onmicrosoft.com/groups/83cf2753-5831-4675-bc0e-2f8dc067c58d"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateGroup.json -func ExampleGroupClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGroupClient().Update(ctx, "rg1", "apimService1", "tempgroup", "*", armapimanagement.GroupUpdateParameters{ - Properties: &armapimanagement.GroupUpdateParametersProperties{ - DisplayName: to.Ptr("temp group"), - }, - }, 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.GroupContract = armapimanagement.GroupContract{ - // Name: to.Ptr("tempgroup"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/tempgroup"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeExternal), - // Description: to.Ptr("awesome group of people"), - // BuiltIn: to.Ptr(false), - // DisplayName: to.Ptr("tempgroup"), - // ExternalID: to.Ptr("aad://samiraad.onmicrosoft.com/groups/3773adf4-032e-4d25-9988-eaff9ca72eca"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGroup.json -func ExampleGroupClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGroupClient().Delete(ctx, "rg1", "apimService1", "aadGroup", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/groupuser_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/groupuser_client.go index 39871122e0c6..8186feec8e62 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/groupuser_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/groupuser_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type GroupUserClient struct { } // NewGroupUserClient creates a new instance of GroupUserClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewGroupUserClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GroupUserClient, error) { @@ -46,7 +43,7 @@ func NewGroupUserClient(subscriptionID string, credential azcore.TokenCredential // CheckEntityExists - Checks that user entity specified by identifier is associated with the group entity. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - groupID - Group identifier. Must be unique in the current API Management service instance. @@ -75,7 +72,7 @@ func (client *GroupUserClient) CheckEntityExists(ctx context.Context, resourceGr } // checkEntityExistsCreateRequest creates the CheckEntityExists request. -func (client *GroupUserClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, options *GroupUserClientCheckEntityExistsOptions) (*policy.Request, error) { +func (client *GroupUserClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, _ *GroupUserClientCheckEntityExistsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -102,7 +99,7 @@ func (client *GroupUserClient) checkEntityExistsCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -111,7 +108,7 @@ func (client *GroupUserClient) checkEntityExistsCreateRequest(ctx context.Contex // Create - Add existing user to existing group // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - groupID - Group identifier. Must be unique in the current API Management service instance. @@ -140,7 +137,7 @@ func (client *GroupUserClient) Create(ctx context.Context, resourceGroupName str } // createCreateRequest creates the Create request. -func (client *GroupUserClient) createCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, options *GroupUserClientCreateOptions) (*policy.Request, error) { +func (client *GroupUserClient) createCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, _ *GroupUserClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -167,7 +164,7 @@ func (client *GroupUserClient) createCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -185,7 +182,7 @@ func (client *GroupUserClient) createHandleResponse(resp *http.Response) (GroupU // Delete - Remove existing user from existing group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - groupID - Group identifier. Must be unique in the current API Management service instance. @@ -213,7 +210,7 @@ func (client *GroupUserClient) Delete(ctx context.Context, resourceGroupName str } // deleteCreateRequest creates the Delete request. -func (client *GroupUserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, options *GroupUserClientDeleteOptions) (*policy.Request, error) { +func (client *GroupUserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, _ *GroupUserClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -240,7 +237,7 @@ func (client *GroupUserClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -248,7 +245,7 @@ func (client *GroupUserClient) deleteCreateRequest(ctx context.Context, resource // NewListPager - Lists a collection of user entities associated with the group. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - groupID - Group identifier. Must be unique in the current API Management service instance. @@ -303,13 +300,13 @@ func (client *GroupUserClient) listCreateRequest(ctx context.Context, resourceGr if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/groupuser_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/groupuser_client_example_test.go deleted file mode 100644 index f41c207544b0..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/groupuser_client_example_test.go +++ /dev/null @@ -1,138 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListGroupUsers.json -func ExampleGroupUserClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGroupUserClient().NewListPager("rg1", "apimService1", "57d2ef278aa04f0888cba3f3", &armapimanagement.GroupUserClientListOptions{Filter: nil, - Top: nil, - Skip: 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.UserCollection = armapimanagement.UserCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.UserContract{ - // { - // Name: to.Ptr("armTemplateUser1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups/users"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/kjoshiarmTemplateUser1"), - // Properties: &armapimanagement.UserContractProperties{ - // Identities: []*armapimanagement.UserIdentityContract{ - // { - // ID: to.Ptr("user1@live.com"), - // Provider: to.Ptr("Basic"), - // }}, - // Note: to.Ptr("note for user 1"), - // State: to.Ptr(armapimanagement.UserStateActive), - // Email: to.Ptr("user1@live.com"), - // FirstName: to.Ptr("user1"), - // LastName: to.Ptr("lastname1"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-05-31T18:54:41.447Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadGroupUser.json -func ExampleGroupUserClient_CheckEntityExists() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGroupUserClient().CheckEntityExists(ctx, "rg1", "apimService1", "59306a29e4bbd510dc24e5f9", "5931a75ae4bbd512a88c680b", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateGroupUser.json -func ExampleGroupUserClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGroupUserClient().Create(ctx, "rg1", "apimService1", "tempgroup", "59307d350af58404d8a26300", 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.UserContract = armapimanagement.UserContract{ - // Name: to.Ptr("59307d350af58404d8a26300"), - // Type: to.Ptr("Microsoft.ApiManagement/service/groups/users"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/59307d350af58404d8a26300"), - // Properties: &armapimanagement.UserContractProperties{ - // Identities: []*armapimanagement.UserIdentityContract{ - // }, - // State: to.Ptr(armapimanagement.UserStateActive), - // Email: to.Ptr("testuser1@live.com"), - // FirstName: to.Ptr("test"), - // Groups: []*armapimanagement.GroupContractProperties{ - // }, - // LastName: to.Ptr("user"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-01T20:46:45.437Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteGroupUser.json -func ExampleGroupUserClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewGroupUserClient().Delete(ctx, "rg1", "apimService1", "templategroup", "59307d350af58404d8a26300", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/identityprovider_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/identityprovider_client.go index 9f611de33511..1f547ab42bdf 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/identityprovider_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/identityprovider_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type IdentityProviderClient struct { } // NewIdentityProviderClient creates a new instance of IdentityProviderClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewIdentityProviderClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IdentityProviderClient, error) { @@ -46,7 +43,7 @@ func NewIdentityProviderClient(subscriptionID string, credential azcore.TokenCre // CreateOrUpdate - Creates or Updates the IdentityProvider configuration. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - identityProviderName - Identity Provider Type identifier. @@ -99,12 +96,12 @@ func (client *IdentityProviderClient) createOrUpdateCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -126,7 +123,7 @@ func (client *IdentityProviderClient) createOrUpdateHandleResponse(resp *http.Re // Delete - Deletes the specified identity provider configuration. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - identityProviderName - Identity Provider Type identifier. @@ -155,7 +152,7 @@ func (client *IdentityProviderClient) Delete(ctx context.Context, resourceGroupN } // deleteCreateRequest creates the Delete request. -func (client *IdentityProviderClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string, options *IdentityProviderClientDeleteOptions) (*policy.Request, error) { +func (client *IdentityProviderClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string, _ *IdentityProviderClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -178,17 +175,17 @@ func (client *IdentityProviderClient) deleteCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the configuration details of the identity Provider configured in specified service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - identityProviderName - Identity Provider Type identifier. @@ -216,7 +213,7 @@ func (client *IdentityProviderClient) Get(ctx context.Context, resourceGroupName } // getCreateRequest creates the Get request. -func (client *IdentityProviderClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, options *IdentityProviderClientGetOptions) (*policy.Request, error) { +func (client *IdentityProviderClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, _ *IdentityProviderClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -239,7 +236,7 @@ func (client *IdentityProviderClient) getCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -259,7 +256,7 @@ func (client *IdentityProviderClient) getHandleResponse(resp *http.Response) (Id // GetEntityTag - Gets the entity state (Etag) version of the identityProvider specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - identityProviderName - Identity Provider Type identifier. @@ -288,7 +285,7 @@ func (client *IdentityProviderClient) GetEntityTag(ctx context.Context, resource } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *IdentityProviderClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, options *IdentityProviderClientGetEntityTagOptions) (*policy.Request, error) { +func (client *IdentityProviderClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, _ *IdentityProviderClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -311,7 +308,7 @@ func (client *IdentityProviderClient) getEntityTagCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -328,7 +325,7 @@ func (client *IdentityProviderClient) getEntityTagHandleResponse(resp *http.Resp // NewListByServicePager - Lists a collection of Identity Provider configured in the specified service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - IdentityProviderClientListByServiceOptions contains the optional parameters for the IdentityProviderClient.NewListByServicePager @@ -357,7 +354,7 @@ func (client *IdentityProviderClient) NewListByServicePager(resourceGroupName st } // listByServiceCreateRequest creates the ListByService request. -func (client *IdentityProviderClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *IdentityProviderClientListByServiceOptions) (*policy.Request, error) { +func (client *IdentityProviderClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *IdentityProviderClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -376,7 +373,7 @@ func (client *IdentityProviderClient) listByServiceCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -394,7 +391,7 @@ func (client *IdentityProviderClient) listByServiceHandleResponse(resp *http.Res // ListSecrets - Gets the client secret details of the Identity Provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - identityProviderName - Identity Provider Type identifier. @@ -423,7 +420,7 @@ func (client *IdentityProviderClient) ListSecrets(ctx context.Context, resourceG } // listSecretsCreateRequest creates the ListSecrets request. -func (client *IdentityProviderClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, options *IdentityProviderClientListSecretsOptions) (*policy.Request, error) { +func (client *IdentityProviderClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, _ *IdentityProviderClientListSecretsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -446,7 +443,7 @@ func (client *IdentityProviderClient) listSecretsCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -467,7 +464,7 @@ func (client *IdentityProviderClient) listSecretsHandleResponse(resp *http.Respo // Update - Updates an existing IdentityProvider configuration. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - identityProviderName - Identity Provider Type identifier. @@ -498,7 +495,7 @@ func (client *IdentityProviderClient) Update(ctx context.Context, resourceGroupN } // updateCreateRequest creates the Update request. -func (client *IdentityProviderClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string, parameters IdentityProviderUpdateParameters, options *IdentityProviderClientUpdateOptions) (*policy.Request, error) { +func (client *IdentityProviderClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string, parameters IdentityProviderUpdateParameters, _ *IdentityProviderClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -521,10 +518,10 @@ func (client *IdentityProviderClient) updateCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/identityprovider_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/identityprovider_client_example_test.go deleted file mode 100644 index ad17bc328da6..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/identityprovider_client_example_test.go +++ /dev/null @@ -1,249 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListIdentityProviders.json -func ExampleIdentityProviderClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewIdentityProviderClient().NewListByServicePager("rg1", "apimService1", 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.IdentityProviderList = armapimanagement.IdentityProviderList{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.IdentityProviderContract{ - // { - // Name: to.Ptr("Google"), - // Type: to.Ptr("Microsoft.ApiManagement/service/identityProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/identityProviders/Google"), - // Properties: &armapimanagement.IdentityProviderContractProperties{ - // Type: to.Ptr(armapimanagement.IdentityProviderTypeGoogle), - // ClientID: to.Ptr("googleId"), - // }, - // }, - // { - // Name: to.Ptr("Aad"), - // Type: to.Ptr("Microsoft.ApiManagement/service/identityProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/identityProviders/Aad"), - // Properties: &armapimanagement.IdentityProviderContractProperties{ - // Type: to.Ptr(armapimanagement.IdentityProviderTypeAAD), - // AllowedTenants: []*string{ - // to.Ptr("samiraad.onmicrosoft.com")}, - // ClientID: to.Ptr("aadapplicationid"), - // }, - // }, - // { - // Name: to.Ptr("AadB2C"), - // Type: to.Ptr("Microsoft.ApiManagement/service/identityProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/identityProviders/AadB2C"), - // Properties: &armapimanagement.IdentityProviderContractProperties{ - // Type: to.Ptr(armapimanagement.IdentityProviderTypeAADB2C), - // AllowedTenants: []*string{ - // to.Ptr("samirtestbc.onmicrosoft.com")}, - // SigninPolicyName: to.Ptr("B2C_1_Signin_Default"), - // SignupPolicyName: to.Ptr("B2C_1_Signup_Default"), - // ClientID: to.Ptr("aadb2clientId"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadIdentityProvider.json -func ExampleIdentityProviderClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewIdentityProviderClient().GetEntityTag(ctx, "rg1", "apimService1", armapimanagement.IdentityProviderTypeAADB2C, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetIdentityProvider.json -func ExampleIdentityProviderClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewIdentityProviderClient().Get(ctx, "rg1", "apimService1", armapimanagement.IdentityProviderTypeAADB2C, 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.IdentityProviderContract = armapimanagement.IdentityProviderContract{ - // Name: to.Ptr("AadB2C"), - // Type: to.Ptr("Microsoft.ApiManagement/service/identityProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/identityProviders/AadB2C"), - // Properties: &armapimanagement.IdentityProviderContractProperties{ - // Type: to.Ptr(armapimanagement.IdentityProviderTypeAADB2C), - // AllowedTenants: []*string{ - // to.Ptr("contosoaadb2c.onmicrosoft.com"), - // to.Ptr("contoso2aadb2c.onmicrosoft.com")}, - // Authority: to.Ptr("login.microsoftonline.com"), - // SigninPolicyName: to.Ptr("B2C_1_policy-signin"), - // SigninTenant: to.Ptr("contosoaadb2c.onmicrosoft.com"), - // SignupPolicyName: to.Ptr("B2C_1_policy-signup"), - // ClientID: to.Ptr("f02dafe2-b8b8-48ec-a38e-27e5c16c51e5"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateIdentityProvider.json -func ExampleIdentityProviderClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewIdentityProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.IdentityProviderTypeFacebook, armapimanagement.IdentityProviderCreateContract{ - Properties: &armapimanagement.IdentityProviderCreateContractProperties{ - ClientID: to.Ptr("facebookid"), - ClientSecret: to.Ptr("facebookapplicationsecret"), - }, - }, &armapimanagement.IdentityProviderClientCreateOrUpdateOptions{IfMatch: 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.IdentityProviderContract = armapimanagement.IdentityProviderContract{ - // Name: to.Ptr("Facebook"), - // Type: to.Ptr("Microsoft.ApiManagement/service/identityProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/identityProviders/Facebook"), - // Properties: &armapimanagement.IdentityProviderContractProperties{ - // Type: to.Ptr(armapimanagement.IdentityProviderTypeFacebook), - // ClientID: to.Ptr("facebookid"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateIdentityProvider.json -func ExampleIdentityProviderClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewIdentityProviderClient().Update(ctx, "rg1", "apimService1", armapimanagement.IdentityProviderTypeFacebook, "*", armapimanagement.IdentityProviderUpdateParameters{ - Properties: &armapimanagement.IdentityProviderUpdateProperties{ - ClientID: to.Ptr("updatedfacebookid"), - ClientSecret: to.Ptr("updatedfacebooksecret"), - }, - }, 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.IdentityProviderContract = armapimanagement.IdentityProviderContract{ - // Name: to.Ptr("AadB2C"), - // Type: to.Ptr("Microsoft.ApiManagement/service/identityProviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/identityProviders/AadB2C"), - // Properties: &armapimanagement.IdentityProviderContractProperties{ - // Type: to.Ptr(armapimanagement.IdentityProviderTypeAADB2C), - // AllowedTenants: []*string{ - // to.Ptr("contosoaadb2c.onmicrosoft.com"), - // to.Ptr("contoso2aadb2c.onmicrosoft.com")}, - // Authority: to.Ptr("login.microsoftonline.com"), - // SigninPolicyName: to.Ptr("B2C_1_policy-signin"), - // SigninTenant: to.Ptr("contosoaadb2c.onmicrosoft.com"), - // SignupPolicyName: to.Ptr("B2C_1_policy-signup"), - // ClientID: to.Ptr("f02dafe2-b8b8-48ec-a38e-27e5c16c51e5"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteIdentityProvider.json -func ExampleIdentityProviderClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewIdentityProviderClient().Delete(ctx, "rg1", "apimService1", armapimanagement.IdentityProviderTypeAAD, "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementIdentityProviderListSecrets.json -func ExampleIdentityProviderClient_ListSecrets() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewIdentityProviderClient().ListSecrets(ctx, "rg1", "apimService1", armapimanagement.IdentityProviderTypeAADB2C, 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.ClientSecretContract = armapimanagement.ClientSecretContract{ - // ClientSecret: to.Ptr("XXXXXXX"), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/issue_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/issue_client.go index 9c615e6ad905..810738624cfe 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/issue_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/issue_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type IssueClient struct { } // NewIssueClient creates a new instance of IssueClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewIssueClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IssueClient, error) { @@ -47,7 +44,7 @@ func NewIssueClient(subscriptionID string, credential azcore.TokenCredential, op // Get - Gets API Management issue details // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - issueID - Issue identifier. Must be unique in the current API Management service instance. @@ -75,7 +72,7 @@ func (client *IssueClient) Get(ctx context.Context, resourceGroupName string, se } // getCreateRequest creates the Get request. -func (client *IssueClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, issueID string, options *IssueClientGetOptions) (*policy.Request, error) { +func (client *IssueClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, issueID string, _ *IssueClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -98,7 +95,7 @@ func (client *IssueClient) getCreateRequest(ctx context.Context, resourceGroupNa return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -118,7 +115,7 @@ func (client *IssueClient) getHandleResponse(resp *http.Response) (IssueClientGe // NewListByServicePager - Lists a collection of issues in the specified service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - IssueClientListByServiceOptions contains the optional parameters for the IssueClient.NewListByServicePager method. @@ -168,13 +165,13 @@ func (client *IssueClient) listByServiceCreateRequest(ctx context.Context, resou if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/issue_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/issue_client_example_test.go deleted file mode 100644 index dcda8fae380d..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/issue_client_example_test.go +++ /dev/null @@ -1,96 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListIssues.json -func ExampleIssueClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewIssueClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.IssueClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.IssueCollection = armapimanagement.IssueCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.IssueContract{ - // { - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/issues"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/issues/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.IssueContractProperties{ - // APIID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a"), - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // State: to.Ptr(armapimanagement.StateOpen), - // Description: to.Ptr("New API issue description"), - // Title: to.Ptr("New API issue"), - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetIssue.json -func ExampleIssueClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewIssueClient().Get(ctx, "rg1", "apimService1", "57d2ef278aa04f0ad01d6cdc", 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.IssueContract = armapimanagement.IssueContract{ - // Name: to.Ptr("57d2ef278aa04f0ad01d6cdc"), - // Type: to.Ptr("Microsoft.ApiManagement/service/issues"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/issues/57d2ef278aa04f0ad01d6cdc"), - // Properties: &armapimanagement.IssueContractProperties{ - // APIID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/57d1f7558aa04f15146d9d8a"), - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-01T22:21:20.467Z"); return t}()), - // State: to.Ptr(armapimanagement.StateOpen), - // Description: to.Ptr("New API issue description"), - // Title: to.Ptr("New API issue"), - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/logger_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/logger_client.go index 4a2ae8ed048f..dba1335201f0 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/logger_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/logger_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type LoggerClient struct { } // NewLoggerClient creates a new instance of LoggerClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewLoggerClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LoggerClient, error) { @@ -47,7 +44,7 @@ func NewLoggerClient(subscriptionID string, credential azcore.TokenCredential, o // CreateOrUpdate - Creates or Updates a logger. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - loggerID - Logger identifier. Must be unique in the API Management service instance. @@ -99,12 +96,12 @@ func (client *LoggerClient) createOrUpdateCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -126,7 +123,7 @@ func (client *LoggerClient) createOrUpdateHandleResponse(resp *http.Response) (L // Delete - Deletes the specified logger. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - loggerID - Logger identifier. Must be unique in the API Management service instance. @@ -155,7 +152,7 @@ func (client *LoggerClient) Delete(ctx context.Context, resourceGroupName string } // deleteCreateRequest creates the Delete request. -func (client *LoggerClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string, options *LoggerClientDeleteOptions) (*policy.Request, error) { +func (client *LoggerClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string, _ *LoggerClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -178,17 +175,17 @@ func (client *LoggerClient) deleteCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the logger specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - loggerID - Logger identifier. Must be unique in the API Management service instance. @@ -216,7 +213,7 @@ func (client *LoggerClient) Get(ctx context.Context, resourceGroupName string, s } // getCreateRequest creates the Get request. -func (client *LoggerClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, options *LoggerClientGetOptions) (*policy.Request, error) { +func (client *LoggerClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, _ *LoggerClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -239,7 +236,7 @@ func (client *LoggerClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -259,7 +256,7 @@ func (client *LoggerClient) getHandleResponse(resp *http.Response) (LoggerClient // GetEntityTag - Gets the entity state (Etag) version of the logger specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - loggerID - Logger identifier. Must be unique in the API Management service instance. @@ -287,7 +284,7 @@ func (client *LoggerClient) GetEntityTag(ctx context.Context, resourceGroupName } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *LoggerClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, options *LoggerClientGetEntityTagOptions) (*policy.Request, error) { +func (client *LoggerClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, _ *LoggerClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -310,7 +307,7 @@ func (client *LoggerClient) getEntityTagCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -327,7 +324,7 @@ func (client *LoggerClient) getEntityTagHandleResponse(resp *http.Response) (Log // NewListByServicePager - Lists a collection of loggers in the specified service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - LoggerClientListByServiceOptions contains the optional parameters for the LoggerClient.NewListByServicePager @@ -378,13 +375,13 @@ func (client *LoggerClient) listByServiceCreateRequest(ctx context.Context, reso if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -402,7 +399,7 @@ func (client *LoggerClient) listByServiceHandleResponse(resp *http.Response) (Lo // Update - Updates an existing logger. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - loggerID - Logger identifier. Must be unique in the API Management service instance. @@ -433,7 +430,7 @@ func (client *LoggerClient) Update(ctx context.Context, resourceGroupName string } // updateCreateRequest creates the Update request. -func (client *LoggerClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string, parameters LoggerUpdateContract, options *LoggerClientUpdateOptions) (*policy.Request, error) { +func (client *LoggerClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string, parameters LoggerUpdateContract, _ *LoggerClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -456,10 +453,10 @@ func (client *LoggerClient) updateCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/logger_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/logger_client_example_test.go deleted file mode 100644 index c427d53a4a1f..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/logger_client_example_test.go +++ /dev/null @@ -1,274 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListLoggers.json -func ExampleLoggerClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLoggerClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.LoggerClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.LoggerCollection = armapimanagement.LoggerCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.LoggerContract{ - // { - // Name: to.Ptr("azuremonitor"), - // Type: to.Ptr("Microsoft.ApiManagement/service/loggers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/azuremonitor"), - // Properties: &armapimanagement.LoggerContractProperties{ - // IsBuffered: to.Ptr(true), - // LoggerType: to.Ptr(armapimanagement.LoggerTypeAzureMonitor), - // }, - // }, - // { - // Name: to.Ptr("vvktest"), - // Type: to.Ptr("Microsoft.ApiManagement/service/loggers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/vvktest"), - // Properties: &armapimanagement.LoggerContractProperties{ - // Credentials: map[string]*string{ - // "instrumentationKey": to.Ptr("{{Logger-Credentials-5b1a17ef2b3f91153004b10d}}"), - // }, - // IsBuffered: to.Ptr(true), - // LoggerType: to.Ptr(armapimanagement.LoggerTypeApplicationInsights), - // }, - // }, - // { - // Name: to.Ptr("applicationinsights"), - // Type: to.Ptr("Microsoft.ApiManagement/service/loggers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/applicationinsights"), - // Properties: &armapimanagement.LoggerContractProperties{ - // Description: to.Ptr("miaoappinsight"), - // Credentials: map[string]*string{ - // "instrumentationKey": to.Ptr("{{Logger-Credentials-5b2056062b3f911ae84a3069}}"), - // }, - // IsBuffered: to.Ptr(true), - // LoggerType: to.Ptr(armapimanagement.LoggerTypeApplicationInsights), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadLogger.json -func ExampleLoggerClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewLoggerClient().GetEntityTag(ctx, "rg1", "apimService1", "templateLogger", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetLogger.json -func ExampleLoggerClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewLoggerClient().Get(ctx, "rg1", "apimService1", "templateLogger", 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.LoggerContract = armapimanagement.LoggerContract{ - // Name: to.Ptr("kloudapilogger1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/loggers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/kloudapilogger1"), - // Properties: &armapimanagement.LoggerContractProperties{ - // Description: to.Ptr("testeventhub3again"), - // Credentials: map[string]*string{ - // "name": to.Ptr("testeventhub4"), - // "connectionString": to.Ptr("Endpoint=sb://eventhubapim.servicebus.windows.net/;SharedAccessKeyName=Sender;SharedAccessKey=************"), - // }, - // IsBuffered: to.Ptr(true), - // LoggerType: to.Ptr(armapimanagement.LoggerTypeAzureEventHub), - // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.EventHub/namespaces/eventhubapim"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAILogger.json -func ExampleLoggerClient_CreateOrUpdate_apiManagementCreateAiLogger() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewLoggerClient().CreateOrUpdate(ctx, "rg1", "apimService1", "loggerId", armapimanagement.LoggerContract{ - Properties: &armapimanagement.LoggerContractProperties{ - Description: to.Ptr("adding a new logger"), - Credentials: map[string]*string{ - "instrumentationKey": to.Ptr("11................a1"), - }, - LoggerType: to.Ptr(armapimanagement.LoggerTypeApplicationInsights), - }, - }, &armapimanagement.LoggerClientCreateOrUpdateOptions{IfMatch: 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.LoggerContract = armapimanagement.LoggerContract{ - // Name: to.Ptr("loggerId"), - // Type: to.Ptr("Microsoft.ApiManagement/service/loggers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/loggerId"), - // Properties: &armapimanagement.LoggerContractProperties{ - // Credentials: map[string]*string{ - // "instrumentationKey": to.Ptr("{{5a.......2a}}"), - // }, - // IsBuffered: to.Ptr(false), - // LoggerType: to.Ptr(armapimanagement.LoggerTypeApplicationInsights), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateEHLogger.json -func ExampleLoggerClient_CreateOrUpdate_apiManagementCreateEhLogger() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewLoggerClient().CreateOrUpdate(ctx, "rg1", "apimService1", "eh1", armapimanagement.LoggerContract{ - Properties: &armapimanagement.LoggerContractProperties{ - Description: to.Ptr("adding a new logger"), - Credentials: map[string]*string{ - "name": to.Ptr("hydraeventhub"), - "connectionString": to.Ptr("Endpoint=sb://hydraeventhub-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=********="), - }, - LoggerType: to.Ptr(armapimanagement.LoggerTypeAzureEventHub), - }, - }, &armapimanagement.LoggerClientCreateOrUpdateOptions{IfMatch: 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.LoggerContract = armapimanagement.LoggerContract{ - // Name: to.Ptr("eh1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/loggers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/eh1"), - // Properties: &armapimanagement.LoggerContractProperties{ - // Description: to.Ptr("adding a new logger"), - // Credentials: map[string]*string{ - // "connectionString": to.Ptr("{{Logger-Credentials-5f28745bbebeeb13cc3f7301}}"), - // }, - // IsBuffered: to.Ptr(true), - // LoggerType: to.Ptr(armapimanagement.LoggerTypeAzureEventHub), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateLogger.json -func ExampleLoggerClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewLoggerClient().Update(ctx, "rg1", "apimService1", "eh1", "*", armapimanagement.LoggerUpdateContract{ - Properties: &armapimanagement.LoggerUpdateParameters{ - Description: to.Ptr("updating description"), - LoggerType: to.Ptr(armapimanagement.LoggerTypeAzureEventHub), - }, - }, 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.LoggerContract = armapimanagement.LoggerContract{ - // Name: to.Ptr("eh1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/loggers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/loggers/eh1"), - // Properties: &armapimanagement.LoggerContractProperties{ - // Description: to.Ptr("updating description"), - // Credentials: map[string]*string{ - // "connectionString": to.Ptr("{{Logger-Credentials-5f28745bbebeeb13cc3f7301}}"), - // }, - // IsBuffered: to.Ptr(true), - // LoggerType: to.Ptr(armapimanagement.LoggerTypeAzureEventHub), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteLogger.json -func ExampleLoggerClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewLoggerClient().Delete(ctx, "rg1", "apimService1", "loggerId", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/models.go b/sdk/resourcemanager/apimanagement/armapimanagement/models.go index 3681bdb0a2bd..0fca70e01c0e 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/models.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/models.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -115,6 +112,9 @@ type APIContractProperties struct { // READ-ONLY; Indicates if API revision is accessible via the gateway. IsOnline *bool + + // READ-ONLY; The provisioning state + ProvisioningState *string } // APIContractUpdateProperties - API update contract properties. @@ -225,7 +225,7 @@ type APICreateOrUpdateProperties struct { // API name. Must be 1 to 300 characters long. DisplayName *string - // Format of the Content in which the API is getting imported. + // Format of the Content in which the API is getting imported. New formats can be added in the future Format *ContentFormat // Indicates if API revision is current api revision. @@ -244,7 +244,7 @@ type APICreateOrUpdateProperties struct { // * http creates a REST API // * soap creates a SOAP pass-through API // * websocket creates websocket API - // * graphql creates GraphQL API. + // * graphql creates GraphQL API. New types can be added in the future. SoapAPIType *SoapAPIType // API identifier of the source API. @@ -271,6 +271,9 @@ type APICreateOrUpdateProperties struct { // READ-ONLY; Indicates if API revision is accessible via the gateway. IsOnline *bool + + // READ-ONLY; The provisioning state + ProvisioningState *string } // APICreateOrUpdatePropertiesWsdlSelector - Criteria to limit import of WSDL to a subset of the document. @@ -772,6 +775,39 @@ type AdditionalLocation struct { PublicIPAddresses []*string } +// AllPoliciesCollection - The response of All Policies. +type AllPoliciesCollection struct { + // Next page link if any. + NextLink *string + + // AllPolicies Contract value. + Value []*AllPoliciesContract +} + +// AllPoliciesContract - AllPolicies Contract details. +type AllPoliciesContract struct { + // Properties of the All Policies. + Properties *AllPoliciesContractProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// AllPoliciesContractProperties - AllPolicies Properties. +type AllPoliciesContractProperties struct { + // Policy Restriction Compliance State + ComplianceState *PolicyComplianceState + + // Policy Identifier + ReferencePolicyID *string +} + // ApimResource - The Resource definition. type ApimResource struct { // Resource tags. @@ -810,7 +846,8 @@ type AssociationContract struct { // AssociationContractProperties - Association entity contract properties. type AssociationContractProperties struct { - // Provisioning state. + // CONSTANT; Provisioning state. + // Field has constant value "created", any specified value is ignored. ProvisioningState *string } @@ -858,6 +895,9 @@ type AuthorizationAccessPolicyContract struct { // AuthorizationAccessPolicyContractProperties - Authorization Access Policy details. type AuthorizationAccessPolicyContractProperties struct { + // The allowed Azure Active Directory Application IDs + AppIDs []*string + // The Object Id ObjectID *string @@ -1235,11 +1275,15 @@ type BackendAuthorizationHeaderCredentials struct { // BackendBaseParameters - Backend entity base Parameter set. type BackendBaseParameters struct { + // Backend Circuit Breaker Configuration + CircuitBreaker *BackendCircuitBreaker + // Backend Credentials Contract Properties Credentials *BackendCredentialsContract // Backend Description. Description *string + Pool *BackendBaseParametersPool // Backend Properties contract Properties *BackendProperties @@ -1256,6 +1300,20 @@ type BackendBaseParameters struct { // Backend Title. Title *string + + // Type of the backend. A backend can be either Single or Pool. + Type *BackendType +} + +type BackendBaseParametersPool struct { + // The list of backend entities belonging to a pool. + Services []*BackendPoolItem +} + +// BackendCircuitBreaker - The configuration of the backend circuit breaker +type BackendCircuitBreaker struct { + // The rules for tripping the backend. + Rules []*CircuitBreakerRule } // BackendCollection - Paged Backend list representation. @@ -1270,6 +1328,12 @@ type BackendCollection struct { Value []*BackendContract } +// BackendConfiguration - Information regarding how the gateway should integrate with backend systems. +type BackendConfiguration struct { + // The default hostname of the data-plane gateway to which requests can be sent. + Subnet *BackendSubnetConfiguration +} + // BackendContract - Backend details. type BackendContract struct { // Backend entity contract properties. @@ -1293,11 +1357,15 @@ type BackendContractProperties struct { // REQUIRED; Runtime Url of the Backend. URL *string + // Backend Circuit Breaker Configuration + CircuitBreaker *BackendCircuitBreaker + // Backend Credentials Contract Properties Credentials *BackendCredentialsContract // Backend Description. Description *string + Pool *BackendBaseParametersPool // Backend Properties contract Properties *BackendProperties @@ -1314,6 +1382,9 @@ type BackendContractProperties struct { // Backend Title. Title *string + + // Type of the backend. A backend can be either Single or Pool. + Type *BackendType } // BackendCredentialsContract - Details of the Credentials used to connect to Backend. @@ -1334,6 +1405,25 @@ type BackendCredentialsContract struct { Query map[string][]*string } +// BackendPool - Backend pool information +type BackendPool struct { + // The list of backend entities belonging to a pool. + Services []*BackendPoolItem +} + +// BackendPoolItem - Backend pool service information +type BackendPoolItem struct { + // REQUIRED; The unique ARM id of the backend entity. The ARM id should refer to an already existing backend entity. + ID *string + + // The priority of the backend entity in the backend pool. Must be between 0 and 100. It can be also null if the value not + // specified. + Priority *int32 + + // The weight of the backend entity in the backend pool. Must be between 0 and 100. It can be also null if the value not specified. + Weight *int32 +} + // BackendProperties - Properties specific to the Backend Type. type BackendProperties struct { // Backend Service Fabric Cluster Properties @@ -1395,6 +1485,12 @@ type BackendServiceFabricClusterProperties struct { ServerX509Names []*X509CertificateName } +// BackendSubnetConfiguration - Information regarding how the subnet to which the gateway should be injected. +type BackendSubnetConfiguration struct { + // The ARM ID of the subnet in which the backend systems are hosted. + ID *string +} + // BackendTLSProperties - Properties controlling TLS Certificate Validation. type BackendTLSProperties struct { // Flag indicating whether SSL certificate chain validation should be done when using self-signed certificates for this backend @@ -1408,11 +1504,15 @@ type BackendTLSProperties struct { // BackendUpdateParameterProperties - Parameters supplied to the Update Backend operation. type BackendUpdateParameterProperties struct { + // Backend Circuit Breaker Configuration + CircuitBreaker *BackendCircuitBreaker + // Backend Credentials Contract Properties Credentials *BackendCredentialsContract // Backend Description. Description *string + Pool *BackendBaseParametersPool // Backend Properties contract Properties *BackendProperties @@ -1433,6 +1533,9 @@ type BackendUpdateParameterProperties struct { // Backend Title. Title *string + // Type of the backend. A backend can be either Single or Pool. + Type *BackendType + // Runtime Url of the Backend. URL *string } @@ -1602,12 +1705,53 @@ type CertificateInformation struct { Thumbprint *string } +// CircuitBreakerFailureCondition - The trip conditions of the circuit breaker +type CircuitBreakerFailureCondition struct { + // The threshold for opening the circuit. + Count *int64 + + // The error reasons which are considered as failure. + ErrorReasons []*string + + // The interval during which the failures are counted. + Interval *string + + // The threshold for opening the circuit. + Percentage *int64 + + // The status code ranges which are considered as failure. + StatusCodeRanges []*FailureStatusCodeRange +} + +// CircuitBreakerRule - Rule configuration to trip the backend. +type CircuitBreakerRule struct { + // flag to accept Retry-After header from the backend. + AcceptRetryAfter *bool + + // The conditions for tripping the circuit breaker. + FailureCondition *CircuitBreakerFailureCondition + + // The rule name. + Name *string + + // The duration for which the circuit will be tripped. + TripDuration *string +} + // ClientSecretContract - Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. type ClientSecretContract struct { // Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. ClientSecret *string } +// ConfigurationAPI - Information regarding the Configuration API of the API Management service. +type ConfigurationAPI struct { + // Indication whether or not the legacy Configuration API (v1) should be exposed on the API Management service. Value is optional + // but must be 'Enabled' or 'Disabled'. If 'Disabled', legacy Configuration + // API (v1) will not be available for self-hosted gateways. Default value is 'Enabled' + LegacyAPI *LegacyAPIState +} + // ConnectivityCheckRequest - A request to perform the connectivity check operation on a API Management service. type ConnectivityCheckRequest struct { // REQUIRED; The connectivity check operation destination. @@ -1949,6 +2093,54 @@ type DiagnosticContractProperties struct { Verbosity *Verbosity } +// DiagnosticContractUpdateProperties - Diagnostic Entity Properties +type DiagnosticContractUpdateProperties struct { + // Specifies for what type of messages sampling settings should not apply. + AlwaysLog *AlwaysLog + + // Diagnostic settings for incoming/outgoing HTTP messages to the Backend + Backend *PipelineDiagnosticSettings + + // Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + Frontend *PipelineDiagnosticSettings + + // Sets correlation protocol to use for Application Insights diagnostics. + HTTPCorrelationProtocol *HTTPCorrelationProtocol + + // Log the ClientIP. Default is false. + LogClientIP *bool + + // Resource Id of a target logger. + LoggerID *string + + // Emit custom metrics via emit-metric policy. Applicable only to Application Insights diagnostic settings. + Metrics *bool + + // The format of the Operation Name for Application Insights telemetries. Default is Name. + OperationNameFormat *OperationNameFormat + + // Sampling settings for Diagnostic. + Sampling *SamplingSettings + + // The verbosity level applied to traces emitted by trace policies. + Verbosity *Verbosity +} + +// DiagnosticUpdateContract - Diagnostic details. +type DiagnosticUpdateContract struct { + // Diagnostic entity contract properties. + Properties *DiagnosticContractUpdateProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + // DocumentationCollection - Paged Documentation list representation. type DocumentationCollection struct { // READ-ONLY; Next page link if any. @@ -2090,6 +2282,33 @@ type EndpointDetail struct { Region *string } +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + // ErrorFieldContract - Error Field contract. type ErrorFieldContract struct { // Property level error code. @@ -2102,10 +2321,11 @@ type ErrorFieldContract struct { Target *string } -// ErrorResponse - Error Response. +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). type ErrorResponse struct { - // Properties of the Error Response. - Error *ErrorResponseBody + // The error object. + Error *ErrorDetail } // ErrorResponseBody - Error Body contract. @@ -2120,6 +2340,49 @@ type ErrorResponseBody struct { Message *string } +// FailureStatusCodeRange - The failure http status code range +type FailureStatusCodeRange struct { + // The maximum http status code. + Max *int32 + + // The minimum http status code. + Min *int32 +} + +// FrontendConfiguration - Information regarding how the gateway should be exposed. +type FrontendConfiguration struct { + // READ-ONLY; The default hostname of the data-plane gateway to which requests can be sent. This is only applicable for API + // gateway with Standard SKU. + DefaultHostname *string +} + +// GatewayBaseProperties - Base Properties of an API Management gateway resource description. +type GatewayBaseProperties struct { + // Information regarding how the gateway should integrate with backend systems. + Backend *BackendConfiguration + + // Information regarding the Configuration API of the API Management gateway. This is only applicable for API gateway with + // Standard SKU. + ConfigurationAPI *GatewayConfigurationAPI + + // Information regarding how the gateway should be exposed. + Frontend *FrontendConfiguration + + // The type of VPN in which API Management gateway needs to be configured in. + VirtualNetworkType *VirtualNetworkType + + // READ-ONLY; Creation UTC date of the API Management gateway.The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ + // as specified by the ISO 8601 standard. + CreatedAtUTC *time.Time + + // READ-ONLY; The current provisioning state of the API Management gateway which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + ProvisioningState *string + + // READ-ONLY; The provisioning state of the API Management gateway, which is targeted by the long running operation started + // on the gateway. + TargetProvisioningState *string +} + // GatewayCertificateAuthorityCollection - Paged Gateway certificate authority list representation. type GatewayCertificateAuthorityCollection struct { // READ-ONLY; Next page link if any. @@ -2162,6 +2425,54 @@ type GatewayCollection struct { Value []*GatewayContract } +type GatewayConfigConnectionBaseProperties struct { + // The hostnames of the data-plane gateway to which requests can be sent. + Hostnames []*string + + // The link to the API Management service workspace. + SourceID *string + + // READ-ONLY; The default hostname of the data-plane gateway. + DefaultHostname *string + + // READ-ONLY; The current provisioning state of the API Management gateway config connection + ProvisioningState *string +} + +// GatewayConfigConnectionListResult - The response of the List API Management gateway operation. +type GatewayConfigConnectionListResult struct { + // REQUIRED; Result of the List API Management gateway config connection operation. + Value []*GatewayConfigConnectionResource + + // Link to the next set of results. Not empty if Value contains incomplete list of API Management services. + NextLink *string +} + +// GatewayConfigConnectionResource - A single API Management gateway resource in List or Get response. +type GatewayConfigConnectionResource struct { + // REQUIRED; Properties of the API Management gateway config connection. + Properties *GatewayConfigConnectionBaseProperties + + // READ-ONLY; ETag of the resource. + Etag *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// GatewayConfigurationAPI - Information regarding the Configuration API of the API Management gateway. This is only applicable +// for API gateway with Standard SKU. +type GatewayConfigurationAPI struct { + // READ-ONLY; Hostname to which the agent connects to propagate configuration to the cloud. + Hostname *string +} + // GatewayContract - Gateway details. type GatewayContract struct { // Gateway details. @@ -2186,6 +2497,12 @@ type GatewayContractProperties struct { LocationData *ResourceLocationDataContract } +// GatewayDebugCredentialsContract - Gateway debug credentials. +type GatewayDebugCredentialsContract struct { + // Gateway debug token. + Token *string +} + // GatewayHostnameConfigurationCollection - Paged Gateway hostname configuration list representation. type GatewayHostnameConfigurationCollection struct { // READ-ONLY; Next page link if any. @@ -2246,20 +2563,217 @@ type GatewayKeysContract struct { Secondary *string } +// GatewayListDebugCredentialsContract - List debug credentials properties. +type GatewayListDebugCredentialsContract struct { + // REQUIRED; Full resource Id of an API. + APIID *string + + // REQUIRED; Purposes of debug credential. + Purposes []*GatewayListDebugCredentialsContractPurpose + + // Credentials expiration in ISO8601 format. Maximum duration of the credentials is PT1H. When property is not specified, + // them value PT1H is used. + CredentialsExpireAfter *string +} + +// GatewayListResult - The response of the List API Management gateway operation. +type GatewayListResult struct { + // REQUIRED; Result of the List API Management gateway operation. + Value []*GatewayResource + + // Link to the next set of results. Not empty if Value contains incomplete list of API Management services. + NextLink *string +} + +// GatewayListTraceContract - List trace properties. +type GatewayListTraceContract struct { + // Trace id. + TraceID *string +} + +// GatewayProperties - Properties of an API Management gateway resource description. +type GatewayProperties struct { + // Information regarding how the gateway should integrate with backend systems. + Backend *BackendConfiguration + + // Information regarding the Configuration API of the API Management gateway. This is only applicable for API gateway with + // Standard SKU. + ConfigurationAPI *GatewayConfigurationAPI + + // Information regarding how the gateway should be exposed. + Frontend *FrontendConfiguration + + // The type of VPN in which API Management gateway needs to be configured in. + VirtualNetworkType *VirtualNetworkType + + // READ-ONLY; Creation UTC date of the API Management gateway.The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ + // as specified by the ISO 8601 standard. + CreatedAtUTC *time.Time + + // READ-ONLY; The current provisioning state of the API Management gateway which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + ProvisioningState *string + + // READ-ONLY; The provisioning state of the API Management gateway, which is targeted by the long running operation started + // on the gateway. + TargetProvisioningState *string +} + +// GatewayResource - A single API Management gateway resource in List or Get response. +type GatewayResource struct { + // REQUIRED; Resource location. + Location *string + + // REQUIRED; Properties of the API Management gateway. + Properties *GatewayProperties + + // REQUIRED; SKU properties of the API Management gateway. + SKU *GatewaySKUProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; ETag of the resource. + Etag *string + + // READ-ONLY; Resource ID. + ID *string + + // READ-ONLY; Resource name. + Name *string + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData + + // READ-ONLY; Resource type for API Management resource is set to Microsoft.ApiManagement. + Type *string +} + +// GatewayResourceSKUResult - Describes an available API Management gateway SKU. +type GatewayResourceSKUResult struct { + // READ-ONLY; Specifies the number of API Management gateway units. + Capacity *GatewaySKUCapacity + + // READ-ONLY; The type of resource the SKU applies to. + ResourceType *string + + // READ-ONLY; Specifies API Management gateway SKU. + SKU *GatewaySKU +} + +// GatewayResourceSKUResults - The API Management gateway SKUs operation response. +type GatewayResourceSKUResults struct { + // REQUIRED; The list of skus available for the gateway. + Value []*GatewayResourceSKUResult + + // The uri to fetch the next page of API Management gateway Skus. + NextLink *string +} + +// GatewaySKU - Describes an available API Management SKU for gateways. +type GatewaySKU struct { + // Name of the Sku. + Name *APIGatewaySKUType +} + +// GatewaySKUCapacity - Describes scaling information of a SKU. +type GatewaySKUCapacity struct { + // READ-ONLY; The default capacity. + Default *int32 + + // READ-ONLY; The maximum capacity that can be set. + Maximum *int32 + + // READ-ONLY; The minimum capacity. + Minimum *int32 + + // READ-ONLY; The scale type applicable to the sku. + ScaleType *GatewaySKUCapacityScaleType +} + +// GatewaySKUProperties - API Management gateway resource SKU properties. +type GatewaySKUProperties struct { + // REQUIRED; Name of the Sku. + Name *APIGatewaySKUType + + // Capacity of the SKU (number of deployed units of the SKU) + Capacity *int32 +} + +// GatewaySKUPropertiesForPatch - API Management gateway resource SKU properties for PATCH operations given nothing should +// be required. +type GatewaySKUPropertiesForPatch struct { + // Capacity of the SKU (number of deployed units of the SKU) + Capacity *int32 + + // Name of the Sku. + Name *APIGatewaySKUType +} + // GatewayTokenContract - Gateway access token. type GatewayTokenContract struct { // Shared Access Authentication token value for the Gateway. Value *string } -// GatewayTokenRequestContract - Gateway token request contract properties. -type GatewayTokenRequestContract struct { - // REQUIRED; The Expiry time of the Token. Maximum token expiry time is set to 30 days. The date conforms to the following - // format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - Expiry *time.Time +// GatewayTokenRequestContract - Gateway token request contract properties. +type GatewayTokenRequestContract struct { + // REQUIRED; The Expiry time of the Token. Maximum token expiry time is set to 30 days. The date conforms to the following + // format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + Expiry *time.Time + + // REQUIRED; The Key to be used to generate gateway token. + KeyType *KeyType +} + +// GatewayUpdateParameters - Parameter supplied to Update API Management gateway. +type GatewayUpdateParameters struct { + // Properties of the API Management gateway. + Properties *GatewayUpdateProperties + + // SKU properties of the API Management gateway. + SKU *GatewaySKUPropertiesForPatch + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; ETag of the resource. + Etag *string + + // READ-ONLY; Resource ID. + ID *string + + // READ-ONLY; Resource name. + Name *string + + // READ-ONLY; Resource type for API Management resource is set to Microsoft.ApiManagement. + Type *string +} + +// GatewayUpdateProperties - Properties of an API Management gateway resource description. +type GatewayUpdateProperties struct { + // Information regarding how the gateway should integrate with backend systems. + Backend *BackendConfiguration + + // Information regarding the Configuration API of the API Management gateway. This is only applicable for API gateway with + // Standard SKU. + ConfigurationAPI *GatewayConfigurationAPI + + // Information regarding how the gateway should be exposed. + Frontend *FrontendConfiguration + + // The type of VPN in which API Management gateway needs to be configured in. + VirtualNetworkType *VirtualNetworkType + + // READ-ONLY; Creation UTC date of the API Management gateway.The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ + // as specified by the ISO 8601 standard. + CreatedAtUTC *time.Time + + // READ-ONLY; The current provisioning state of the API Management gateway which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + ProvisioningState *string - // REQUIRED; The Key to be used to generate gateway token. - KeyType *KeyType + // READ-ONLY; The provisioning state of the API Management gateway, which is targeted by the long running operation started + // on the gateway. + TargetProvisioningState *string } // GenerateSsoURLResult - Generate SSO Url operations response details. @@ -2308,6 +2822,9 @@ type GlobalSchemaContractProperties struct { // Json-encoded string for non json-based schema. Value any + + // READ-ONLY; The provisioning state + ProvisioningState *string } // GroupCollection - Paged Group list representation. @@ -2933,6 +3450,12 @@ type LoggerUpdateParameters struct { LoggerType *LoggerType } +// MigrateToStv2Contract - Describes an available API Management SKU. +type MigrateToStv2Contract struct { + // Mode of Migration to stv2. Default is PreserveIp. + Mode *MigrateToStv2Mode +} + // NamedValueCollection - Paged NamedValue list representation. type NamedValueCollection struct { // Total record count number across all pages. @@ -2978,6 +3501,9 @@ type NamedValueContractProperties struct { // will not be filled on 'GET' operations! Use '/listSecrets' POST request to get // the value. Value *string + + // READ-ONLY; The provisioning state + ProvisioningState *string } // NamedValueCreateContract - NamedValue details. @@ -3381,6 +3907,36 @@ type OperationResultLogItemContract struct { ObjectType *string } +// OperationStatusResult - The current status of an async operation. +type OperationStatusResult struct { + // REQUIRED; Operation status. + Status *string + + // The end time of the operation. + EndTime *time.Time + + // If present, details of the operation error. + Error *ErrorDetail + + // Fully qualified ID for the async operation. + ID *string + + // Name of the async operation. + Name *string + + // The operations list. + Operations []*OperationStatusResult + + // Percent of the operation that is complete. + PercentComplete *float32 + + // The start time of the operation. + StartTime *time.Time + + // READ-ONLY; Fully qualified ID of the resource against which the original async operation was started. + ResourceID *string +} + // OperationTagResourceContractProperties - Operation Entity contract Properties. type OperationTagResourceContractProperties struct { // Identifier of the operation in form /operations/{operationId}. @@ -3620,6 +4176,79 @@ type PolicyFragmentContractProperties struct { // Format of the policy fragment content. Format *PolicyFragmentContentFormat + + // READ-ONLY; The provisioning state + ProvisioningState *string +} + +// PolicyRestrictionCollection - The response of the get policy restrictions operation. +type PolicyRestrictionCollection struct { + // Next page link if any. + NextLink *string + Value []*PolicyRestrictionContract +} + +// PolicyRestrictionContract - Policy restriction contract details. +type PolicyRestrictionContract struct { + // Properties of the Policy Restriction. + Properties *PolicyRestrictionContractProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PolicyRestrictionContractProperties - Policy restrictions contract properties. +type PolicyRestrictionContractProperties struct { + // Indicates if base policy should be enforced for the policy document. + RequireBase *PolicyRestrictionRequireBase + + // Path to the policy document. + Scope *string +} + +// PolicyRestrictionUpdateContract - Policy restriction contract details. +type PolicyRestrictionUpdateContract struct { + // Properties of the Policy Restriction. + Properties *PolicyRestrictionContractProperties +} + +// PolicyWithComplianceCollection - The response of the list policy operation. +type PolicyWithComplianceCollection struct { + // Next page link if any. + NextLink *string + + // Policy Contract value. + Value []*PolicyWithComplianceContract +} + +// PolicyWithComplianceContract - Policy Contract details. +type PolicyWithComplianceContract struct { + // Properties of the Policy. + Properties *PolicyWithComplianceContractProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PolicyWithComplianceContractProperties - Policy contract Properties. +type PolicyWithComplianceContractProperties struct { + // Policy Restriction Compliance State + ComplianceState *PolicyComplianceState + + // Policy Identifier + ReferencePolicyID *string } // PortalConfigCollection - The collection of the developer portal configurations. @@ -3778,6 +4407,9 @@ type PortalRevisionContractProperties struct { // READ-ONLY; Portal's revision creation date and time. CreatedDateTime *time.Time + // READ-ONLY; The provisioning state + ProvisioningState *string + // READ-ONLY; Status of the portal's revision. Status *PortalRevisionStatus @@ -3999,6 +4631,39 @@ type PrivateLinkServiceConnectionState struct { Status *PrivateEndpointServiceConnectionStatus } +// ProductAPILinkCollection - Paged Product-API link list representation. +type ProductAPILinkCollection struct { + // Total record count number across all pages. + Count *int64 + + // Next page link if any. + NextLink *string + + // Page values. + Value []*ProductAPILinkContract +} + +// ProductAPILinkContract - Product-API link details. +type ProductAPILinkContract struct { + // Product-API link entity contract properties. + Properties *ProductAPILinkContractProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ProductAPILinkContractProperties - Product-API link entity properties. +type ProductAPILinkContractProperties struct { + // REQUIRED; Full resource Id of an API. + APIID *string +} + // ProductCollection - Paged Products list representation. type ProductCollection struct { // Total record count number across all pages. @@ -4095,6 +4760,39 @@ type ProductEntityBaseParameters struct { Terms *string } +// ProductGroupLinkCollection - Paged Product-group link list representation. +type ProductGroupLinkCollection struct { + // Total record count number across all pages. + Count *int64 + + // Next page link if any. + NextLink *string + + // Page values. + Value []*ProductGroupLinkContract +} + +// ProductGroupLinkContract - Product-group link details. +type ProductGroupLinkContract struct { + // Product-group link entity contract properties. + Properties *ProductGroupLinkContractProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ProductGroupLinkContractProperties - Product-group link entity properties. +type ProductGroupLinkContractProperties struct { + // REQUIRED; Full resource Id of a group. + GroupID *string +} + // ProductTagResourceContractProperties - Product profile. type ProductTagResourceContractProperties struct { // REQUIRED; Product name. @@ -4974,11 +5672,16 @@ type SchemaContractProperties struct { // - Swagger Schema use application/vnd.ms-azure-apim.swagger.definitions+json // - WSDL Schema use application/vnd.ms-azure-apim.xsd+xml // - OpenApi Schema use application/vnd.oai.openapi.components+json - // - WADL Schema use application/vnd.ms-azure-apim.wadl.grammars+xml. + // - WADL Schema use application/vnd.ms-azure-apim.wadl.grammars+xml + // - OData Schema use application/vnd.ms-azure-apim.odata.schema + // - gRPC Schema use text/protobuf. ContentType *string // REQUIRED; Create or update Properties of the API Schema Document. Document *SchemaDocumentProperties + + // READ-ONLY; The provisioning state + ProvisioningState *string } // SchemaDocumentProperties - Api Schema Document Properties. @@ -5033,6 +5736,9 @@ type ServiceBaseProperties struct { // is 10. Certificates []*CertificateConfiguration + // Configuration API configuration of the API Management service. + ConfigurationAPI *ConfigurationAPI + // Custom properties of the API Management service. // Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168 will disable the cipher TLSRSAWITH3DESEDECBCSHA // for all TLS(1.0, 1.1 and 1.2). @@ -5058,6 +5764,9 @@ type ServiceBaseProperties struct { // SHA256,TLSECDHERSAWITHAES256GCMSHA384,TLSECDHERSAWITHAES128GCMSHA256,TLSECDHEECDSAWITHAES256CBCSHA384,TLSECDHEECDSAWITHAES128CBCSHA256,TLSECDHERSAWITHAES256CBCSHA384,TLSECDHERSAWITHAES128CBCSHA256 CustomProperties map[string]*string + // Status of developer portal in this API Management service. + DeveloperPortalStatus *DeveloperPortalStatus + // Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway // in master region. DisableGateway *bool @@ -5070,6 +5779,9 @@ type ServiceBaseProperties struct { // Custom hostname configuration of the API Management service. HostnameConfigurations []*HostnameConfiguration + // Status of legacy portal in the API Management service. + LegacyPortalStatus *LegacyPortalStatus + // Property can be used to enable NAT Gateway for this API Management service. NatGatewayState *NatGatewayState @@ -5228,6 +5940,9 @@ type ServiceProperties struct { // is 10. Certificates []*CertificateConfiguration + // Configuration API configuration of the API Management service. + ConfigurationAPI *ConfigurationAPI + // Custom properties of the API Management service. // Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168 will disable the cipher TLSRSAWITH3DESEDECBCSHA // for all TLS(1.0, 1.1 and 1.2). @@ -5253,6 +5968,9 @@ type ServiceProperties struct { // SHA256,TLSECDHERSAWITHAES256GCMSHA384,TLSECDHERSAWITHAES128GCMSHA256,TLSECDHEECDSAWITHAES256CBCSHA384,TLSECDHEECDSAWITHAES128CBCSHA256,TLSECDHERSAWITHAES256CBCSHA384,TLSECDHERSAWITHAES128CBCSHA256 CustomProperties map[string]*string + // Status of developer portal in this API Management service. + DeveloperPortalStatus *DeveloperPortalStatus + // Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway // in master region. DisableGateway *bool @@ -5265,6 +5983,9 @@ type ServiceProperties struct { // Custom hostname configuration of the API Management service. HostnameConfigurations []*HostnameConfiguration + // Status of legacy portal in the API Management service. + LegacyPortalStatus *LegacyPortalStatus + // Property can be used to enable NAT Gateway for this API Management service. NatGatewayState *NatGatewayState @@ -5431,6 +6152,9 @@ type ServiceUpdateProperties struct { // is 10. Certificates []*CertificateConfiguration + // Configuration API configuration of the API Management service. + ConfigurationAPI *ConfigurationAPI + // Custom properties of the API Management service. // Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168 will disable the cipher TLSRSAWITH3DESEDECBCSHA // for all TLS(1.0, 1.1 and 1.2). @@ -5456,6 +6180,9 @@ type ServiceUpdateProperties struct { // SHA256,TLSECDHERSAWITHAES256GCMSHA384,TLSECDHERSAWITHAES128GCMSHA256,TLSECDHEECDSAWITHAES256CBCSHA384,TLSECDHEECDSAWITHAES128CBCSHA256,TLSECDHERSAWITHAES256CBCSHA384,TLSECDHERSAWITHAES128CBCSHA256 CustomProperties map[string]*string + // Status of developer portal in this API Management service. + DeveloperPortalStatus *DeveloperPortalStatus + // Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway // in master region. DisableGateway *bool @@ -5468,6 +6195,9 @@ type ServiceUpdateProperties struct { // Custom hostname configuration of the API Management service. HostnameConfigurations []*HostnameConfiguration + // Status of legacy portal in the API Management service. + LegacyPortalStatus *LegacyPortalStatus + // Property can be used to enable NAT Gateway for this API Management service. NatGatewayState *NatGatewayState @@ -5761,6 +6491,39 @@ type SystemData struct { LastModifiedByType *CreatedByType } +// TagAPILinkCollection - Paged Tag-API link list representation. +type TagAPILinkCollection struct { + // Total record count number across all pages. + Count *int64 + + // Next page link if any. + NextLink *string + + // Page values. + Value []*TagAPILinkContract +} + +// TagAPILinkContract - Tag-API link details. +type TagAPILinkContract struct { + // Tag-API link entity contract properties. + Properties *TagAPILinkContractProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// TagAPILinkContractProperties - Tag-API link entity properties. +type TagAPILinkContractProperties struct { + // REQUIRED; Full resource Id of an API. + APIID *string +} + // TagCollection - Paged Tag list representation. type TagCollection struct { // Total record count number across all pages. @@ -5863,6 +6626,72 @@ type TagDescriptionCreateParameters struct { Properties *TagDescriptionBaseProperties } +// TagOperationLinkCollection - Paged Tag-operation link list representation. +type TagOperationLinkCollection struct { + // Total record count number across all pages. + Count *int64 + + // Next page link if any. + NextLink *string + + // Page values. + Value []*TagOperationLinkContract +} + +// TagOperationLinkContract - Tag-operation link details. +type TagOperationLinkContract struct { + // Tag-API link entity contract properties. + Properties *TagOperationLinkContractProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// TagOperationLinkContractProperties - Tag-operation link entity properties. +type TagOperationLinkContractProperties struct { + // REQUIRED; Full resource Id of an API operation. + OperationID *string +} + +// TagProductLinkCollection - Paged Tag-product link list representation. +type TagProductLinkCollection struct { + // Total record count number across all pages. + Count *int64 + + // Next page link if any. + NextLink *string + + // Page values. + Value []*TagProductLinkContract +} + +// TagProductLinkContract - Tag-product link details. +type TagProductLinkContract struct { + // Tag-API link entity contract properties. + Properties *TagProductLinkContractProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// TagProductLinkContractProperties - Tag-product link entity properties. +type TagProductLinkContractProperties struct { + // REQUIRED; Full resource Id of a product. + ProductID *string +} + // TagResourceCollection - Paged Tag list representation. type TagResourceCollection struct { // Total record count number across all pages. @@ -6236,6 +7065,91 @@ type WikiUpdateContract struct { Properties *WikiContractProperties } +// WorkspaceCollection - Paged workspace list representation. +type WorkspaceCollection struct { + // Total record count number across all pages. + Count *int64 + + // Next page link if any. + NextLink *string + + // Page values. + Value []*WorkspaceContract +} + +// WorkspaceContract - Workspace details. +type WorkspaceContract struct { + // Workspace entity contract properties. + Properties *WorkspaceContractProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// WorkspaceContractProperties - Workspace entity properties. +type WorkspaceContractProperties struct { + // REQUIRED; Name of the workspace. + DisplayName *string + + // Description of the workspace. + Description *string +} + +type WorkspaceLinksBaseProperties struct { + // The array of linked gateways. + Gateways []*WorkspaceLinksGateway + + // The link to the API Management service workspace. + WorkspaceID *string +} + +type WorkspaceLinksGateway struct { + // The link to the API Management gateway. + ID *string +} + +// WorkspaceLinksListResult - The response of the List API Management WorkspaceLink operation. +type WorkspaceLinksListResult struct { + // REQUIRED; Result of the List API Management WorkspaceLinks operation. + Value []*WorkspaceLinksResource + + // Link to the next set of results. Not empty if Value contains incomplete list of API Management services. + NextLink *string +} + +// WorkspaceLinksProperties - Properties of an API Management workspaceLinks resource. +type WorkspaceLinksProperties struct { + // The array of linked gateways. + Gateways []*WorkspaceLinksGateway + + // The link to the API Management service workspace. + WorkspaceID *string +} + +// WorkspaceLinksResource - A single API Management WorkspaceLinks in List or Get response. +type WorkspaceLinksResource struct { + // REQUIRED; Properties of the API Management WorkspaceLinks. + Properties *WorkspaceLinksProperties + + // READ-ONLY; ETag of the resource. + Etag *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + // X509CertificateName - Properties of server X509Names. type X509CertificateName struct { // Thumbprint for the Issuer of the Certificate. diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/models_serde.go b/sdk/resourcemanager/apimanagement/armapimanagement/models_serde.go index b14f63101074..0ad661e35d9f 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/models_serde.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/models_serde.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -143,6 +140,7 @@ func (a APIContractProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "license", a.License) populate(objectMap, "path", a.Path) populate(objectMap, "protocols", a.Protocols) + populate(objectMap, "provisioningState", a.ProvisioningState) populate(objectMap, "serviceUrl", a.ServiceURL) populate(objectMap, "sourceApiId", a.SourceAPIID) populate(objectMap, "subscriptionKeyParameterNames", a.SubscriptionKeyParameterNames) @@ -208,6 +206,9 @@ func (a *APIContractProperties) UnmarshalJSON(data []byte) error { case "protocols": err = unpopulate(val, "Protocols", &a.Protocols) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) case "serviceUrl": err = unpopulate(val, "ServiceURL", &a.ServiceURL) delete(rawMsg, key) @@ -377,6 +378,7 @@ func (a APICreateOrUpdateProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "license", a.License) populate(objectMap, "path", a.Path) populate(objectMap, "protocols", a.Protocols) + populate(objectMap, "provisioningState", a.ProvisioningState) populate(objectMap, "serviceUrl", a.ServiceURL) populate(objectMap, "apiType", a.SoapAPIType) populate(objectMap, "sourceApiId", a.SourceAPIID) @@ -449,6 +451,9 @@ func (a *APICreateOrUpdateProperties) UnmarshalJSON(data []byte) error { case "protocols": err = unpopulate(val, "Protocols", &a.Protocols) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) case "serviceUrl": err = unpopulate(val, "ServiceURL", &a.ServiceURL) delete(rawMsg, key) @@ -1702,6 +1707,107 @@ func (a *AdditionalLocation) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AllPoliciesCollection. +func (a AllPoliciesCollection) 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 AllPoliciesCollection. +func (a *AllPoliciesCollection) 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 AllPoliciesContract. +func (a AllPoliciesContract) 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, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AllPoliciesContract. +func (a *AllPoliciesContract) 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 "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 AllPoliciesContractProperties. +func (a AllPoliciesContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "complianceState", a.ComplianceState) + populate(objectMap, "referencePolicyId", a.ReferencePolicyID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AllPoliciesContractProperties. +func (a *AllPoliciesContractProperties) 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 "complianceState": + err = unpopulate(val, "ComplianceState", &a.ComplianceState) + delete(rawMsg, key) + case "referencePolicyId": + err = unpopulate(val, "ReferencePolicyID", &a.ReferencePolicyID) + 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 ApimResource. func (a ApimResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1950,6 +2056,7 @@ func (a *AuthorizationAccessPolicyContract) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AuthorizationAccessPolicyContractProperties. func (a AuthorizationAccessPolicyContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "appIds", a.AppIDs) populate(objectMap, "objectId", a.ObjectID) populate(objectMap, "tenantId", a.TenantID) return json.Marshal(objectMap) @@ -1964,6 +2071,9 @@ func (a *AuthorizationAccessPolicyContractProperties) UnmarshalJSON(data []byte) for key, val := range rawMsg { var err error switch key { + case "appIds": + err = unpopulate(val, "AppIDs", &a.AppIDs) + delete(rawMsg, key) case "objectId": err = unpopulate(val, "ObjectID", &a.ObjectID) delete(rawMsg, key) @@ -2809,13 +2919,16 @@ func (b *BackendAuthorizationHeaderCredentials) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type BackendBaseParameters. func (b BackendBaseParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "circuitBreaker", b.CircuitBreaker) populate(objectMap, "credentials", b.Credentials) populate(objectMap, "description", b.Description) + populate(objectMap, "pool", b.Pool) populate(objectMap, "properties", b.Properties) populate(objectMap, "proxy", b.Proxy) populate(objectMap, "resourceId", b.ResourceID) populate(objectMap, "tls", b.TLS) populate(objectMap, "title", b.Title) + populate(objectMap, "type", b.Type) return json.Marshal(objectMap) } @@ -2828,12 +2941,18 @@ func (b *BackendBaseParameters) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "circuitBreaker": + err = unpopulate(val, "CircuitBreaker", &b.CircuitBreaker) + delete(rawMsg, key) case "credentials": err = unpopulate(val, "Credentials", &b.Credentials) delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &b.Description) delete(rawMsg, key) + case "pool": + err = unpopulate(val, "Pool", &b.Pool) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &b.Properties) delete(rawMsg, key) @@ -2849,6 +2968,63 @@ func (b *BackendBaseParameters) UnmarshalJSON(data []byte) error { case "title": err = unpopulate(val, "Title", &b.Title) delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackendBaseParametersPool. +func (b BackendBaseParametersPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "services", b.Services) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendBaseParametersPool. +func (b *BackendBaseParametersPool) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "services": + err = unpopulate(val, "Services", &b.Services) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackendCircuitBreaker. +func (b BackendCircuitBreaker) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "rules", b.Rules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendCircuitBreaker. +func (b *BackendCircuitBreaker) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "rules": + err = unpopulate(val, "Rules", &b.Rules) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) @@ -2892,6 +3068,33 @@ func (b *BackendCollection) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type BackendConfiguration. +func (b BackendConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "subnet", b.Subnet) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendConfiguration. +func (b *BackendConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "subnet": + err = unpopulate(val, "Subnet", &b.Subnet) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type BackendContract. func (b BackendContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2934,14 +3137,17 @@ func (b *BackendContract) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type BackendContractProperties. func (b BackendContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "circuitBreaker", b.CircuitBreaker) populate(objectMap, "credentials", b.Credentials) populate(objectMap, "description", b.Description) + populate(objectMap, "pool", b.Pool) populate(objectMap, "properties", b.Properties) populate(objectMap, "protocol", b.Protocol) populate(objectMap, "proxy", b.Proxy) populate(objectMap, "resourceId", b.ResourceID) populate(objectMap, "tls", b.TLS) populate(objectMap, "title", b.Title) + populate(objectMap, "type", b.Type) populate(objectMap, "url", b.URL) return json.Marshal(objectMap) } @@ -2955,12 +3161,18 @@ func (b *BackendContractProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "circuitBreaker": + err = unpopulate(val, "CircuitBreaker", &b.CircuitBreaker) + delete(rawMsg, key) case "credentials": err = unpopulate(val, "Credentials", &b.Credentials) delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &b.Description) delete(rawMsg, key) + case "pool": + err = unpopulate(val, "Pool", &b.Pool) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &b.Properties) delete(rawMsg, key) @@ -2979,6 +3191,9 @@ func (b *BackendContractProperties) UnmarshalJSON(data []byte) error { case "title": err = unpopulate(val, "Title", &b.Title) delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) case "url": err = unpopulate(val, "URL", &b.URL) delete(rawMsg, key) @@ -3033,6 +3248,68 @@ func (b *BackendCredentialsContract) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type BackendPool. +func (b BackendPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "services", b.Services) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendPool. +func (b *BackendPool) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "services": + err = unpopulate(val, "Services", &b.Services) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackendPoolItem. +func (b BackendPoolItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", b.ID) + populate(objectMap, "priority", b.Priority) + populate(objectMap, "weight", b.Weight) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendPoolItem. +func (b *BackendPoolItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &b.Priority) + delete(rawMsg, key) + case "weight": + err = unpopulate(val, "Weight", &b.Weight) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type BackendProperties. func (b BackendProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3208,6 +3485,33 @@ func (b *BackendServiceFabricClusterProperties) UnmarshalJSON(data []byte) error return nil } +// MarshalJSON implements the json.Marshaller interface for type BackendSubnetConfiguration. +func (b BackendSubnetConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", b.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendSubnetConfiguration. +func (b *BackendSubnetConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type BackendTLSProperties. func (b BackendTLSProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3242,14 +3546,17 @@ func (b *BackendTLSProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type BackendUpdateParameterProperties. func (b BackendUpdateParameterProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "circuitBreaker", b.CircuitBreaker) populate(objectMap, "credentials", b.Credentials) populate(objectMap, "description", b.Description) + populate(objectMap, "pool", b.Pool) populate(objectMap, "properties", b.Properties) populate(objectMap, "protocol", b.Protocol) populate(objectMap, "proxy", b.Proxy) populate(objectMap, "resourceId", b.ResourceID) populate(objectMap, "tls", b.TLS) populate(objectMap, "title", b.Title) + populate(objectMap, "type", b.Type) populate(objectMap, "url", b.URL) return json.Marshal(objectMap) } @@ -3263,12 +3570,18 @@ func (b *BackendUpdateParameterProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "circuitBreaker": + err = unpopulate(val, "CircuitBreaker", &b.CircuitBreaker) + delete(rawMsg, key) case "credentials": err = unpopulate(val, "Credentials", &b.Credentials) delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &b.Description) delete(rawMsg, key) + case "pool": + err = unpopulate(val, "Pool", &b.Pool) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &b.Properties) delete(rawMsg, key) @@ -3287,6 +3600,9 @@ func (b *BackendUpdateParameterProperties) UnmarshalJSON(data []byte) error { case "title": err = unpopulate(val, "Title", &b.Title) delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) case "url": err = unpopulate(val, "URL", &b.URL) delete(rawMsg, key) @@ -3780,15 +4096,19 @@ func (c *CertificateInformation) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ClientSecretContract. -func (c ClientSecretContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CircuitBreakerFailureCondition. +func (c CircuitBreakerFailureCondition) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "clientSecret", c.ClientSecret) + populate(objectMap, "count", c.Count) + populate(objectMap, "errorReasons", c.ErrorReasons) + populate(objectMap, "interval", c.Interval) + populate(objectMap, "percentage", c.Percentage) + populate(objectMap, "statusCodeRanges", c.StatusCodeRanges) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ClientSecretContract. -func (c *ClientSecretContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CircuitBreakerFailureCondition. +func (c *CircuitBreakerFailureCondition) 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) @@ -3796,8 +4116,20 @@ func (c *ClientSecretContract) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "clientSecret": - err = unpopulate(val, "ClientSecret", &c.ClientSecret) + case "count": + err = unpopulate(val, "Count", &c.Count) + delete(rawMsg, key) + case "errorReasons": + err = unpopulate(val, "ErrorReasons", &c.ErrorReasons) + delete(rawMsg, key) + case "interval": + err = unpopulate(val, "Interval", &c.Interval) + delete(rawMsg, key) + case "percentage": + err = unpopulate(val, "Percentage", &c.Percentage) + delete(rawMsg, key) + case "statusCodeRanges": + err = unpopulate(val, "StatusCodeRanges", &c.StatusCodeRanges) delete(rawMsg, key) } if err != nil { @@ -3807,10 +4139,103 @@ func (c *ClientSecretContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ConnectivityCheckRequest. -func (c ConnectivityCheckRequest) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CircuitBreakerRule. +func (c CircuitBreakerRule) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "destination", c.Destination) + populate(objectMap, "acceptRetryAfter", c.AcceptRetryAfter) + populate(objectMap, "failureCondition", c.FailureCondition) + populate(objectMap, "name", c.Name) + populate(objectMap, "tripDuration", c.TripDuration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CircuitBreakerRule. +func (c *CircuitBreakerRule) 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 "acceptRetryAfter": + err = unpopulate(val, "AcceptRetryAfter", &c.AcceptRetryAfter) + delete(rawMsg, key) + case "failureCondition": + err = unpopulate(val, "FailureCondition", &c.FailureCondition) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "tripDuration": + err = unpopulate(val, "TripDuration", &c.TripDuration) + 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 ClientSecretContract. +func (c ClientSecretContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientSecret", c.ClientSecret) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClientSecretContract. +func (c *ClientSecretContract) 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 "clientSecret": + err = unpopulate(val, "ClientSecret", &c.ClientSecret) + 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 ConfigurationAPI. +func (c ConfigurationAPI) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "legacyApi", c.LegacyAPI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationAPI. +func (c *ConfigurationAPI) 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 "legacyApi": + err = unpopulate(val, "LegacyAPI", &c.LegacyAPI) + 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 ConnectivityCheckRequest. +func (c ConnectivityCheckRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "destination", c.Destination) populate(objectMap, "preferredIPVersion", c.PreferredIPVersion) populate(objectMap, "protocol", c.Protocol) populate(objectMap, "protocolConfiguration", c.ProtocolConfiguration) @@ -4711,6 +5136,108 @@ func (d *DiagnosticContractProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DiagnosticContractUpdateProperties. +func (d DiagnosticContractUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "alwaysLog", d.AlwaysLog) + populate(objectMap, "backend", d.Backend) + populate(objectMap, "frontend", d.Frontend) + populate(objectMap, "httpCorrelationProtocol", d.HTTPCorrelationProtocol) + populate(objectMap, "logClientIp", d.LogClientIP) + populate(objectMap, "loggerId", d.LoggerID) + populate(objectMap, "metrics", d.Metrics) + populate(objectMap, "operationNameFormat", d.OperationNameFormat) + populate(objectMap, "sampling", d.Sampling) + populate(objectMap, "verbosity", d.Verbosity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiagnosticContractUpdateProperties. +func (d *DiagnosticContractUpdateProperties) 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 "alwaysLog": + err = unpopulate(val, "AlwaysLog", &d.AlwaysLog) + delete(rawMsg, key) + case "backend": + err = unpopulate(val, "Backend", &d.Backend) + delete(rawMsg, key) + case "frontend": + err = unpopulate(val, "Frontend", &d.Frontend) + delete(rawMsg, key) + case "httpCorrelationProtocol": + err = unpopulate(val, "HTTPCorrelationProtocol", &d.HTTPCorrelationProtocol) + delete(rawMsg, key) + case "logClientIp": + err = unpopulate(val, "LogClientIP", &d.LogClientIP) + delete(rawMsg, key) + case "loggerId": + err = unpopulate(val, "LoggerID", &d.LoggerID) + delete(rawMsg, key) + case "metrics": + err = unpopulate(val, "Metrics", &d.Metrics) + delete(rawMsg, key) + case "operationNameFormat": + err = unpopulate(val, "OperationNameFormat", &d.OperationNameFormat) + delete(rawMsg, key) + case "sampling": + err = unpopulate(val, "Sampling", &d.Sampling) + delete(rawMsg, key) + case "verbosity": + err = unpopulate(val, "Verbosity", &d.Verbosity) + 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 DiagnosticUpdateContract. +func (d DiagnosticUpdateContract) 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, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiagnosticUpdateContract. +func (d *DiagnosticUpdateContract) 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 "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 DocumentationCollection. func (d DocumentationCollection) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -5127,6 +5654,80 @@ func (e *EndpointDetail) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorFieldContract. func (e ErrorFieldContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -5224,61 +5825,170 @@ func (e *ErrorResponseBody) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GatewayCertificateAuthorityCollection. -func (g GatewayCertificateAuthorityCollection) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type FailureStatusCodeRange. +func (f FailureStatusCodeRange) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", g.NextLink) - populate(objectMap, "value", g.Value) + populate(objectMap, "max", f.Max) + populate(objectMap, "min", f.Min) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayCertificateAuthorityCollection. -func (g *GatewayCertificateAuthorityCollection) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type FailureStatusCodeRange. +func (f *FailureStatusCodeRange) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", g, err) + return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &g.NextLink) + case "max": + err = unpopulate(val, "Max", &f.Max) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &g.Value) + case "min": + err = unpopulate(val, "Min", &f.Min) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", g, err) + return fmt.Errorf("unmarshalling type %T: %v", f, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type GatewayCertificateAuthorityContract. -func (g GatewayCertificateAuthorityContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type FrontendConfiguration. +func (f FrontendConfiguration) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", g.ID) - populate(objectMap, "name", g.Name) - populate(objectMap, "properties", g.Properties) - populate(objectMap, "type", g.Type) + populate(objectMap, "defaultHostname", f.DefaultHostname) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayCertificateAuthorityContract. -func (g *GatewayCertificateAuthorityContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type FrontendConfiguration. +func (f *FrontendConfiguration) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", g, err) + return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &g.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &g.Name) + case "defaultHostname": + err = unpopulate(val, "DefaultHostname", &f.DefaultHostname) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayBaseProperties. +func (g GatewayBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backend", g.Backend) + populate(objectMap, "configurationApi", g.ConfigurationAPI) + populateDateTimeRFC3339(objectMap, "createdAtUtc", g.CreatedAtUTC) + populate(objectMap, "frontend", g.Frontend) + populate(objectMap, "provisioningState", g.ProvisioningState) + populate(objectMap, "targetProvisioningState", g.TargetProvisioningState) + populate(objectMap, "virtualNetworkType", g.VirtualNetworkType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayBaseProperties. +func (g *GatewayBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backend": + err = unpopulate(val, "Backend", &g.Backend) + delete(rawMsg, key) + case "configurationApi": + err = unpopulate(val, "ConfigurationAPI", &g.ConfigurationAPI) + delete(rawMsg, key) + case "createdAtUtc": + err = unpopulateDateTimeRFC3339(val, "CreatedAtUTC", &g.CreatedAtUTC) + delete(rawMsg, key) + case "frontend": + err = unpopulate(val, "Frontend", &g.Frontend) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + case "targetProvisioningState": + err = unpopulate(val, "TargetProvisioningState", &g.TargetProvisioningState) + delete(rawMsg, key) + case "virtualNetworkType": + err = unpopulate(val, "VirtualNetworkType", &g.VirtualNetworkType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayCertificateAuthorityCollection. +func (g GatewayCertificateAuthorityCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayCertificateAuthorityCollection. +func (g *GatewayCertificateAuthorityCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayCertificateAuthorityContract. +func (g GatewayCertificateAuthorityContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayCertificateAuthorityContract. +func (g *GatewayCertificateAuthorityContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &g.Properties) @@ -5356,6 +6066,146 @@ func (g *GatewayCollection) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type GatewayConfigConnectionBaseProperties. +func (g GatewayConfigConnectionBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "defaultHostname", g.DefaultHostname) + populate(objectMap, "hostnames", g.Hostnames) + populate(objectMap, "provisioningState", g.ProvisioningState) + populate(objectMap, "sourceId", g.SourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayConfigConnectionBaseProperties. +func (g *GatewayConfigConnectionBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "defaultHostname": + err = unpopulate(val, "DefaultHostname", &g.DefaultHostname) + delete(rawMsg, key) + case "hostnames": + err = unpopulate(val, "Hostnames", &g.Hostnames) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + case "sourceId": + err = unpopulate(val, "SourceID", &g.SourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayConfigConnectionListResult. +func (g GatewayConfigConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayConfigConnectionListResult. +func (g *GatewayConfigConnectionListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayConfigConnectionResource. +func (g GatewayConfigConnectionResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", g.Etag) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayConfigConnectionResource. +func (g *GatewayConfigConnectionResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &g.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayConfigurationAPI. +func (g GatewayConfigurationAPI) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hostname", g.Hostname) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayConfigurationAPI. +func (g *GatewayConfigurationAPI) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hostname": + err = unpopulate(val, "Hostname", &g.Hostname) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type GatewayContract. func (g GatewayContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -5426,6 +6276,33 @@ func (g *GatewayContractProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type GatewayDebugCredentialsContract. +func (g GatewayDebugCredentialsContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "token", g.Token) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayDebugCredentialsContract. +func (g *GatewayDebugCredentialsContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "token": + err = unpopulate(val, "Token", &g.Token) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type GatewayHostnameConfigurationCollection. func (g GatewayHostnameConfigurationCollection) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -5601,15 +6478,17 @@ func (g *GatewayKeysContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GatewayTokenContract. -func (g GatewayTokenContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayListDebugCredentialsContract. +func (g GatewayListDebugCredentialsContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "value", g.Value) + populate(objectMap, "apiId", g.APIID) + populate(objectMap, "credentialsExpireAfter", g.CredentialsExpireAfter) + populate(objectMap, "purposes", g.Purposes) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayTokenContract. -func (g *GatewayTokenContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayListDebugCredentialsContract. +func (g *GatewayListDebugCredentialsContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5617,8 +6496,14 @@ func (g *GatewayTokenContract) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "value": - err = unpopulate(val, "Value", &g.Value) + case "apiId": + err = unpopulate(val, "APIID", &g.APIID) + delete(rawMsg, key) + case "credentialsExpireAfter": + err = unpopulate(val, "CredentialsExpireAfter", &g.CredentialsExpireAfter) + delete(rawMsg, key) + case "purposes": + err = unpopulate(val, "Purposes", &g.Purposes) delete(rawMsg, key) } if err != nil { @@ -5628,16 +6513,16 @@ func (g *GatewayTokenContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GatewayTokenRequestContract. -func (g GatewayTokenRequestContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayListResult. +func (g GatewayListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateDateTimeRFC3339(objectMap, "expiry", g.Expiry) - populate(objectMap, "keyType", g.KeyType) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayTokenRequestContract. -func (g *GatewayTokenRequestContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayListResult. +func (g *GatewayListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5645,11 +6530,11 @@ func (g *GatewayTokenRequestContract) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "expiry": - err = unpopulateDateTimeRFC3339(val, "Expiry", &g.Expiry) + case "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) delete(rawMsg, key) - case "keyType": - err = unpopulate(val, "KeyType", &g.KeyType) + case "value": + err = unpopulate(val, "Value", &g.Value) delete(rawMsg, key) } if err != nil { @@ -5659,15 +6544,15 @@ func (g *GatewayTokenRequestContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GenerateSsoURLResult. -func (g GenerateSsoURLResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayListTraceContract. +func (g GatewayListTraceContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "value", g.Value) + populate(objectMap, "traceId", g.TraceID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateSsoURLResult. -func (g *GenerateSsoURLResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayListTraceContract. +func (g *GatewayListTraceContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5675,8 +6560,8 @@ func (g *GenerateSsoURLResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "value": - err = unpopulate(val, "Value", &g.Value) + case "traceId": + err = unpopulate(val, "TraceID", &g.TraceID) delete(rawMsg, key) } if err != nil { @@ -5686,17 +6571,21 @@ func (g *GenerateSsoURLResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GlobalSchemaCollection. -func (g GlobalSchemaCollection) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayProperties. +func (g GatewayProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "count", g.Count) - populate(objectMap, "nextLink", g.NextLink) - populate(objectMap, "value", g.Value) + populate(objectMap, "backend", g.Backend) + populate(objectMap, "configurationApi", g.ConfigurationAPI) + populateDateTimeRFC3339(objectMap, "createdAtUtc", g.CreatedAtUTC) + populate(objectMap, "frontend", g.Frontend) + populate(objectMap, "provisioningState", g.ProvisioningState) + populate(objectMap, "targetProvisioningState", g.TargetProvisioningState) + populate(objectMap, "virtualNetworkType", g.VirtualNetworkType) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GlobalSchemaCollection. -func (g *GlobalSchemaCollection) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayProperties. +func (g *GatewayProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5704,14 +6593,26 @@ func (g *GlobalSchemaCollection) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "count": - err = unpopulate(val, "Count", &g.Count) + case "backend": + err = unpopulate(val, "Backend", &g.Backend) delete(rawMsg, key) - case "nextLink": - err = unpopulate(val, "NextLink", &g.NextLink) + case "configurationApi": + err = unpopulate(val, "ConfigurationAPI", &g.ConfigurationAPI) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &g.Value) + case "createdAtUtc": + err = unpopulateDateTimeRFC3339(val, "CreatedAtUTC", &g.CreatedAtUTC) + delete(rawMsg, key) + case "frontend": + err = unpopulate(val, "Frontend", &g.Frontend) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + case "targetProvisioningState": + err = unpopulate(val, "TargetProvisioningState", &g.TargetProvisioningState) + delete(rawMsg, key) + case "virtualNetworkType": + err = unpopulate(val, "VirtualNetworkType", &g.VirtualNetworkType) delete(rawMsg, key) } if err != nil { @@ -5721,18 +6622,23 @@ func (g *GlobalSchemaCollection) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GlobalSchemaContract. -func (g GlobalSchemaContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayResource. +func (g GatewayResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "etag", g.Etag) populate(objectMap, "id", g.ID) + populate(objectMap, "location", g.Location) populate(objectMap, "name", g.Name) populate(objectMap, "properties", g.Properties) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "systemData", g.SystemData) + populate(objectMap, "tags", g.Tags) populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GlobalSchemaContract. -func (g *GlobalSchemaContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayResource. +func (g *GatewayResource) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5740,15 +6646,30 @@ func (g *GlobalSchemaContract) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "etag": + err = unpopulate(val, "Etag", &g.Etag) + delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &g.ID) delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &g.Location) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &g.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &g.Properties) delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &g.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &g.Tags) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &g.Type) delete(rawMsg, key) @@ -5760,18 +6681,17 @@ func (g *GlobalSchemaContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GlobalSchemaContractProperties. -func (g GlobalSchemaContractProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayResourceSKUResult. +func (g GatewayResourceSKUResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", g.Description) - populateAny(objectMap, "document", g.Document) - populate(objectMap, "schemaType", g.SchemaType) - populateAny(objectMap, "value", g.Value) + populate(objectMap, "capacity", g.Capacity) + populate(objectMap, "resourceType", g.ResourceType) + populate(objectMap, "sku", g.SKU) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GlobalSchemaContractProperties. -func (g *GlobalSchemaContractProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayResourceSKUResult. +func (g *GatewayResourceSKUResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5779,17 +6699,14 @@ func (g *GlobalSchemaContractProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &g.Description) - delete(rawMsg, key) - case "document": - err = unpopulate(val, "Document", &g.Document) + case "capacity": + err = unpopulate(val, "Capacity", &g.Capacity) delete(rawMsg, key) - case "schemaType": - err = unpopulate(val, "SchemaType", &g.SchemaType) + case "resourceType": + err = unpopulate(val, "ResourceType", &g.ResourceType) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &g.Value) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) delete(rawMsg, key) } if err != nil { @@ -5799,17 +6716,16 @@ func (g *GlobalSchemaContractProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GroupCollection. -func (g GroupCollection) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayResourceSKUResults. +func (g GatewayResourceSKUResults) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "count", g.Count) populate(objectMap, "nextLink", g.NextLink) populate(objectMap, "value", g.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GroupCollection. -func (g *GroupCollection) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayResourceSKUResults. +func (g *GatewayResourceSKUResults) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5817,9 +6733,6 @@ func (g *GroupCollection) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "count": - err = unpopulate(val, "Count", &g.Count) - delete(rawMsg, key) case "nextLink": err = unpopulate(val, "NextLink", &g.NextLink) delete(rawMsg, key) @@ -5834,18 +6747,15 @@ func (g *GroupCollection) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GroupContract. -func (g GroupContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewaySKU. +func (g GatewaySKU) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", g.ID) populate(objectMap, "name", g.Name) - populate(objectMap, "properties", g.Properties) - populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GroupContract. -func (g *GroupContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewaySKU. +func (g *GatewaySKU) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5853,18 +6763,9 @@ func (g *GroupContract) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &g.ID) - delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &g.Name) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &g.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &g.Type) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5873,19 +6774,18 @@ func (g *GroupContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GroupContractProperties. -func (g GroupContractProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewaySKUCapacity. +func (g GatewaySKUCapacity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "builtIn", g.BuiltIn) - populate(objectMap, "description", g.Description) - populate(objectMap, "displayName", g.DisplayName) - populate(objectMap, "externalId", g.ExternalID) - populate(objectMap, "type", g.Type) + populate(objectMap, "default", g.Default) + populate(objectMap, "maximum", g.Maximum) + populate(objectMap, "minimum", g.Minimum) + populate(objectMap, "scaleType", g.ScaleType) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GroupContractProperties. -func (g *GroupContractProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewaySKUCapacity. +func (g *GatewaySKUCapacity) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5893,20 +6793,17 @@ func (g *GroupContractProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "builtIn": - err = unpopulate(val, "BuiltIn", &g.BuiltIn) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &g.Description) + case "default": + err = unpopulate(val, "Default", &g.Default) delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &g.DisplayName) + case "maximum": + err = unpopulate(val, "Maximum", &g.Maximum) delete(rawMsg, key) - case "externalId": - err = unpopulate(val, "ExternalID", &g.ExternalID) + case "minimum": + err = unpopulate(val, "Minimum", &g.Minimum) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &g.Type) + case "scaleType": + err = unpopulate(val, "ScaleType", &g.ScaleType) delete(rawMsg, key) } if err != nil { @@ -5916,15 +6813,16 @@ func (g *GroupContractProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GroupCreateParameters. -func (g GroupCreateParameters) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewaySKUProperties. +func (g GatewaySKUProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", g.Properties) + populate(objectMap, "capacity", g.Capacity) + populate(objectMap, "name", g.Name) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GroupCreateParameters. -func (g *GroupCreateParameters) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewaySKUProperties. +func (g *GatewaySKUProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5932,8 +6830,11 @@ func (g *GroupCreateParameters) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &g.Properties) + case "capacity": + err = unpopulate(val, "Capacity", &g.Capacity) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) delete(rawMsg, key) } if err != nil { @@ -5943,18 +6844,16 @@ func (g *GroupCreateParameters) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GroupCreateParametersProperties. -func (g GroupCreateParametersProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewaySKUPropertiesForPatch. +func (g GatewaySKUPropertiesForPatch) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", g.Description) - populate(objectMap, "displayName", g.DisplayName) - populate(objectMap, "externalId", g.ExternalID) - populate(objectMap, "type", g.Type) + populate(objectMap, "capacity", g.Capacity) + populate(objectMap, "name", g.Name) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GroupCreateParametersProperties. -func (g *GroupCreateParametersProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewaySKUPropertiesForPatch. +func (g *GatewaySKUPropertiesForPatch) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5962,17 +6861,11 @@ func (g *GroupCreateParametersProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &g.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &g.DisplayName) - delete(rawMsg, key) - case "externalId": - err = unpopulate(val, "ExternalID", &g.ExternalID) + case "capacity": + err = unpopulate(val, "Capacity", &g.Capacity) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &g.Type) + case "name": + err = unpopulate(val, "Name", &g.Name) delete(rawMsg, key) } if err != nil { @@ -5982,15 +6875,15 @@ func (g *GroupCreateParametersProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GroupUpdateParameters. -func (g GroupUpdateParameters) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayTokenContract. +func (g GatewayTokenContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", g.Properties) + populate(objectMap, "value", g.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GroupUpdateParameters. -func (g *GroupUpdateParameters) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayTokenContract. +func (g *GatewayTokenContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -5998,8 +6891,8 @@ func (g *GroupUpdateParameters) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &g.Properties) + case "value": + err = unpopulate(val, "Value", &g.Value) delete(rawMsg, key) } if err != nil { @@ -6009,18 +6902,16 @@ func (g *GroupUpdateParameters) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GroupUpdateParametersProperties. -func (g GroupUpdateParametersProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayTokenRequestContract. +func (g GatewayTokenRequestContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", g.Description) - populate(objectMap, "displayName", g.DisplayName) - populate(objectMap, "externalId", g.ExternalID) - populate(objectMap, "type", g.Type) + populateDateTimeRFC3339(objectMap, "expiry", g.Expiry) + populate(objectMap, "keyType", g.KeyType) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GroupUpdateParametersProperties. -func (g *GroupUpdateParametersProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayTokenRequestContract. +func (g *GatewayTokenRequestContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -6028,17 +6919,11 @@ func (g *GroupUpdateParametersProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &g.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &g.DisplayName) - delete(rawMsg, key) - case "externalId": - err = unpopulate(val, "ExternalID", &g.ExternalID) + case "expiry": + err = unpopulateDateTimeRFC3339(val, "Expiry", &g.Expiry) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &g.Type) + case "keyType": + err = unpopulate(val, "KeyType", &g.KeyType) delete(rawMsg, key) } if err != nil { @@ -6048,84 +6933,579 @@ func (g *GroupUpdateParametersProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type HTTPHeader. -func (h HTTPHeader) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayUpdateParameters. +func (g GatewayUpdateParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "name", h.Name) - populate(objectMap, "value", h.Value) + populate(objectMap, "etag", g.Etag) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "tags", g.Tags) + populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPHeader. -func (h *HTTPHeader) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayUpdateParameters. +func (g *GatewayUpdateParameters) 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", h, err) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } for key, val := range rawMsg { var err error switch key { + case "etag": + err = unpopulate(val, "Etag", &g.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &h.Name) + err = unpopulate(val, "Name", &g.Name) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &h.Value) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &g.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", h, err) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type HTTPMessageDiagnostic. -func (h HTTPMessageDiagnostic) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayUpdateProperties. +func (g GatewayUpdateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "body", h.Body) - populate(objectMap, "dataMasking", h.DataMasking) - populate(objectMap, "headers", h.Headers) + populate(objectMap, "backend", g.Backend) + populate(objectMap, "configurationApi", g.ConfigurationAPI) + populateDateTimeRFC3339(objectMap, "createdAtUtc", g.CreatedAtUTC) + populate(objectMap, "frontend", g.Frontend) + populate(objectMap, "provisioningState", g.ProvisioningState) + populate(objectMap, "targetProvisioningState", g.TargetProvisioningState) + populate(objectMap, "virtualNetworkType", g.VirtualNetworkType) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPMessageDiagnostic. -func (h *HTTPMessageDiagnostic) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayUpdateProperties. +func (g *GatewayUpdateProperties) 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", h, err) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } for key, val := range rawMsg { var err error switch key { - case "body": - err = unpopulate(val, "Body", &h.Body) + case "backend": + err = unpopulate(val, "Backend", &g.Backend) delete(rawMsg, key) - case "dataMasking": - err = unpopulate(val, "DataMasking", &h.DataMasking) + case "configurationApi": + err = unpopulate(val, "ConfigurationAPI", &g.ConfigurationAPI) delete(rawMsg, key) - case "headers": - err = unpopulate(val, "Headers", &h.Headers) + case "createdAtUtc": + err = unpopulateDateTimeRFC3339(val, "CreatedAtUTC", &g.CreatedAtUTC) + delete(rawMsg, key) + case "frontend": + err = unpopulate(val, "Frontend", &g.Frontend) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + case "targetProvisioningState": + err = unpopulate(val, "TargetProvisioningState", &g.TargetProvisioningState) + delete(rawMsg, key) + case "virtualNetworkType": + err = unpopulate(val, "VirtualNetworkType", &g.VirtualNetworkType) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", h, err) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type HostnameConfiguration. -func (h HostnameConfiguration) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GenerateSsoURLResult. +func (g GenerateSsoURLResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "certificate", h.Certificate) - populate(objectMap, "certificatePassword", h.CertificatePassword) - populate(objectMap, "certificateSource", h.CertificateSource) - populate(objectMap, "certificateStatus", h.CertificateStatus) - populate(objectMap, "defaultSslBinding", h.DefaultSSLBinding) - populate(objectMap, "encodedCertificate", h.EncodedCertificate) - populate(objectMap, "hostName", h.HostName) - populate(objectMap, "identityClientId", h.IdentityClientID) - populate(objectMap, "keyVaultId", h.KeyVaultID) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateSsoURLResult. +func (g *GenerateSsoURLResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GlobalSchemaCollection. +func (g GlobalSchemaCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", g.Count) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GlobalSchemaCollection. +func (g *GlobalSchemaCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &g.Count) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GlobalSchemaContract. +func (g GlobalSchemaContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GlobalSchemaContract. +func (g *GlobalSchemaContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GlobalSchemaContractProperties. +func (g GlobalSchemaContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", g.Description) + populateAny(objectMap, "document", g.Document) + populate(objectMap, "provisioningState", g.ProvisioningState) + populate(objectMap, "schemaType", g.SchemaType) + populateAny(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GlobalSchemaContractProperties. +func (g *GlobalSchemaContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &g.Description) + delete(rawMsg, key) + case "document": + err = unpopulate(val, "Document", &g.Document) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + case "schemaType": + err = unpopulate(val, "SchemaType", &g.SchemaType) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupCollection. +func (g GroupCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", g.Count) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupCollection. +func (g *GroupCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &g.Count) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupContract. +func (g GroupContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupContract. +func (g *GroupContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupContractProperties. +func (g GroupContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "builtIn", g.BuiltIn) + populate(objectMap, "description", g.Description) + populate(objectMap, "displayName", g.DisplayName) + populate(objectMap, "externalId", g.ExternalID) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupContractProperties. +func (g *GroupContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "builtIn": + err = unpopulate(val, "BuiltIn", &g.BuiltIn) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &g.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &g.DisplayName) + delete(rawMsg, key) + case "externalId": + err = unpopulate(val, "ExternalID", &g.ExternalID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupCreateParameters. +func (g GroupCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupCreateParameters. +func (g *GroupCreateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupCreateParametersProperties. +func (g GroupCreateParametersProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", g.Description) + populate(objectMap, "displayName", g.DisplayName) + populate(objectMap, "externalId", g.ExternalID) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupCreateParametersProperties. +func (g *GroupCreateParametersProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &g.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &g.DisplayName) + delete(rawMsg, key) + case "externalId": + err = unpopulate(val, "ExternalID", &g.ExternalID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupUpdateParameters. +func (g GroupUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupUpdateParameters. +func (g *GroupUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GroupUpdateParametersProperties. +func (g GroupUpdateParametersProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", g.Description) + populate(objectMap, "displayName", g.DisplayName) + populate(objectMap, "externalId", g.ExternalID) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GroupUpdateParametersProperties. +func (g *GroupUpdateParametersProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &g.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &g.DisplayName) + delete(rawMsg, key) + case "externalId": + err = unpopulate(val, "ExternalID", &g.ExternalID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HTTPHeader. +func (h HTTPHeader) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", h.Name) + populate(objectMap, "value", h.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPHeader. +func (h *HTTPHeader) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &h.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &h.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HTTPMessageDiagnostic. +func (h HTTPMessageDiagnostic) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "body", h.Body) + populate(objectMap, "dataMasking", h.DataMasking) + populate(objectMap, "headers", h.Headers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPMessageDiagnostic. +func (h *HTTPMessageDiagnostic) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "body": + err = unpopulate(val, "Body", &h.Body) + delete(rawMsg, key) + case "dataMasking": + err = unpopulate(val, "DataMasking", &h.DataMasking) + delete(rawMsg, key) + case "headers": + err = unpopulate(val, "Headers", &h.Headers) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HostnameConfiguration. +func (h HostnameConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificate", h.Certificate) + populate(objectMap, "certificatePassword", h.CertificatePassword) + populate(objectMap, "certificateSource", h.CertificateSource) + populate(objectMap, "certificateStatus", h.CertificateStatus) + populate(objectMap, "defaultSslBinding", h.DefaultSSLBinding) + populate(objectMap, "encodedCertificate", h.EncodedCertificate) + populate(objectMap, "hostName", h.HostName) + populate(objectMap, "identityClientId", h.IdentityClientID) + populate(objectMap, "keyVaultId", h.KeyVaultID) populate(objectMap, "negotiateClientCertificate", h.NegotiateClientCertificate) populate(objectMap, "type", h.Type) return json.Marshal(objectMap) @@ -7307,7 +8687,34 @@ func (l *LoggerUpdateParameters) UnmarshalJSON(data []byte) error { delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", l, err) + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MigrateToStv2Contract. +func (m MigrateToStv2Contract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mode", m.Mode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MigrateToStv2Contract. +func (m *MigrateToStv2Contract) 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 "mode": + err = unpopulate(val, "Mode", &m.Mode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil @@ -7392,6 +8799,7 @@ func (n NamedValueContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "displayName", n.DisplayName) populate(objectMap, "keyVault", n.KeyVault) + populate(objectMap, "provisioningState", n.ProvisioningState) populate(objectMap, "secret", n.Secret) populate(objectMap, "tags", n.Tags) populate(objectMap, "value", n.Value) @@ -7413,6 +8821,9 @@ func (n *NamedValueContractProperties) UnmarshalJSON(data []byte) error { case "keyVault": err = unpopulate(val, "KeyVault", &n.KeyVault) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &n.ProvisioningState) + delete(rawMsg, key) case "secret": err = unpopulate(val, "Secret", &n.Secret) delete(rawMsg, key) @@ -8482,6 +9893,65 @@ func (o *OperationResultLogItemContract) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OperationStatusResult. +func (o OperationStatusResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "endTime", o.EndTime) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "operations", o.Operations) + populate(objectMap, "percentComplete", o.PercentComplete) + populate(objectMap, "resourceId", o.ResourceID) + populateDateTimeRFC3339(objectMap, "startTime", o.StartTime) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatusResult. +func (o *OperationStatusResult) 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 "endTime": + err = unpopulateDateTimeRFC3339(val, "EndTime", &o.EndTime) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "operations": + err = unpopulate(val, "Operations", &o.Operations) + delete(rawMsg, key) + case "percentComplete": + err = unpopulate(val, "PercentComplete", &o.PercentComplete) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &o.ResourceID) + delete(rawMsg, key) + case "startTime": + err = unpopulateDateTimeRFC3339(val, "StartTime", &o.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + 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 OperationTagResourceContractProperties. func (o OperationTagResourceContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -8729,8 +10199,214 @@ func (p *ParameterContract) UnmarshalJSON(data []byte) error { case "typeName": err = unpopulate(val, "TypeName", &p.TypeName) delete(rawMsg, key) - case "values": - err = unpopulate(val, "Values", &p.Values) + case "values": + err = unpopulate(val, "Values", &p.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ParameterExampleContract. +func (p ParameterExampleContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", p.Description) + populate(objectMap, "externalValue", p.ExternalValue) + populate(objectMap, "summary", p.Summary) + populateAny(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ParameterExampleContract. +func (p *ParameterExampleContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "externalValue": + err = unpopulate(val, "ExternalValue", &p.ExternalValue) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &p.Summary) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineDiagnosticSettings. +func (p PipelineDiagnosticSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "request", p.Request) + populate(objectMap, "response", p.Response) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineDiagnosticSettings. +func (p *PipelineDiagnosticSettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "request": + err = unpopulate(val, "Request", &p.Request) + delete(rawMsg, key) + case "response": + err = unpopulate(val, "Response", &p.Response) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyCollection. +func (p PolicyCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", p.Count) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyCollection. +func (p *PolicyCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &p.Count) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyContract. +func (p PolicyContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyContract. +func (p *PolicyContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyContractProperties. +func (p PolicyContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "format", p.Format) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyContractProperties. +func (p *PolicyContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "format": + err = unpopulate(val, "Format", &p.Format) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyDescriptionCollection. +func (p PolicyDescriptionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", p.Count) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyDescriptionCollection. +func (p *PolicyDescriptionCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &p.Count) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) delete(rawMsg, key) } if err != nil { @@ -8740,18 +10416,18 @@ func (p *ParameterContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ParameterExampleContract. -func (p ParameterExampleContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyDescriptionContract. +func (p PolicyDescriptionContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", p.Description) - populate(objectMap, "externalValue", p.ExternalValue) - populate(objectMap, "summary", p.Summary) - populateAny(objectMap, "value", p.Value) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ParameterExampleContract. -func (p *ParameterExampleContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyDescriptionContract. +func (p *PolicyDescriptionContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -8759,17 +10435,17 @@ func (p *ParameterExampleContract) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &p.Description) + case "id": + err = unpopulate(val, "ID", &p.ID) delete(rawMsg, key) - case "externalValue": - err = unpopulate(val, "ExternalValue", &p.ExternalValue) + case "name": + err = unpopulate(val, "Name", &p.Name) delete(rawMsg, key) - case "summary": - err = unpopulate(val, "Summary", &p.Summary) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &p.Value) + case "type": + err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) } if err != nil { @@ -8779,16 +10455,16 @@ func (p *ParameterExampleContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PipelineDiagnosticSettings. -func (p PipelineDiagnosticSettings) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyDescriptionContractProperties. +func (p PolicyDescriptionContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "request", p.Request) - populate(objectMap, "response", p.Response) + populate(objectMap, "description", p.Description) + populate(objectMap, "scope", p.Scope) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineDiagnosticSettings. -func (p *PipelineDiagnosticSettings) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyDescriptionContractProperties. +func (p *PolicyDescriptionContractProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -8796,11 +10472,11 @@ func (p *PipelineDiagnosticSettings) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "request": - err = unpopulate(val, "Request", &p.Request) + case "description": + err = unpopulate(val, "Description", &p.Description) delete(rawMsg, key) - case "response": - err = unpopulate(val, "Response", &p.Response) + case "scope": + err = unpopulate(val, "Scope", &p.Scope) delete(rawMsg, key) } if err != nil { @@ -8810,8 +10486,8 @@ func (p *PipelineDiagnosticSettings) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyCollection. -func (p PolicyCollection) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyFragmentCollection. +func (p PolicyFragmentCollection) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "count", p.Count) populate(objectMap, "nextLink", p.NextLink) @@ -8819,8 +10495,8 @@ func (p PolicyCollection) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyCollection. -func (p *PolicyCollection) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyFragmentCollection. +func (p *PolicyFragmentCollection) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -8845,8 +10521,8 @@ func (p *PolicyCollection) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyContract. -func (p PolicyContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyFragmentContract. +func (p PolicyFragmentContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) @@ -8855,8 +10531,8 @@ func (p PolicyContract) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyContract. -func (p *PolicyContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyFragmentContract. +func (p *PolicyFragmentContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -8884,16 +10560,18 @@ func (p *PolicyContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyContractProperties. -func (p PolicyContractProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyFragmentContractProperties. +func (p PolicyFragmentContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "description", p.Description) populate(objectMap, "format", p.Format) + populate(objectMap, "provisioningState", p.ProvisioningState) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyContractProperties. -func (p *PolicyContractProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyFragmentContractProperties. +func (p *PolicyFragmentContractProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -8901,9 +10579,15 @@ func (p *PolicyContractProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) case "format": err = unpopulate(val, "Format", &p.Format) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &p.Value) delete(rawMsg, key) @@ -8915,16 +10599,16 @@ func (p *PolicyContractProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyDescriptionCollection. -func (p PolicyDescriptionCollection) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyRestrictionCollection. +func (p PolicyRestrictionCollection) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "count", p.Count) + populate(objectMap, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyDescriptionCollection. -func (p *PolicyDescriptionCollection) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyRestrictionCollection. +func (p *PolicyRestrictionCollection) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -8932,8 +10616,8 @@ func (p *PolicyDescriptionCollection) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "count": - err = unpopulate(val, "Count", &p.Count) + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &p.Value) @@ -8946,8 +10630,8 @@ func (p *PolicyDescriptionCollection) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyDescriptionContract. -func (p PolicyDescriptionContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyRestrictionContract. +func (p PolicyRestrictionContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) @@ -8956,8 +10640,8 @@ func (p PolicyDescriptionContract) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyDescriptionContract. -func (p *PolicyDescriptionContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyRestrictionContract. +func (p *PolicyRestrictionContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -8985,16 +10669,16 @@ func (p *PolicyDescriptionContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyDescriptionContractProperties. -func (p PolicyDescriptionContractProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyRestrictionContractProperties. +func (p PolicyRestrictionContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", p.Description) + populate(objectMap, "requireBase", p.RequireBase) populate(objectMap, "scope", p.Scope) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyDescriptionContractProperties. -func (p *PolicyDescriptionContractProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyRestrictionContractProperties. +func (p *PolicyRestrictionContractProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -9002,8 +10686,8 @@ func (p *PolicyDescriptionContractProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &p.Description) + case "requireBase": + err = unpopulate(val, "RequireBase", &p.RequireBase) delete(rawMsg, key) case "scope": err = unpopulate(val, "Scope", &p.Scope) @@ -9016,17 +10700,43 @@ func (p *PolicyDescriptionContractProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyFragmentCollection. -func (p PolicyFragmentCollection) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyRestrictionUpdateContract. +func (p PolicyRestrictionUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyRestrictionUpdateContract. +func (p *PolicyRestrictionUpdateContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyWithComplianceCollection. +func (p PolicyWithComplianceCollection) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "count", p.Count) populate(objectMap, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyFragmentCollection. -func (p *PolicyFragmentCollection) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyWithComplianceCollection. +func (p *PolicyWithComplianceCollection) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -9034,9 +10744,6 @@ func (p *PolicyFragmentCollection) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "count": - err = unpopulate(val, "Count", &p.Count) - delete(rawMsg, key) case "nextLink": err = unpopulate(val, "NextLink", &p.NextLink) delete(rawMsg, key) @@ -9051,8 +10758,8 @@ func (p *PolicyFragmentCollection) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyFragmentContract. -func (p PolicyFragmentContract) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyWithComplianceContract. +func (p PolicyWithComplianceContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) @@ -9061,8 +10768,8 @@ func (p PolicyFragmentContract) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyFragmentContract. -func (p *PolicyFragmentContract) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyWithComplianceContract. +func (p *PolicyWithComplianceContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -9090,17 +10797,16 @@ func (p *PolicyFragmentContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PolicyFragmentContractProperties. -func (p PolicyFragmentContractProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PolicyWithComplianceContractProperties. +func (p PolicyWithComplianceContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", p.Description) - populate(objectMap, "format", p.Format) - populate(objectMap, "value", p.Value) + populate(objectMap, "complianceState", p.ComplianceState) + populate(objectMap, "referencePolicyId", p.ReferencePolicyID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyFragmentContractProperties. -func (p *PolicyFragmentContractProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyWithComplianceContractProperties. +func (p *PolicyWithComplianceContractProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -9108,14 +10814,11 @@ func (p *PolicyFragmentContractProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &p.Description) - delete(rawMsg, key) - case "format": - err = unpopulate(val, "Format", &p.Format) + case "complianceState": + err = unpopulate(val, "ComplianceState", &p.ComplianceState) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &p.Value) + case "referencePolicyId": + err = unpopulate(val, "ReferencePolicyID", &p.ReferencePolicyID) delete(rawMsg, key) } if err != nil { @@ -9582,6 +11285,7 @@ func (p PortalRevisionContractProperties) MarshalJSON() ([]byte, error) { populateDateTimeRFC3339(objectMap, "createdDateTime", p.CreatedDateTime) populate(objectMap, "description", p.Description) populate(objectMap, "isCurrent", p.IsCurrent) + populate(objectMap, "provisioningState", p.ProvisioningState) populate(objectMap, "status", p.Status) populate(objectMap, "statusDetails", p.StatusDetails) populateDateTimeRFC3339(objectMap, "updatedDateTime", p.UpdatedDateTime) @@ -9606,6 +11310,9 @@ func (p *PortalRevisionContractProperties) UnmarshalJSON(data []byte) error { case "isCurrent": err = unpopulate(val, "IsCurrent", &p.IsCurrent) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &p.Status) delete(rawMsg, key) @@ -10167,15 +11874,114 @@ func (p *PrivateLinkResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. -func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceListResult. +func (p *PrivateLinkResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceProperties. +func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "groupId": + err = unpopulate(val, "GroupID", &p.GroupID) + delete(rawMsg, key) + case "requiredMembers": + err = unpopulate(val, "RequiredMembers", &p.RequiredMembers) + delete(rawMsg, key) + case "requiredZoneNames": + err = unpopulate(val, "RequiredZoneNames", &p.RequiredZoneNames) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnectionState. +func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionsRequired", p.ActionsRequired) + populate(objectMap, "description", p.Description) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkServiceConnectionState. +func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionsRequired": + err = unpopulate(val, "ActionsRequired", &p.ActionsRequired) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductAPILinkCollection. +func (p ProductAPILinkCollection) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "count", p.Count) + populate(objectMap, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceListResult. -func (p *PrivateLinkResourceListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductAPILinkCollection. +func (p *ProductAPILinkCollection) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -10183,6 +11989,12 @@ func (p *PrivateLinkResourceListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "count": + err = unpopulate(val, "Count", &p.Count) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &p.Value) delete(rawMsg, key) @@ -10194,17 +12006,18 @@ func (p *PrivateLinkResourceListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. -func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ProductAPILinkContract. +func (p ProductAPILinkContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "groupId", p.GroupID) - populate(objectMap, "requiredMembers", p.RequiredMembers) - populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceProperties. -func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductAPILinkContract. +func (p *ProductAPILinkContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -10212,14 +12025,17 @@ func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "groupId": - err = unpopulate(val, "GroupID", &p.GroupID) + case "id": + err = unpopulate(val, "ID", &p.ID) delete(rawMsg, key) - case "requiredMembers": - err = unpopulate(val, "RequiredMembers", &p.RequiredMembers) + case "name": + err = unpopulate(val, "Name", &p.Name) delete(rawMsg, key) - case "requiredZoneNames": - err = unpopulate(val, "RequiredZoneNames", &p.RequiredZoneNames) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) } if err != nil { @@ -10229,17 +12045,15 @@ func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnectionState. -func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ProductAPILinkContractProperties. +func (p ProductAPILinkContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "actionsRequired", p.ActionsRequired) - populate(objectMap, "description", p.Description) - populate(objectMap, "status", p.Status) + populate(objectMap, "apiId", p.APIID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkServiceConnectionState. -func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductAPILinkContractProperties. +func (p *ProductAPILinkContractProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -10247,14 +12061,8 @@ func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "actionsRequired": - err = unpopulate(val, "ActionsRequired", &p.ActionsRequired) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &p.Description) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &p.Status) + case "apiId": + err = unpopulate(val, "APIID", &p.APIID) delete(rawMsg, key) } if err != nil { @@ -10436,6 +12244,107 @@ func (p *ProductEntityBaseParameters) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ProductGroupLinkCollection. +func (p ProductGroupLinkCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", p.Count) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductGroupLinkCollection. +func (p *ProductGroupLinkCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &p.Count) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductGroupLinkContract. +func (p ProductGroupLinkContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductGroupLinkContract. +func (p *ProductGroupLinkContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductGroupLinkContractProperties. +func (p ProductGroupLinkContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "groupId", p.GroupID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductGroupLinkContractProperties. +func (p *ProductGroupLinkContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "groupId": + err = unpopulate(val, "GroupID", &p.GroupID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ProductTagResourceContractProperties. func (p ProductTagResourceContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -12632,6 +14541,7 @@ func (s SchemaContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "contentType", s.ContentType) populate(objectMap, "document", s.Document) + populate(objectMap, "provisioningState", s.ProvisioningState) return json.Marshal(objectMap) } @@ -12650,6 +14560,9 @@ func (s *SchemaContractProperties) UnmarshalJSON(data []byte) error { case "document": err = unpopulate(val, "Document", &s.Document) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -12773,14 +14686,17 @@ func (s ServiceBaseProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "apiVersionConstraint", s.APIVersionConstraint) populate(objectMap, "additionalLocations", s.AdditionalLocations) populate(objectMap, "certificates", s.Certificates) + populate(objectMap, "configurationApi", s.ConfigurationAPI) populateDateTimeRFC3339(objectMap, "createdAtUtc", s.CreatedAtUTC) populate(objectMap, "customProperties", s.CustomProperties) + populate(objectMap, "developerPortalStatus", s.DeveloperPortalStatus) populate(objectMap, "developerPortalUrl", s.DeveloperPortalURL) populate(objectMap, "disableGateway", s.DisableGateway) populate(objectMap, "enableClientCertificate", s.EnableClientCertificate) populate(objectMap, "gatewayRegionalUrl", s.GatewayRegionalURL) populate(objectMap, "gatewayUrl", s.GatewayURL) populate(objectMap, "hostnameConfigurations", s.HostnameConfigurations) + populate(objectMap, "legacyPortalStatus", s.LegacyPortalStatus) populate(objectMap, "managementApiUrl", s.ManagementAPIURL) populate(objectMap, "natGatewayState", s.NatGatewayState) populate(objectMap, "notificationSenderEmail", s.NotificationSenderEmail) @@ -12819,12 +14735,18 @@ func (s *ServiceBaseProperties) UnmarshalJSON(data []byte) error { case "certificates": err = unpopulate(val, "Certificates", &s.Certificates) delete(rawMsg, key) + case "configurationApi": + err = unpopulate(val, "ConfigurationAPI", &s.ConfigurationAPI) + delete(rawMsg, key) case "createdAtUtc": err = unpopulateDateTimeRFC3339(val, "CreatedAtUTC", &s.CreatedAtUTC) delete(rawMsg, key) case "customProperties": err = unpopulate(val, "CustomProperties", &s.CustomProperties) delete(rawMsg, key) + case "developerPortalStatus": + err = unpopulate(val, "DeveloperPortalStatus", &s.DeveloperPortalStatus) + delete(rawMsg, key) case "developerPortalUrl": err = unpopulate(val, "DeveloperPortalURL", &s.DeveloperPortalURL) delete(rawMsg, key) @@ -12843,6 +14765,9 @@ func (s *ServiceBaseProperties) UnmarshalJSON(data []byte) error { case "hostnameConfigurations": err = unpopulate(val, "HostnameConfigurations", &s.HostnameConfigurations) delete(rawMsg, key) + case "legacyPortalStatus": + err = unpopulate(val, "LegacyPortalStatus", &s.LegacyPortalStatus) + delete(rawMsg, key) case "managementApiUrl": err = unpopulate(val, "ManagementAPIURL", &s.ManagementAPIURL) delete(rawMsg, key) @@ -13094,14 +15019,17 @@ func (s ServiceProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "apiVersionConstraint", s.APIVersionConstraint) populate(objectMap, "additionalLocations", s.AdditionalLocations) populate(objectMap, "certificates", s.Certificates) + populate(objectMap, "configurationApi", s.ConfigurationAPI) populateDateTimeRFC3339(objectMap, "createdAtUtc", s.CreatedAtUTC) populate(objectMap, "customProperties", s.CustomProperties) + populate(objectMap, "developerPortalStatus", s.DeveloperPortalStatus) populate(objectMap, "developerPortalUrl", s.DeveloperPortalURL) populate(objectMap, "disableGateway", s.DisableGateway) populate(objectMap, "enableClientCertificate", s.EnableClientCertificate) populate(objectMap, "gatewayRegionalUrl", s.GatewayRegionalURL) populate(objectMap, "gatewayUrl", s.GatewayURL) populate(objectMap, "hostnameConfigurations", s.HostnameConfigurations) + populate(objectMap, "legacyPortalStatus", s.LegacyPortalStatus) populate(objectMap, "managementApiUrl", s.ManagementAPIURL) populate(objectMap, "natGatewayState", s.NatGatewayState) populate(objectMap, "notificationSenderEmail", s.NotificationSenderEmail) @@ -13142,12 +15070,18 @@ func (s *ServiceProperties) UnmarshalJSON(data []byte) error { case "certificates": err = unpopulate(val, "Certificates", &s.Certificates) delete(rawMsg, key) + case "configurationApi": + err = unpopulate(val, "ConfigurationAPI", &s.ConfigurationAPI) + delete(rawMsg, key) case "createdAtUtc": err = unpopulateDateTimeRFC3339(val, "CreatedAtUTC", &s.CreatedAtUTC) delete(rawMsg, key) case "customProperties": err = unpopulate(val, "CustomProperties", &s.CustomProperties) delete(rawMsg, key) + case "developerPortalStatus": + err = unpopulate(val, "DeveloperPortalStatus", &s.DeveloperPortalStatus) + delete(rawMsg, key) case "developerPortalUrl": err = unpopulate(val, "DeveloperPortalURL", &s.DeveloperPortalURL) delete(rawMsg, key) @@ -13166,6 +15100,9 @@ func (s *ServiceProperties) UnmarshalJSON(data []byte) error { case "hostnameConfigurations": err = unpopulate(val, "HostnameConfigurations", &s.HostnameConfigurations) delete(rawMsg, key) + case "legacyPortalStatus": + err = unpopulate(val, "LegacyPortalStatus", &s.LegacyPortalStatus) + delete(rawMsg, key) case "managementApiUrl": err = unpopulate(val, "ManagementAPIURL", &s.ManagementAPIURL) delete(rawMsg, key) @@ -13394,14 +15331,17 @@ func (s ServiceUpdateProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "apiVersionConstraint", s.APIVersionConstraint) populate(objectMap, "additionalLocations", s.AdditionalLocations) populate(objectMap, "certificates", s.Certificates) + populate(objectMap, "configurationApi", s.ConfigurationAPI) populateDateTimeRFC3339(objectMap, "createdAtUtc", s.CreatedAtUTC) populate(objectMap, "customProperties", s.CustomProperties) + populate(objectMap, "developerPortalStatus", s.DeveloperPortalStatus) populate(objectMap, "developerPortalUrl", s.DeveloperPortalURL) populate(objectMap, "disableGateway", s.DisableGateway) populate(objectMap, "enableClientCertificate", s.EnableClientCertificate) populate(objectMap, "gatewayRegionalUrl", s.GatewayRegionalURL) populate(objectMap, "gatewayUrl", s.GatewayURL) populate(objectMap, "hostnameConfigurations", s.HostnameConfigurations) + populate(objectMap, "legacyPortalStatus", s.LegacyPortalStatus) populate(objectMap, "managementApiUrl", s.ManagementAPIURL) populate(objectMap, "natGatewayState", s.NatGatewayState) populate(objectMap, "notificationSenderEmail", s.NotificationSenderEmail) @@ -13442,12 +15382,18 @@ func (s *ServiceUpdateProperties) UnmarshalJSON(data []byte) error { case "certificates": err = unpopulate(val, "Certificates", &s.Certificates) delete(rawMsg, key) + case "configurationApi": + err = unpopulate(val, "ConfigurationAPI", &s.ConfigurationAPI) + delete(rawMsg, key) case "createdAtUtc": err = unpopulateDateTimeRFC3339(val, "CreatedAtUTC", &s.CreatedAtUTC) delete(rawMsg, key) case "customProperties": err = unpopulate(val, "CustomProperties", &s.CustomProperties) delete(rawMsg, key) + case "developerPortalStatus": + err = unpopulate(val, "DeveloperPortalStatus", &s.DeveloperPortalStatus) + delete(rawMsg, key) case "developerPortalUrl": err = unpopulate(val, "DeveloperPortalURL", &s.DeveloperPortalURL) delete(rawMsg, key) @@ -13466,6 +15412,9 @@ func (s *ServiceUpdateProperties) UnmarshalJSON(data []byte) error { case "hostnameConfigurations": err = unpopulate(val, "HostnameConfigurations", &s.HostnameConfigurations) delete(rawMsg, key) + case "legacyPortalStatus": + err = unpopulate(val, "LegacyPortalStatus", &s.LegacyPortalStatus) + delete(rawMsg, key) case "managementApiUrl": err = unpopulate(val, "ManagementAPIURL", &s.ManagementAPIURL) delete(rawMsg, key) @@ -13900,81 +15849,182 @@ func (s *SubscriptionUpdateParameters) UnmarshalJSON(data []byte) error { delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionsDelegationSettingsProperties. +func (s SubscriptionsDelegationSettingsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabled", s.Enabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionsDelegationSettingsProperties. +func (s *SubscriptionsDelegationSettingsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enabled": + err = unpopulate(val, "Enabled", &s.Enabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagAPILinkCollection. +func (t TagAPILinkCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", t.Count) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagAPILinkCollection. +func (t *TagAPILinkCollection) 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 "count": + err = unpopulate(val, "Count", &t.Count) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type SubscriptionsDelegationSettingsProperties. -func (s SubscriptionsDelegationSettingsProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TagAPILinkContract. +func (t TagAPILinkContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "enabled", s.Enabled) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "type", t.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionsDelegationSettingsProperties. -func (s *SubscriptionsDelegationSettingsProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TagAPILinkContract. +func (t *TagAPILinkContract) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "enabled": - err = unpopulate(val, "Enabled", &s.Enabled) + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TagAPILinkContractProperties. +func (t TagAPILinkContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + populate(objectMap, "apiId", t.APIID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TagAPILinkContractProperties. +func (t *TagAPILinkContractProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "createdAt": - err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + case "apiId": + err = unpopulate(val, "APIID", &t.APIID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil @@ -14217,19 +16267,224 @@ func (t *TagDescriptionContract) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TagDescriptionContractProperties. -func (t TagDescriptionContractProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TagDescriptionContractProperties. +func (t TagDescriptionContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", t.Description) + populate(objectMap, "displayName", t.DisplayName) + populate(objectMap, "externalDocsDescription", t.ExternalDocsDescription) + populate(objectMap, "externalDocsUrl", t.ExternalDocsURL) + populate(objectMap, "tagId", t.TagID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagDescriptionContractProperties. +func (t *TagDescriptionContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &t.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &t.DisplayName) + delete(rawMsg, key) + case "externalDocsDescription": + err = unpopulate(val, "ExternalDocsDescription", &t.ExternalDocsDescription) + delete(rawMsg, key) + case "externalDocsUrl": + err = unpopulate(val, "ExternalDocsURL", &t.ExternalDocsURL) + delete(rawMsg, key) + case "tagId": + err = unpopulate(val, "TagID", &t.TagID) + 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 TagDescriptionCreateParameters. +func (t TagDescriptionCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagDescriptionCreateParameters. +func (t *TagDescriptionCreateParameters) 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 "properties": + err = unpopulate(val, "Properties", &t.Properties) + 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 TagOperationLinkCollection. +func (t TagOperationLinkCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", t.Count) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagOperationLinkCollection. +func (t *TagOperationLinkCollection) 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 "count": + err = unpopulate(val, "Count", &t.Count) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagOperationLinkContract. +func (t TagOperationLinkContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagOperationLinkContract. +func (t *TagOperationLinkContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagOperationLinkContractProperties. +func (t TagOperationLinkContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "operationId", t.OperationID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagOperationLinkContractProperties. +func (t *TagOperationLinkContractProperties) 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 "operationId": + err = unpopulate(val, "OperationID", &t.OperationID) + 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 TagProductLinkCollection. +func (t TagProductLinkCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", t.Count) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagProductLinkCollection. +func (t *TagProductLinkCollection) 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 "count": + err = unpopulate(val, "Count", &t.Count) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagProductLinkContract. +func (t TagProductLinkContract) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", t.Description) - populate(objectMap, "displayName", t.DisplayName) - populate(objectMap, "externalDocsDescription", t.ExternalDocsDescription) - populate(objectMap, "externalDocsUrl", t.ExternalDocsURL) - populate(objectMap, "tagId", t.TagID) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "type", t.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TagDescriptionContractProperties. -func (t *TagDescriptionContractProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TagProductLinkContract. +func (t *TagProductLinkContract) 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) @@ -14237,20 +16492,17 @@ func (t *TagDescriptionContractProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &t.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &t.DisplayName) + case "id": + err = unpopulate(val, "ID", &t.ID) delete(rawMsg, key) - case "externalDocsDescription": - err = unpopulate(val, "ExternalDocsDescription", &t.ExternalDocsDescription) + case "name": + err = unpopulate(val, "Name", &t.Name) delete(rawMsg, key) - case "externalDocsUrl": - err = unpopulate(val, "ExternalDocsURL", &t.ExternalDocsURL) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) delete(rawMsg, key) - case "tagId": - err = unpopulate(val, "TagID", &t.TagID) + case "type": + err = unpopulate(val, "Type", &t.Type) delete(rawMsg, key) } if err != nil { @@ -14260,15 +16512,15 @@ func (t *TagDescriptionContractProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TagDescriptionCreateParameters. -func (t TagDescriptionCreateParameters) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TagProductLinkContractProperties. +func (t TagProductLinkContractProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", t.Properties) + populate(objectMap, "productId", t.ProductID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type TagDescriptionCreateParameters. -func (t *TagDescriptionCreateParameters) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TagProductLinkContractProperties. +func (t *TagProductLinkContractProperties) 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) @@ -14276,8 +16528,8 @@ func (t *TagDescriptionCreateParameters) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &t.Properties) + case "productId": + err = unpopulate(val, "ProductID", &t.ProductID) delete(rawMsg, key) } if err != nil { @@ -15345,6 +17597,274 @@ func (w *WikiUpdateContract) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type WorkspaceCollection. +func (w WorkspaceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", w.Count) + 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 "count": + err = unpopulate(val, "Count", &w.Count) + delete(rawMsg, 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 WorkspaceContract. +func (w WorkspaceContract) 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, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceContract. +func (w *WorkspaceContract) 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 "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 WorkspaceContractProperties. +func (w WorkspaceContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", w.Description) + populate(objectMap, "displayName", w.DisplayName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceContractProperties. +func (w *WorkspaceContractProperties) 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 "displayName": + err = unpopulate(val, "DisplayName", &w.DisplayName) + 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 WorkspaceLinksBaseProperties. +func (w WorkspaceLinksBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "gateways", w.Gateways) + populate(objectMap, "workspaceId", w.WorkspaceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceLinksBaseProperties. +func (w *WorkspaceLinksBaseProperties) 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 "gateways": + err = unpopulate(val, "Gateways", &w.Gateways) + delete(rawMsg, key) + case "workspaceId": + err = unpopulate(val, "WorkspaceID", &w.WorkspaceID) + 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 WorkspaceLinksGateway. +func (w WorkspaceLinksGateway) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceLinksGateway. +func (w *WorkspaceLinksGateway) 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceLinksListResult. +func (w WorkspaceLinksListResult) 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 WorkspaceLinksListResult. +func (w *WorkspaceLinksListResult) 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 WorkspaceLinksProperties. +func (w WorkspaceLinksProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "gateways", w.Gateways) + populate(objectMap, "workspaceId", w.WorkspaceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceLinksProperties. +func (w *WorkspaceLinksProperties) 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 "gateways": + err = unpopulate(val, "Gateways", &w.Gateways) + delete(rawMsg, key) + case "workspaceId": + err = unpopulate(val, "WorkspaceID", &w.WorkspaceID) + 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 WorkspaceLinksResource. +func (w WorkspaceLinksResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", w.Etag) + populate(objectMap, "id", w.ID) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceLinksResource. +func (w *WorkspaceLinksResource) 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 "etag": + err = unpopulate(val, "Etag", &w.Etag) + delete(rawMsg, 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 "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 X509CertificateName. func (x X509CertificateName) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -15397,7 +17917,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/namedvalue_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/namedvalue_client.go index 7606df5e6603..8b25409111bd 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/namedvalue_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/namedvalue_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type NamedValueClient struct { } // NewNamedValueClient creates a new instance of NamedValueClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewNamedValueClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NamedValueClient, error) { @@ -47,7 +44,7 @@ func NewNamedValueClient(subscriptionID string, credential azcore.TokenCredentia // BeginCreateOrUpdate - Creates or updates named value. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - namedValueID - Identifier of the NamedValue. @@ -75,7 +72,7 @@ func (client *NamedValueClient) BeginCreateOrUpdate(ctx context.Context, resourc // CreateOrUpdate - Creates or updates named value. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *NamedValueClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters NamedValueCreateContract, options *NamedValueClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "NamedValueClient.BeginCreateOrUpdate" @@ -90,7 +87,7 @@ func (client *NamedValueClient) createOrUpdate(ctx context.Context, resourceGrou if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -121,12 +118,12 @@ func (client *NamedValueClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -136,7 +133,7 @@ func (client *NamedValueClient) createOrUpdateCreateRequest(ctx context.Context, // Delete - Deletes specific named value from the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - namedValueID - Identifier of the NamedValue. @@ -165,7 +162,7 @@ func (client *NamedValueClient) Delete(ctx context.Context, resourceGroupName st } // deleteCreateRequest creates the Delete request. -func (client *NamedValueClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, options *NamedValueClientDeleteOptions) (*policy.Request, error) { +func (client *NamedValueClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, _ *NamedValueClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -188,17 +185,17 @@ func (client *NamedValueClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the named value specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - namedValueID - Identifier of the NamedValue. @@ -226,7 +223,7 @@ func (client *NamedValueClient) Get(ctx context.Context, resourceGroupName strin } // getCreateRequest creates the Get request. -func (client *NamedValueClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueClientGetOptions) (*policy.Request, error) { +func (client *NamedValueClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, _ *NamedValueClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -249,7 +246,7 @@ func (client *NamedValueClient) getCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -269,7 +266,7 @@ func (client *NamedValueClient) getHandleResponse(resp *http.Response) (NamedVal // GetEntityTag - Gets the entity state (Etag) version of the named value specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - namedValueID - Identifier of the NamedValue. @@ -297,7 +294,7 @@ func (client *NamedValueClient) GetEntityTag(ctx context.Context, resourceGroupN } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *NamedValueClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueClientGetEntityTagOptions) (*policy.Request, error) { +func (client *NamedValueClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, _ *NamedValueClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -320,7 +317,7 @@ func (client *NamedValueClient) getEntityTagCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -337,7 +334,7 @@ func (client *NamedValueClient) getEntityTagHandleResponse(resp *http.Response) // NewListByServicePager - Lists a collection of named values defined within a service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - NamedValueClientListByServiceOptions contains the optional parameters for the NamedValueClient.NewListByServicePager @@ -388,16 +385,16 @@ func (client *NamedValueClient) listByServiceCreateRequest(ctx context.Context, if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.IsKeyVaultRefreshFailed != nil { reqQP.Set("isKeyVaultRefreshFailed", strconv.FormatBool(*options.IsKeyVaultRefreshFailed)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -415,7 +412,7 @@ func (client *NamedValueClient) listByServiceHandleResponse(resp *http.Response) // ListValue - Gets the secret of the named value specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - namedValueID - Identifier of the NamedValue. @@ -443,7 +440,7 @@ func (client *NamedValueClient) ListValue(ctx context.Context, resourceGroupName } // listValueCreateRequest creates the ListValue request. -func (client *NamedValueClient) listValueCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueClientListValueOptions) (*policy.Request, error) { +func (client *NamedValueClient) listValueCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, _ *NamedValueClientListValueOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -466,7 +463,7 @@ func (client *NamedValueClient) listValueCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -487,7 +484,7 @@ func (client *NamedValueClient) listValueHandleResponse(resp *http.Response) (Na // BeginRefreshSecret - Refresh the secret of the named value specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - namedValueID - Identifier of the NamedValue. @@ -514,7 +511,7 @@ func (client *NamedValueClient) BeginRefreshSecret(ctx context.Context, resource // RefreshSecret - Refresh the secret of the named value specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *NamedValueClient) refreshSecret(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueClientBeginRefreshSecretOptions) (*http.Response, error) { var err error const operationName = "NamedValueClient.BeginRefreshSecret" @@ -537,7 +534,7 @@ func (client *NamedValueClient) refreshSecret(ctx context.Context, resourceGroup } // refreshSecretCreateRequest creates the RefreshSecret request. -func (client *NamedValueClient) refreshSecretCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueClientBeginRefreshSecretOptions) (*policy.Request, error) { +func (client *NamedValueClient) refreshSecretCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, _ *NamedValueClientBeginRefreshSecretOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -560,7 +557,7 @@ func (client *NamedValueClient) refreshSecretCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -569,7 +566,7 @@ func (client *NamedValueClient) refreshSecretCreateRequest(ctx context.Context, // BeginUpdate - Updates the specific named value. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - namedValueID - Identifier of the NamedValue. @@ -598,7 +595,7 @@ func (client *NamedValueClient) BeginUpdate(ctx context.Context, resourceGroupNa // Update - Updates the specific named value. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *NamedValueClient) update(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, parameters NamedValueUpdateParameters, options *NamedValueClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "NamedValueClient.BeginUpdate" @@ -621,7 +618,7 @@ func (client *NamedValueClient) update(ctx context.Context, resourceGroupName st } // updateCreateRequest creates the Update request. -func (client *NamedValueClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, parameters NamedValueUpdateParameters, options *NamedValueClientBeginUpdateOptions) (*policy.Request, error) { +func (client *NamedValueClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, parameters NamedValueUpdateParameters, _ *NamedValueClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -644,10 +641,10 @@ func (client *NamedValueClient) updateCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/namedvalue_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/namedvalue_client_example_test.go deleted file mode 100644 index f39f5bfc1fef..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/namedvalue_client_example_test.go +++ /dev/null @@ -1,403 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListNamedValues.json -func ExampleNamedValueClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewNamedValueClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.NamedValueClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: nil, - IsKeyVaultRefreshFailed: 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.NamedValueCollection = armapimanagement.NamedValueCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.NamedValueContract{ - // { - // Name: to.Ptr("592f1174cc83890dc4f32686"), - // Type: to.Ptr("Microsoft.ApiManagement/service/namedValues"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/namedValues/592f1174cc83890dc4f32686"), - // Properties: &armapimanagement.NamedValueContractProperties{ - // Secret: to.Ptr(false), - // DisplayName: to.Ptr("Logger-Credentials-592f1174cc83890dc4f32687"), - // Value: to.Ptr("propValue"), - // }, - // }, - // { - // Name: to.Ptr("testprop6"), - // Type: to.Ptr("Microsoft.ApiManagement/service/namedValues"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/namedValues/testprop6"), - // Properties: &armapimanagement.NamedValueContractProperties{ - // Secret: to.Ptr(true), - // Tags: []*string{ - // to.Ptr("foo"), - // to.Ptr("bar")}, - // DisplayName: to.Ptr("prop6namekv"), - // KeyVault: &armapimanagement.KeyVaultContractProperties{ - // IdentityClientID: to.Ptr("2d2df842-44d8-4885-8dec-77cc1a984a31"), - // SecretIdentifier: to.Ptr("https://contoso.vault.azure.net/secrets/aadSecret"), - // LastStatus: &armapimanagement.KeyVaultLastAccessStatusContractProperties{ - // Code: to.Ptr("Success"), - // TimeStampUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-11T00:54:31.802Z"); return t}()), - // }, - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadNamedValue.json -func ExampleNamedValueClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewNamedValueClient().GetEntityTag(ctx, "rg1", "apimService1", "testarmTemplateproperties2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetNamedValue.json -func ExampleNamedValueClient_Get_apiManagementGetNamedValue() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNamedValueClient().Get(ctx, "rg1", "apimService1", "testarmTemplateproperties2", 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.NamedValueContract = armapimanagement.NamedValueContract{ - // Name: to.Ptr("testarmTemplateproperties2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/namedValues"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/namedValues/testarmTemplateproperties2"), - // Properties: &armapimanagement.NamedValueContractProperties{ - // Secret: to.Ptr(false), - // Tags: []*string{ - // to.Ptr("foo"), - // to.Ptr("bar")}, - // DisplayName: to.Ptr("propName"), - // Value: to.Ptr("propValue"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetNamedValueWithKeyVault.json -func ExampleNamedValueClient_Get_apiManagementGetNamedValueWithKeyVault() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNamedValueClient().Get(ctx, "rg1", "apimService1", "testprop6", 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.NamedValueContract = armapimanagement.NamedValueContract{ - // Name: to.Ptr("testprop6"), - // Type: to.Ptr("Microsoft.ApiManagement/service/namedValues"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/namedValues/testprop6"), - // Properties: &armapimanagement.NamedValueContractProperties{ - // Secret: to.Ptr(true), - // Tags: []*string{ - // to.Ptr("foo"), - // to.Ptr("bar")}, - // DisplayName: to.Ptr("prop6namekv"), - // KeyVault: &armapimanagement.KeyVaultContractProperties{ - // IdentityClientID: to.Ptr("2d2df842-44d8-4885-8dec-77cc1a984a31"), - // SecretIdentifier: to.Ptr("https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert"), - // LastStatus: &armapimanagement.KeyVaultLastAccessStatusContractProperties{ - // Code: to.Ptr("Success"), - // TimeStampUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-11T00:54:31.802Z"); return t}()), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNamedValue.json -func ExampleNamedValueClient_BeginCreateOrUpdate_apiManagementCreateNamedValue() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewNamedValueClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "testprop2", armapimanagement.NamedValueCreateContract{ - Properties: &armapimanagement.NamedValueCreateContractProperties{ - Secret: to.Ptr(false), - Tags: []*string{ - to.Ptr("foo"), - to.Ptr("bar")}, - DisplayName: to.Ptr("prop3name"), - Value: to.Ptr("propValue"), - }, - }, &armapimanagement.NamedValueClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.NamedValueContract = armapimanagement.NamedValueContract{ - // Name: to.Ptr("testprop2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/namedValues"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/namedValues/testprop2"), - // Properties: &armapimanagement.NamedValueContractProperties{ - // Secret: to.Ptr(false), - // Tags: []*string{ - // to.Ptr("foo"), - // to.Ptr("bar")}, - // DisplayName: to.Ptr("prop3name"), - // Value: to.Ptr("propValue"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNamedValueWithKeyVault.json -func ExampleNamedValueClient_BeginCreateOrUpdate_apiManagementCreateNamedValueWithKeyVault() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewNamedValueClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "testprop6", armapimanagement.NamedValueCreateContract{ - Properties: &armapimanagement.NamedValueCreateContractProperties{ - Secret: to.Ptr(true), - Tags: []*string{ - to.Ptr("foo"), - to.Ptr("bar")}, - DisplayName: to.Ptr("prop6namekv"), - KeyVault: &armapimanagement.KeyVaultContractCreateProperties{ - IdentityClientID: to.Ptr("ceaa6b06-c00f-43ef-99ac-f53d1fe876a0"), - SecretIdentifier: to.Ptr("https://contoso.vault.azure.net/secrets/aadSecret"), - }, - }, - }, &armapimanagement.NamedValueClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.NamedValueContract = armapimanagement.NamedValueContract{ - // Name: to.Ptr("testprop6"), - // Type: to.Ptr("Microsoft.ApiManagement/service/namedValues"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/namedValues/testprop6"), - // Properties: &armapimanagement.NamedValueContractProperties{ - // Secret: to.Ptr(true), - // Tags: []*string{ - // to.Ptr("foo"), - // to.Ptr("bar")}, - // DisplayName: to.Ptr("prop6namekv"), - // KeyVault: &armapimanagement.KeyVaultContractProperties{ - // IdentityClientID: to.Ptr("ceaa6b06-c00f-43ef-99ac-f53d1fe876a0"), - // SecretIdentifier: to.Ptr("https://contoso.vault.azure.net/secrets/aadSecret"), - // LastStatus: &armapimanagement.KeyVaultLastAccessStatusContractProperties{ - // Code: to.Ptr("Success"), - // TimeStampUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-11T00:54:31.802Z"); return t}()), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateNamedValue.json -func ExampleNamedValueClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewNamedValueClient().BeginUpdate(ctx, "rg1", "apimService1", "testprop2", "*", armapimanagement.NamedValueUpdateParameters{ - Properties: &armapimanagement.NamedValueUpdateParameterProperties{ - Secret: to.Ptr(false), - Tags: []*string{ - to.Ptr("foo"), - to.Ptr("bar2")}, - DisplayName: to.Ptr("prop3name"), - Value: to.Ptr("propValue"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.NamedValueContract = armapimanagement.NamedValueContract{ - // Type: to.Ptr("Microsoft.ApiManagement/service/namedValues"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/namedValues/testprop2"), - // Properties: &armapimanagement.NamedValueContractProperties{ - // Secret: to.Ptr(false), - // Tags: []*string{ - // to.Ptr("foo"), - // to.Ptr("bar2")}, - // DisplayName: to.Ptr("prop3name"), - // Value: to.Ptr("propValue"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteNamedValue.json -func ExampleNamedValueClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewNamedValueClient().Delete(ctx, "rg1", "apimService1", "testprop2", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementNamedValueListValue.json -func ExampleNamedValueClient_ListValue() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNamedValueClient().ListValue(ctx, "rg1", "apimService1", "testarmTemplateproperties2", 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.NamedValueSecretContract = armapimanagement.NamedValueSecretContract{ - // Value: to.Ptr("propValue"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementRefreshNamedValue.json -func ExampleNamedValueClient_BeginRefreshSecret() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewNamedValueClient().BeginRefreshSecret(ctx, "rg1", "apimService1", "testprop2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.NamedValueContract = armapimanagement.NamedValueContract{ - // Name: to.Ptr("testprop6"), - // Type: to.Ptr("Microsoft.ApiManagement/service/namedValues"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/namedValues/testprop6"), - // Properties: &armapimanagement.NamedValueContractProperties{ - // Secret: to.Ptr(true), - // Tags: []*string{ - // to.Ptr("foo"), - // to.Ptr("bar")}, - // DisplayName: to.Ptr("prop6namekv"), - // KeyVault: &armapimanagement.KeyVaultContractProperties{ - // IdentityClientID: to.Ptr("2d2df842-44d8-4885-8dec-77cc1a984a31"), - // SecretIdentifier: to.Ptr("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), - // LastStatus: &armapimanagement.KeyVaultLastAccessStatusContractProperties{ - // Code: to.Ptr("Success"), - // TimeStampUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-11T00:54:31.802Z"); return t}()), - // }, - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/networkstatus_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/networkstatus_client.go index c5a4cc8f5223..f8b3665ca4b8 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/networkstatus_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/networkstatus_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type NetworkStatusClient struct { } // NewNetworkStatusClient creates a new instance of NetworkStatusClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewNetworkStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NetworkStatusClient, error) { @@ -47,7 +44,7 @@ func NewNetworkStatusClient(subscriptionID string, credential azcore.TokenCreden // inside the Cloud Service. This also returns the DNS Servers as visible to the CloudService. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - locationName - Location in which the API Management service is deployed. This is one of the Azure Regions like West US, @@ -77,7 +74,7 @@ func (client *NetworkStatusClient) ListByLocation(ctx context.Context, resourceG } // listByLocationCreateRequest creates the ListByLocation request. -func (client *NetworkStatusClient) listByLocationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, locationName string, options *NetworkStatusClientListByLocationOptions) (*policy.Request, error) { +func (client *NetworkStatusClient) listByLocationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, locationName string, _ *NetworkStatusClientListByLocationOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -100,7 +97,7 @@ func (client *NetworkStatusClient) listByLocationCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -119,7 +116,7 @@ func (client *NetworkStatusClient) listByLocationHandleResponse(resp *http.Respo // inside the Cloud Service. This also returns the DNS Servers as visible to the CloudService. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - NetworkStatusClientListByServiceOptions contains the optional parameters for the NetworkStatusClient.ListByService @@ -147,7 +144,7 @@ func (client *NetworkStatusClient) ListByService(ctx context.Context, resourceGr } // listByServiceCreateRequest creates the ListByService request. -func (client *NetworkStatusClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *NetworkStatusClientListByServiceOptions) (*policy.Request, error) { +func (client *NetworkStatusClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *NetworkStatusClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -166,7 +163,7 @@ func (client *NetworkStatusClient) listByServiceCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/networkstatus_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/networkstatus_client_example_test.go deleted file mode 100644 index 1597d097a29a..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/networkstatus_client_example_test.go +++ /dev/null @@ -1,324 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetNetworkStatus.json -func ExampleNetworkStatusClient_ListByService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNetworkStatusClient().ListByService(ctx, "rg1", "apimService1", 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.NetworkStatusContractByLocationArray = []*armapimanagement.NetworkStatusContractByLocation{ - // { - // Location: to.Ptr("West US"), - // NetworkStatus: &armapimanagement.NetworkStatusContract{ - // ConnectivityStatus: []*armapimanagement.ConnectivityStatusContract{ - // { - // Name: to.Ptr("apimgmtst6xxxxxxxxxxx.blob.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(false), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.936Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:14.703Z"); return t}()), - // ResourceType: to.Ptr("BlobStorage"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("apimgmtst6xxxxxxxxxxx.file.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.926Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:41.532Z"); return t}()), - // ResourceType: to.Ptr("FileStorage"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("apimgmtst6xxxxxxxxxxx.queue.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.841Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:30.645Z"); return t}()), - // ResourceType: to.Ptr("Queue"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("apimgmtst6xxxxxxxxxxx.table.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(false), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.936Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:23.878Z"); return t}()), - // ResourceType: to.Ptr("TableStorage"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("gcs.prod.monitoring.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T08:07:37.548Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:57:34.866Z"); return t}()), - // ResourceType: to.Ptr("Monitoring"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("https://gcs.ppe.warm.ingestion.monitoring.azure.com"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.106Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:56:26.187Z"); return t}()), - // ResourceType: to.Ptr("Monitoring"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("https://global.metrics.nsatc.net/"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.051Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:56:35.962Z"); return t}()), - // ResourceType: to.Ptr("Monitoring"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("https://login.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.106Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:56:30.804Z"); return t}()), - // ResourceType: to.Ptr("AzureActiveDirectory"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("https://prod2.metrics.nsatc.net:1886/RecoveryService"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.279Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:56:45.209Z"); return t}()), - // ResourceType: to.Ptr("Metrics"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("LocalGatewayRedis"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.936Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:15.134Z"); return t}()), - // ResourceType: to.Ptr("InternalCache"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("prod.warmpath.msftcloudes.com"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(false), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.841Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:57.899Z"); return t}()), - // ResourceType: to.Ptr("Monitoring"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("Scm"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-20T02:25:48.706Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T23:01:24.055Z"); return t}()), - // ResourceType: to.Ptr("SourceControl"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("smtpi-ch1.msn.com:25028"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.351Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:58:22.243Z"); return t}()), - // ResourceType: to.Ptr("Email"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("zwcvuxxxx.database.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(false), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.041Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:44.358Z"); return t}()), - // ResourceType: to.Ptr("SQLDatabase"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }}, - // DNSServers: []*string{ - // to.Ptr("10.82.98.10")}, - // }, - // }} -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetNetworkStatusByLocation.json -func ExampleNetworkStatusClient_ListByLocation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNetworkStatusClient().ListByLocation(ctx, "rg1", "apimService1", "North Central US", 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.NetworkStatusContract = armapimanagement.NetworkStatusContract{ - // ConnectivityStatus: []*armapimanagement.ConnectivityStatusContract{ - // { - // Name: to.Ptr("apimgmtst6tnxxxxxxxxxxx.blob.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(false), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.936Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:14.703Z"); return t}()), - // ResourceType: to.Ptr("BlobStorage"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("apimgmtst6tnxxxxxxxxxxx.file.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.926Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:41.532Z"); return t}()), - // ResourceType: to.Ptr("FileStorage"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("apimgmtst6tnxxxxxxxxxxx.queue.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.841Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:30.645Z"); return t}()), - // ResourceType: to.Ptr("Queue"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("apimgmtst6tnxxxxxxxxxxx.table.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(false), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.936Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:23.878Z"); return t}()), - // ResourceType: to.Ptr("TableStorage"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("gcs.prod.monitoring.core.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T08:07:37.548Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:57:34.866Z"); return t}()), - // ResourceType: to.Ptr("Monitoring"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("https://gcs.ppe.warm.ingestion.monitoring.azure.com"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.106Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:56:26.187Z"); return t}()), - // ResourceType: to.Ptr("Monitoring"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("https://global.metrics.nsatc.net/"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.051Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:56:35.962Z"); return t}()), - // ResourceType: to.Ptr("Monitoring"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("https://login.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.106Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:56:30.804Z"); return t}()), - // ResourceType: to.Ptr("AzureActiveDirectory"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("https://prod2.metrics.nsatc.net:1886/RecoveryService"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.279Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:56:45.209Z"); return t}()), - // ResourceType: to.Ptr("Metrics"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("LocalGatewayRedis"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.936Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:15.134Z"); return t}()), - // ResourceType: to.Ptr("InternalCache"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("prod.warmpath.msftcloudes.com"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(false), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:55.841Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:57.899Z"); return t}()), - // ResourceType: to.Ptr("Monitoring"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("Scm"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:57.325Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T23:03:57.618Z"); return t}()), - // ResourceType: to.Ptr("SourceControl"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("smtpi-xxx.msn.com:25028"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(true), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.351Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:58:22.243Z"); return t}()), - // ResourceType: to.Ptr("Email"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }, - // { - // Name: to.Ptr("zwcvuxxxx.database.windows.net"), - // Error: to.Ptr(""), - // IsOptional: to.Ptr(false), - // LastStatusChange: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-20T07:54:56.041Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-24T22:55:44.358Z"); return t}()), - // ResourceType: to.Ptr("SQLDatabase"), - // Status: to.Ptr(armapimanagement.ConnectivityStatusTypeSuccess), - // }}, - // DNSServers: []*string{ - // to.Ptr("10.82.98.10")}, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/notification_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/notification_client.go index bbc44a1aa4cd..0faf04ebd66a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/notification_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/notification_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type NotificationClient struct { } // NewNotificationClient creates a new instance of NotificationClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewNotificationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NotificationClient, error) { @@ -47,7 +44,7 @@ func NewNotificationClient(subscriptionID string, credential azcore.TokenCredent // CreateOrUpdate - Create or Update API Management publisher notification. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -99,12 +96,12 @@ func (client *NotificationClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -120,7 +117,7 @@ func (client *NotificationClient) createOrUpdateHandleResponse(resp *http.Respon // Get - Gets the details of the Notification specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -148,7 +145,7 @@ func (client *NotificationClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *NotificationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationClientGetOptions) (*policy.Request, error) { +func (client *NotificationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, _ *NotificationClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -171,7 +168,7 @@ func (client *NotificationClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -188,7 +185,7 @@ func (client *NotificationClient) getHandleResponse(resp *http.Response) (Notifi // NewListByServicePager - Lists a collection of properties defined within a service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - NotificationClientListByServiceOptions contains the optional parameters for the NotificationClient.NewListByServicePager @@ -236,13 +233,13 @@ func (client *NotificationClient) listByServiceCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/notification_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/notification_client_example_test.go deleted file mode 100644 index d211919473d4..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/notification_client_example_test.go +++ /dev/null @@ -1,230 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListNotifications.json -func ExampleNotificationClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewNotificationClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.NotificationClientListByServiceOptions{Top: nil, - Skip: 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.NotificationCollection = armapimanagement.NotificationCollection{ - // Count: to.Ptr[int64](7), - // Value: []*armapimanagement.NotificationContract{ - // { - // Name: to.Ptr("RequestPublisherNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage"), - // Properties: &armapimanagement.NotificationContractProperties{ - // Description: to.Ptr("The following email recipients and users will receive email notifications about subscription requests for API products requiring approval."), - // Recipients: &armapimanagement.RecipientsContractProperties{ - // Emails: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/contoso@live.com"), - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/foobar!live"), - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/foobar@live.com")}, - // Users: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/576823d0a40f7e74ec07d642")}, - // }, - // Title: to.Ptr("Subscription requests (requiring approval)"), - // }, - // }, - // { - // Name: to.Ptr("PurchasePublisherNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/PurchasePublisherNotificationMessage"), - // Properties: &armapimanagement.NotificationContractProperties{ - // Description: to.Ptr("The following email recipients and users will receive email notifications about new API product subscriptions."), - // Recipients: &armapimanagement.RecipientsContractProperties{ - // Emails: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/contoso@live.com")}, - // Users: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1")}, - // }, - // Title: to.Ptr("New subscriptions"), - // }, - // }, - // { - // Name: to.Ptr("NewApplicationNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/NewApplicationNotificationMessage"), - // Properties: &armapimanagement.NotificationContractProperties{ - // Description: to.Ptr("The following email recipients and users will receive email notifications when new applications are submitted to the application gallery."), - // Recipients: &armapimanagement.RecipientsContractProperties{ - // Emails: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/contoso@live.com")}, - // Users: []*string{ - // }, - // }, - // Title: to.Ptr("Application gallery requests"), - // }, - // }, - // { - // Name: to.Ptr("BCC"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/BCC"), - // Properties: &armapimanagement.NotificationContractProperties{ - // Description: to.Ptr("The following recipients will receive blind carbon copies of all emails sent to developers."), - // Recipients: &armapimanagement.RecipientsContractProperties{ - // Emails: []*string{ - // }, - // Users: []*string{ - // }, - // }, - // Title: to.Ptr("BCC"), - // }, - // }, - // { - // Name: to.Ptr("NewIssuePublisherNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/NewIssuePublisherNotificationMessage"), - // Properties: &armapimanagement.NotificationContractProperties{ - // Description: to.Ptr("The following email recipients and users will receive email notifications when a new issue or comment is submitted on the developer portal."), - // Recipients: &armapimanagement.RecipientsContractProperties{ - // Emails: []*string{ - // }, - // Users: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1")}, - // }, - // Title: to.Ptr("New issue or comment"), - // }, - // }, - // { - // Name: to.Ptr("AccountClosedPublisher"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/AccountClosedPublisher"), - // Properties: &armapimanagement.NotificationContractProperties{ - // Description: to.Ptr("The following email recipients and users will receive email notifications when developer closes his account"), - // Recipients: &armapimanagement.RecipientsContractProperties{ - // Emails: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/contoso@live.com")}, - // Users: []*string{ - // }, - // }, - // Title: to.Ptr("Close account message"), - // }, - // }, - // { - // Name: to.Ptr("QuotaLimitApproachingPublisherNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/QuotaLimitApproachingPublisherNotificationMessage"), - // Properties: &armapimanagement.NotificationContractProperties{ - // Description: to.Ptr("The following email recipients and users will receive email notifications when subscription usage gets close to usage quota."), - // Recipients: &armapimanagement.RecipientsContractProperties{ - // Emails: []*string{ - // }, - // Users: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1")}, - // }, - // Title: to.Ptr("Approaching subscription quota limit"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetNotification.json -func ExampleNotificationClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNotificationClient().Get(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, 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.NotificationContract = armapimanagement.NotificationContract{ - // Name: to.Ptr("RequestPublisherNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage"), - // Properties: &armapimanagement.NotificationContractProperties{ - // Description: to.Ptr("The following email recipients and users will receive email notifications about subscription requests for API products requiring approval."), - // Recipients: &armapimanagement.RecipientsContractProperties{ - // Emails: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/recipientEmails/contoso@live.com"), - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/recipientEmails/foobar!live"), - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/recipientEmails/foobar@live.com")}, - // Users: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/576823d0a40f7e74ec07d642")}, - // }, - // Title: to.Ptr("Subscription requests (requiring approval)"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNotification.json -func ExampleNotificationClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNotificationClient().CreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, &armapimanagement.NotificationClientCreateOrUpdateOptions{IfMatch: 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.NotificationContract = armapimanagement.NotificationContract{ - // Name: to.Ptr("RequestPublisherNotificationMessage"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage"), - // Properties: &armapimanagement.NotificationContractProperties{ - // Description: to.Ptr("The following email recipients and users will receive email notifications about subscription requests for API products requiring approval."), - // Recipients: &armapimanagement.RecipientsContractProperties{ - // Emails: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/recipientEmails/contoso@live.com"), - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/recipientEmails/foobar!live"), - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/recipientEmails/foobar@live.com")}, - // Users: []*string{ - // to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/576823d0a40f7e74ec07d642")}, - // }, - // Title: to.Ptr("Subscription requests (requiring approval)"), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientemail_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientemail_client.go index 96783e9b0ec9..5a7d129c3457 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientemail_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientemail_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type NotificationRecipientEmailClient struct { } // NewNotificationRecipientEmailClient creates a new instance of NotificationRecipientEmailClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewNotificationRecipientEmailClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NotificationRecipientEmailClient, error) { @@ -45,7 +42,7 @@ func NewNotificationRecipientEmailClient(subscriptionID string, credential azcor // CheckEntityExists - Determine if Notification Recipient Email subscribed to the notification. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -74,7 +71,7 @@ func (client *NotificationRecipientEmailClient) CheckEntityExists(ctx context.Co } // checkEntityExistsCreateRequest creates the CheckEntityExists request. -func (client *NotificationRecipientEmailClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailClientCheckEntityExistsOptions) (*policy.Request, error) { +func (client *NotificationRecipientEmailClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, _ *NotificationRecipientEmailClientCheckEntityExistsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -101,7 +98,7 @@ func (client *NotificationRecipientEmailClient) checkEntityExistsCreateRequest(c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -110,7 +107,7 @@ func (client *NotificationRecipientEmailClient) checkEntityExistsCreateRequest(c // CreateOrUpdate - Adds the Email address to the list of Recipients for the Notification. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -140,7 +137,7 @@ func (client *NotificationRecipientEmailClient) CreateOrUpdate(ctx context.Conte } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *NotificationRecipientEmailClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *NotificationRecipientEmailClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, _ *NotificationRecipientEmailClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -167,7 +164,7 @@ func (client *NotificationRecipientEmailClient) createOrUpdateCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -185,7 +182,7 @@ func (client *NotificationRecipientEmailClient) createOrUpdateHandleResponse(res // Delete - Removes the email from the list of Notification. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -214,7 +211,7 @@ func (client *NotificationRecipientEmailClient) Delete(ctx context.Context, reso } // deleteCreateRequest creates the Delete request. -func (client *NotificationRecipientEmailClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailClientDeleteOptions) (*policy.Request, error) { +func (client *NotificationRecipientEmailClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, _ *NotificationRecipientEmailClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -241,7 +238,7 @@ func (client *NotificationRecipientEmailClient) deleteCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -250,7 +247,7 @@ func (client *NotificationRecipientEmailClient) deleteCreateRequest(ctx context. // ListByNotification - Gets the list of the Notification Recipient Emails subscribed to a notification. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -279,7 +276,7 @@ func (client *NotificationRecipientEmailClient) ListByNotification(ctx context.C } // listByNotificationCreateRequest creates the ListByNotification request. -func (client *NotificationRecipientEmailClient) listByNotificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationRecipientEmailClientListByNotificationOptions) (*policy.Request, error) { +func (client *NotificationRecipientEmailClient) listByNotificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, _ *NotificationRecipientEmailClientListByNotificationOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -302,7 +299,7 @@ func (client *NotificationRecipientEmailClient) listByNotificationCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientemail_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientemail_client_example_test.go deleted file mode 100644 index e063db06f7bc..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientemail_client_example_test.go +++ /dev/null @@ -1,128 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListNotificationRecipientEmails.json -func ExampleNotificationRecipientEmailClient_ListByNotification() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNotificationRecipientEmailClient().ListByNotification(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, 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.RecipientEmailCollection = armapimanagement.RecipientEmailCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.RecipientEmailContract{ - // { - // Name: to.Ptr("contoso@live.com"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications/recipientEmails"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/contoso@live.com"), - // Properties: &armapimanagement.RecipientEmailContractProperties{ - // Email: to.Ptr("contoso@live.com"), - // }, - // }, - // { - // Name: to.Ptr("foobar!live"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications/recipientEmails"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/foobar!live"), - // Properties: &armapimanagement.RecipientEmailContractProperties{ - // Email: to.Ptr("foobar!live"), - // }, - // }, - // { - // Name: to.Ptr("foobar@live.com"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications/recipientEmails"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/foobar@live.com"), - // Properties: &armapimanagement.RecipientEmailContractProperties{ - // Email: to.Ptr("foobar@live.com"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadNotificationRecipientEmail.json -func ExampleNotificationRecipientEmailClient_CheckEntityExists() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewNotificationRecipientEmailClient().CheckEntityExists(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, "contoso@live.com", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNotificationRecipientEmail.json -func ExampleNotificationRecipientEmailClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNotificationRecipientEmailClient().CreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, "foobar@live.com", 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.RecipientEmailContract = armapimanagement.RecipientEmailContract{ - // Name: to.Ptr("foobar@live.com"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications/recipientEmails"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientEmails/foobar@live.com"), - // Properties: &armapimanagement.RecipientEmailContractProperties{ - // Email: to.Ptr("foobar@live.com"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteNotificationRecipientEmail.json -func ExampleNotificationRecipientEmailClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewNotificationRecipientEmailClient().Delete(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, "contoso@live.com", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientuser_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientuser_client.go index 139a2bc2ae80..c53d07789b3b 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientuser_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientuser_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type NotificationRecipientUserClient struct { } // NewNotificationRecipientUserClient creates a new instance of NotificationRecipientUserClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewNotificationRecipientUserClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NotificationRecipientUserClient, error) { @@ -45,7 +42,7 @@ func NewNotificationRecipientUserClient(subscriptionID string, credential azcore // CheckEntityExists - Determine if the Notification Recipient User is subscribed to the notification. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -74,7 +71,7 @@ func (client *NotificationRecipientUserClient) CheckEntityExists(ctx context.Con } // checkEntityExistsCreateRequest creates the CheckEntityExists request. -func (client *NotificationRecipientUserClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, options *NotificationRecipientUserClientCheckEntityExistsOptions) (*policy.Request, error) { +func (client *NotificationRecipientUserClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, _ *NotificationRecipientUserClientCheckEntityExistsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -101,7 +98,7 @@ func (client *NotificationRecipientUserClient) checkEntityExistsCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -110,7 +107,7 @@ func (client *NotificationRecipientUserClient) checkEntityExistsCreateRequest(ct // CreateOrUpdate - Adds the API Management User to the list of Recipients for the Notification. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -140,7 +137,7 @@ func (client *NotificationRecipientUserClient) CreateOrUpdate(ctx context.Contex } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *NotificationRecipientUserClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, options *NotificationRecipientUserClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *NotificationRecipientUserClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, _ *NotificationRecipientUserClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -167,7 +164,7 @@ func (client *NotificationRecipientUserClient) createOrUpdateCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -185,7 +182,7 @@ func (client *NotificationRecipientUserClient) createOrUpdateHandleResponse(resp // Delete - Removes the API Management user from the list of Notification. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -214,7 +211,7 @@ func (client *NotificationRecipientUserClient) Delete(ctx context.Context, resou } // deleteCreateRequest creates the Delete request. -func (client *NotificationRecipientUserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, options *NotificationRecipientUserClientDeleteOptions) (*policy.Request, error) { +func (client *NotificationRecipientUserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, _ *NotificationRecipientUserClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -241,7 +238,7 @@ func (client *NotificationRecipientUserClient) deleteCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -250,7 +247,7 @@ func (client *NotificationRecipientUserClient) deleteCreateRequest(ctx context.C // ListByNotification - Gets the list of the Notification Recipient User subscribed to the notification. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - notificationName - Notification Name Identifier. @@ -279,7 +276,7 @@ func (client *NotificationRecipientUserClient) ListByNotification(ctx context.Co } // listByNotificationCreateRequest creates the ListByNotification request. -func (client *NotificationRecipientUserClient) listByNotificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationRecipientUserClientListByNotificationOptions) (*policy.Request, error) { +func (client *NotificationRecipientUserClient) listByNotificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, _ *NotificationRecipientUserClientListByNotificationOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -302,7 +299,7 @@ func (client *NotificationRecipientUserClient) listByNotificationCreateRequest(c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientuser_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientuser_client_example_test.go deleted file mode 100644 index e36a048ed0c0..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/notificationrecipientuser_client_example_test.go +++ /dev/null @@ -1,112 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListNotificationRecipientUsers.json -func ExampleNotificationRecipientUserClient_ListByNotification() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNotificationRecipientUserClient().ListByNotification(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, 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.RecipientUserCollection = armapimanagement.RecipientUserCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.RecipientUserContract{ - // { - // Name: to.Ptr("576823d0a40f7e74ec07d642"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications/recipientUsers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientUsers/576823d0a40f7e74ec07d642"), - // Properties: &armapimanagement.RecipientUsersContractProperties{ - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/576823d0a40f7e74ec07d642"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadNotificationRecipientUser.json -func ExampleNotificationRecipientUserClient_CheckEntityExists() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewNotificationRecipientUserClient().CheckEntityExists(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, "576823d0a40f7e74ec07d642", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateNotificationRecipientUser.json -func ExampleNotificationRecipientUserClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewNotificationRecipientUserClient().CreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, "576823d0a40f7e74ec07d642", 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.RecipientUserContract = armapimanagement.RecipientUserContract{ - // Name: to.Ptr("576823d0a40f7e74ec07d642"), - // Type: to.Ptr("Microsoft.ApiManagement/service/notifications/recipientUsers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/notifications/RequestPublisherNotificationMessage/recipientUsers/576823d0a40f7e74ec07d642"), - // Properties: &armapimanagement.RecipientUsersContractProperties{ - // UserID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/576823d0a40f7e74ec07d642"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteNotificationRecipientUser.json -func ExampleNotificationRecipientUserClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewNotificationRecipientUserClient().Delete(ctx, "rg1", "apimService1", armapimanagement.NotificationNameRequestPublisherNotificationMessage, "576823d0a40f7e74ec07d642", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/openidconnectprovider_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/openidconnectprovider_client.go index b8867e5b9f78..26ce7611f786 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/openidconnectprovider_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/openidconnectprovider_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type OpenIDConnectProviderClient struct { } // NewOpenIDConnectProviderClient creates a new instance of OpenIDConnectProviderClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewOpenIDConnectProviderClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OpenIDConnectProviderClient, error) { @@ -47,7 +44,7 @@ func NewOpenIDConnectProviderClient(subscriptionID string, credential azcore.Tok // CreateOrUpdate - Creates or updates the OpenID Connect Provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - opid - Identifier of the OpenID Connect Provider. @@ -100,12 +97,12 @@ func (client *OpenIDConnectProviderClient) createOrUpdateCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -127,7 +124,7 @@ func (client *OpenIDConnectProviderClient) createOrUpdateHandleResponse(resp *ht // Delete - Deletes specific OpenID Connect Provider of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - opid - Identifier of the OpenID Connect Provider. @@ -157,7 +154,7 @@ func (client *OpenIDConnectProviderClient) Delete(ctx context.Context, resourceG } // deleteCreateRequest creates the Delete request. -func (client *OpenIDConnectProviderClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string, options *OpenIDConnectProviderClientDeleteOptions) (*policy.Request, error) { +func (client *OpenIDConnectProviderClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string, _ *OpenIDConnectProviderClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -180,17 +177,17 @@ func (client *OpenIDConnectProviderClient) deleteCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets specific OpenID Connect Provider without secrets. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - opid - Identifier of the OpenID Connect Provider. @@ -219,7 +216,7 @@ func (client *OpenIDConnectProviderClient) Get(ctx context.Context, resourceGrou } // getCreateRequest creates the Get request. -func (client *OpenIDConnectProviderClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, options *OpenIDConnectProviderClientGetOptions) (*policy.Request, error) { +func (client *OpenIDConnectProviderClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, _ *OpenIDConnectProviderClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -242,7 +239,7 @@ func (client *OpenIDConnectProviderClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -262,7 +259,7 @@ func (client *OpenIDConnectProviderClient) getHandleResponse(resp *http.Response // GetEntityTag - Gets the entity state (Etag) version of the openIdConnectProvider specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - opid - Identifier of the OpenID Connect Provider. @@ -291,7 +288,7 @@ func (client *OpenIDConnectProviderClient) GetEntityTag(ctx context.Context, res } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *OpenIDConnectProviderClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, options *OpenIDConnectProviderClientGetEntityTagOptions) (*policy.Request, error) { +func (client *OpenIDConnectProviderClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, _ *OpenIDConnectProviderClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -314,7 +311,7 @@ func (client *OpenIDConnectProviderClient) getEntityTagCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -331,7 +328,7 @@ func (client *OpenIDConnectProviderClient) getEntityTagHandleResponse(resp *http // NewListByServicePager - Lists of all the OpenId Connect Providers. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - OpenIDConnectProviderClientListByServiceOptions contains the optional parameters for the OpenIDConnectProviderClient.NewListByServicePager @@ -382,13 +379,13 @@ func (client *OpenIDConnectProviderClient) listByServiceCreateRequest(ctx contex if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -406,7 +403,7 @@ func (client *OpenIDConnectProviderClient) listByServiceHandleResponse(resp *htt // ListSecrets - Gets the client secret details of the OpenID Connect Provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - opid - Identifier of the OpenID Connect Provider. @@ -435,7 +432,7 @@ func (client *OpenIDConnectProviderClient) ListSecrets(ctx context.Context, reso } // listSecretsCreateRequest creates the ListSecrets request. -func (client *OpenIDConnectProviderClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, options *OpenIDConnectProviderClientListSecretsOptions) (*policy.Request, error) { +func (client *OpenIDConnectProviderClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, _ *OpenIDConnectProviderClientListSecretsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -458,7 +455,7 @@ func (client *OpenIDConnectProviderClient) listSecretsCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -479,7 +476,7 @@ func (client *OpenIDConnectProviderClient) listSecretsHandleResponse(resp *http. // Update - Updates the specific OpenID Connect Provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - opid - Identifier of the OpenID Connect Provider. @@ -511,7 +508,7 @@ func (client *OpenIDConnectProviderClient) Update(ctx context.Context, resourceG } // updateCreateRequest creates the Update request. -func (client *OpenIDConnectProviderClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string, parameters OpenidConnectProviderUpdateContract, options *OpenIDConnectProviderClientUpdateOptions) (*policy.Request, error) { +func (client *OpenIDConnectProviderClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string, parameters OpenidConnectProviderUpdateContract, _ *OpenIDConnectProviderClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -534,10 +531,10 @@ func (client *OpenIDConnectProviderClient) updateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/openidconnectprovider_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/openidconnectprovider_client_example_test.go deleted file mode 100644 index 5da175eac161..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/openidconnectprovider_client_example_test.go +++ /dev/null @@ -1,234 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListOpenIdConnectProviders.json -func ExampleOpenIDConnectProviderClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOpenIDConnectProviderClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.OpenIDConnectProviderClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.OpenIDConnectProviderCollection = armapimanagement.OpenIDConnectProviderCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.OpenidConnectProviderContract{ - // { - // Name: to.Ptr("templateOpenIdConnect2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/openidconnectproviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/openidConnectProviders/templateOpenIdConnect2"), - // Properties: &armapimanagement.OpenidConnectProviderContractProperties{ - // Description: to.Ptr("open id provider template2"), - // ClientID: to.Ptr("oidprovidertemplate2"), - // DisplayName: to.Ptr("templateoidprovider2"), - // MetadataEndpoint: to.Ptr("https://oidprovider-template2.net"), - // UseInAPIDocumentation: to.Ptr(true), - // UseInTestConsole: to.Ptr(false), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadOpenIdConnectProvider.json -func ExampleOpenIDConnectProviderClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewOpenIDConnectProviderClient().GetEntityTag(ctx, "rg1", "apimService1", "templateOpenIdConnect2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetOpenIdConnectProvider.json -func ExampleOpenIDConnectProviderClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOpenIDConnectProviderClient().Get(ctx, "rg1", "apimService1", "templateOpenIdConnect2", 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.OpenidConnectProviderContract = armapimanagement.OpenidConnectProviderContract{ - // Name: to.Ptr("templateOpenIdConnect2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/openidconnectproviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/openidConnectProviders/templateOpenIdConnect2"), - // Properties: &armapimanagement.OpenidConnectProviderContractProperties{ - // Description: to.Ptr("open id provider template2"), - // ClientID: to.Ptr("oidprovidertemplate2"), - // DisplayName: to.Ptr("templateoidprovider2"), - // MetadataEndpoint: to.Ptr("https://oidprovider-template2.net"), - // UseInAPIDocumentation: to.Ptr(true), - // UseInTestConsole: to.Ptr(false), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateOpenIdConnectProvider.json -func ExampleOpenIDConnectProviderClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOpenIDConnectProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", "templateOpenIdConnect3", armapimanagement.OpenidConnectProviderContract{ - Properties: &armapimanagement.OpenidConnectProviderContractProperties{ - ClientID: to.Ptr("oidprovidertemplate3"), - ClientSecret: to.Ptr("x"), - DisplayName: to.Ptr("templateoidprovider3"), - MetadataEndpoint: to.Ptr("https://oidprovider-template3.net"), - UseInAPIDocumentation: to.Ptr(true), - UseInTestConsole: to.Ptr(false), - }, - }, &armapimanagement.OpenIDConnectProviderClientCreateOrUpdateOptions{IfMatch: 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.OpenidConnectProviderContract = armapimanagement.OpenidConnectProviderContract{ - // Name: to.Ptr("templateOpenIdConnect3"), - // Type: to.Ptr("Microsoft.ApiManagement/service/openidconnectproviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/openidConnectProviders/templateOpenIdConnect3"), - // Properties: &armapimanagement.OpenidConnectProviderContractProperties{ - // ClientID: to.Ptr("oidprovidertemplate3"), - // DisplayName: to.Ptr("templateoidprovider3"), - // MetadataEndpoint: to.Ptr("https://oidprovider-template3.net"), - // UseInAPIDocumentation: to.Ptr(true), - // UseInTestConsole: to.Ptr(false), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateOpenIdConnectProvider.json -func ExampleOpenIDConnectProviderClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOpenIDConnectProviderClient().Update(ctx, "rg1", "apimService1", "templateOpenIdConnect2", "*", armapimanagement.OpenidConnectProviderUpdateContract{ - Properties: &armapimanagement.OpenidConnectProviderUpdateContractProperties{ - ClientSecret: to.Ptr("updatedsecret"), - UseInAPIDocumentation: to.Ptr(true), - UseInTestConsole: to.Ptr(false), - }, - }, 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.OpenidConnectProviderContract = armapimanagement.OpenidConnectProviderContract{ - // Name: to.Ptr("templateOpenIdConnect2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/openidconnectproviders"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/openidConnectProviders/templateOpenIdConnect2"), - // Properties: &armapimanagement.OpenidConnectProviderContractProperties{ - // Description: to.Ptr("open id provider template2"), - // ClientID: to.Ptr("oidprovidertemplate2"), - // DisplayName: to.Ptr("templateoidprovider2"), - // MetadataEndpoint: to.Ptr("https://oidprovider-template2.net"), - // UseInAPIDocumentation: to.Ptr(true), - // UseInTestConsole: to.Ptr(false), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteOpenIdConnectProvider.json -func ExampleOpenIDConnectProviderClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewOpenIDConnectProviderClient().Delete(ctx, "rg1", "apimService1", "templateOpenIdConnect3", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementOpenidConnectProviderListSecrets.json -func ExampleOpenIDConnectProviderClient_ListSecrets() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOpenIDConnectProviderClient().ListSecrets(ctx, "rg1", "apimService1", "templateOpenIdConnect2", 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.ClientSecretContract = armapimanagement.ClientSecretContract{ - // ClientSecret: to.Ptr("oidsecretproviderTemplate2"), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/operation_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/operation_client.go index c1c52a5af120..932f85d3e0a8 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/operation_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/operation_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type OperationClient struct { } // NewOperationClient creates a new instance of OperationClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewOperationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationClient, error) { @@ -46,7 +43,7 @@ func NewOperationClient(subscriptionID string, credential azcore.TokenCredential // NewListByTagsPager - Lists a collection of operations associated with tags. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -103,16 +100,16 @@ func (client *OperationClient) listByTagsCreateRequest(ctx context.Context, reso if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.IncludeNotTaggedOperations != nil { reqQP.Set("includeNotTaggedOperations", strconv.FormatBool(*options.IncludeNotTaggedOperations)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/operation_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/operation_client_example_test.go deleted file mode 100644 index 7ac557ba31f3..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/operation_client_example_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiOperationsByTags.json -func ExampleOperationClient_NewListByTagsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationClient().NewListByTagsPager("rg1", "apimService1", "a1", &armapimanagement.OperationClientListByTagsOptions{Filter: nil, - Top: nil, - Skip: nil, - IncludeNotTaggedOperations: 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.TagResourceCollection = armapimanagement.TagResourceCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.TagResourceContract{ - // { - // Operation: &armapimanagement.OperationTagResourceContractProperties{ - // Name: to.Ptr("Create resource"), - // Method: to.Ptr("POST"), - // Description: to.Ptr("A demonstration of a POST call based on the echo backend above. The request body is expected to contain JSON-formatted data (see example below). A policy is used to automatically transform any request sent in JSON directly to XML. In a real-world scenario this could be used to enable modern clients to speak to a legacy backend."), - // APIName: to.Ptr("Echo API"), - // APIRevision: to.Ptr("1"), - // ID: to.Ptr("/apis/echo-api/operations/create-resource"), - // URLTemplate: to.Ptr("/resource"), - // }, - // Tag: &armapimanagement.TagResourceContractProperties{ - // Name: to.Ptr("awesomeTag"), - // ID: to.Ptr("/tags/apitag123"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/operations_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/operations_client.go index 03380445517d..eae9cdd97f10 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/operations_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/operations_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -39,7 +36,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all of the available REST API operations of the Microsoft.ApiManagement provider. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-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]{ @@ -65,14 +62,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.ApiManagement/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/operations_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/operations_client_example_test.go deleted file mode 100644 index dc0437cab70b..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/operations_client_example_test.go +++ /dev/null @@ -1,92 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListOperations.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 := armapimanagement.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 = armapimanagement.OperationListResult{ - // Value: []*armapimanagement.Operation{ - // { - // Name: to.Ptr("Microsoft.ApiManagement/service/write"), - // Display: &armapimanagement.OperationDisplay{ - // Description: to.Ptr("Create a new instance of API Management Service"), - // Operation: to.Ptr("Create a new instance of API Management Service"), - // Provider: to.Ptr("Microsoft API Management"), - // Resource: to.Ptr("Service"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ApiManagement/service/read"), - // Display: &armapimanagement.OperationDisplay{ - // Description: to.Ptr("Read metadata for an API Management Service instance"), - // Operation: to.Ptr("Read metadata for an API Management Service instance"), - // Provider: to.Ptr("Microsoft API Management"), - // Resource: to.Ptr("Service"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ApiManagement/service/delete"), - // Display: &armapimanagement.OperationDisplay{ - // Description: to.Ptr("Delete API Management Service instance"), - // Operation: to.Ptr("Delete API Management Service instance"), - // Provider: to.Ptr("Microsoft API Management"), - // Resource: to.Ptr("Service"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ApiManagement/service/providers/Microsoft.Insights/diagnosticSettings/write"), - // Display: &armapimanagement.OperationDisplay{ - // Description: to.Ptr("Creates or updates the diagnostic setting for API Management service"), - // Operation: to.Ptr("Write diagnostic setting"), - // Provider: to.Ptr("Microsoft API Management"), - // Resource: to.Ptr("Service"), - // }, - // Origin: to.Ptr("system"), - // }, - // { - // Name: to.Ptr("Microsoft.ApiManagement/service/tenant/operationResults/read"), - // Display: &armapimanagement.OperationDisplay{ - // Description: to.Ptr("Get list of operation results or Get result of a specific operation"), - // Operation: to.Ptr("Get operation results or Get operation result"), - // Provider: to.Ptr("Microsoft API Management"), - // Resource: to.Ptr("Results of async operations"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/operationsresults_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/operationsresults_client.go new file mode 100644 index 000000000000..0a8a8eddefdb --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/operationsresults_client.go @@ -0,0 +1,105 @@ +// 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 armapimanagement + +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" +) + +// OperationsResultsClient contains the methods for the OperationsResults group. +// Don't use this type directly, use NewOperationsResultsClient() instead. +type OperationsResultsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewOperationsResultsClient creates a new instance of OperationsResultsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsResultsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsResultsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Returns operation results for long running operations executing DELETE or PATCH on the resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - location - The name of the Azure region. +// - operationID - The ID of an ongoing async operation. +// - options - OperationsResultsClientGetOptions contains the optional parameters for the OperationsResultsClient.Get method. +func (client *OperationsResultsClient) Get(ctx context.Context, location string, operationID string, options *OperationsResultsClientGetOptions) (OperationsResultsClientGetResponse, error) { + var err error + const operationName = "OperationsResultsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, location, operationID, options) + if err != nil { + return OperationsResultsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OperationsResultsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return OperationsResultsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *OperationsResultsClient) getCreateRequest(ctx context.Context, location string, operationID string, _ *OperationsResultsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/operationResults/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationsResultsClient) getHandleResponse(resp *http.Response) (OperationsResultsClientGetResponse, error) { + result := OperationsResultsClientGetResponse{} + if val := resp.Header.Get("Location"); val != "" { + result.Location = &val + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/operationstatus_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/operationstatus_client.go new file mode 100644 index 000000000000..816546f46750 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/operationstatus_client.go @@ -0,0 +1,105 @@ +// 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 armapimanagement + +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" +) + +// OperationStatusClient contains the methods for the OperationStatus group. +// Don't use this type directly, use NewOperationStatusClient() instead. +type OperationStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewOperationStatusClient creates a new instance of OperationStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationStatusClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Returns the current status of an async operation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - location - The name of the Azure region. +// - operationID - The ID of an ongoing async operation. +// - options - OperationStatusClientGetOptions contains the optional parameters for the OperationStatusClient.Get method. +func (client *OperationStatusClient) Get(ctx context.Context, location string, operationID string, options *OperationStatusClientGetOptions) (OperationStatusClientGetResponse, error) { + var err error + const operationName = "OperationStatusClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, location, operationID, options) + if err != nil { + return OperationStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OperationStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OperationStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *OperationStatusClient) getCreateRequest(ctx context.Context, location string, operationID string, _ *OperationStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/operationStatuses/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationStatusClient) getHandleResponse(resp *http.Response) (OperationStatusClientGetResponse, error) { + result := OperationStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatusResult); err != nil { + return OperationStatusClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/options.go b/sdk/resourcemanager/apimanagement/armapimanagement/options.go index 5cc2f1ddc18b..7933b118a7a4 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/options.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/options.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -13,14 +10,17 @@ type APIClientBeginCreateOrUpdateOptions struct { // ETag of the Entity. Not required when creating an entity, but required when updating an entity. IfMatch *string - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } -// APIClientDeleteOptions contains the optional parameters for the APIClient.Delete method. -type APIClientDeleteOptions struct { +// APIClientBeginDeleteOptions contains the optional parameters for the APIClient.BeginDelete method. +type APIClientBeginDeleteOptions struct { // Delete all revisions of the Api. DeleteRevisions *bool + + // Resumes the long-running operation from the provided token. + ResumeToken string } // APIClientGetEntityTagOptions contains the optional parameters for the APIClient.GetEntityTag method. @@ -132,6 +132,67 @@ type APIExportClientGetOptions struct { // placeholder for future optional parameters } +// APIGatewayClientBeginCreateOrUpdateOptions contains the optional parameters for the APIGatewayClient.BeginCreateOrUpdate +// method. +type APIGatewayClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// APIGatewayClientBeginDeleteOptions contains the optional parameters for the APIGatewayClient.BeginDelete method. +type APIGatewayClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// APIGatewayClientBeginUpdateOptions contains the optional parameters for the APIGatewayClient.BeginUpdate method. +type APIGatewayClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// APIGatewayClientGetOptions contains the optional parameters for the APIGatewayClient.Get method. +type APIGatewayClientGetOptions struct { + // placeholder for future optional parameters +} + +// APIGatewayClientListByResourceGroupOptions contains the optional parameters for the APIGatewayClient.NewListByResourceGroupPager +// method. +type APIGatewayClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// APIGatewayClientListOptions contains the optional parameters for the APIGatewayClient.NewListPager method. +type APIGatewayClientListOptions struct { + // placeholder for future optional parameters +} + +// APIGatewayConfigConnectionClientBeginCreateOrUpdateOptions contains the optional parameters for the APIGatewayConfigConnectionClient.BeginCreateOrUpdate +// method. +type APIGatewayConfigConnectionClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// APIGatewayConfigConnectionClientBeginDeleteOptions contains the optional parameters for the APIGatewayConfigConnectionClient.BeginDelete +// method. +type APIGatewayConfigConnectionClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// APIGatewayConfigConnectionClientGetOptions contains the optional parameters for the APIGatewayConfigConnectionClient.Get +// method. +type APIGatewayConfigConnectionClientGetOptions struct { + // placeholder for future optional parameters +} + +// APIGatewayConfigConnectionClientListByGatewayOptions contains the optional parameters for the APIGatewayConfigConnectionClient.NewListByGatewayPager +// method. +type APIGatewayConfigConnectionClientListByGatewayOptions struct { + // placeholder for future optional parameters +} + // APIIssueAttachmentClientCreateOrUpdateOptions contains the optional parameters for the APIIssueAttachmentClient.CreateOrUpdate // method. type APIIssueAttachmentClientCreateOrUpdateOptions struct { @@ -434,7 +495,7 @@ type APISchemaClientBeginCreateOrUpdateOptions struct { // ETag of the Entity. Not required when creating an entity, but required when updating an entity. IfMatch *string - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -587,6 +648,12 @@ type APIWikisClientListOptions struct { Top *int32 } +// AllPoliciesClientListByServiceOptions contains the optional parameters for the AllPoliciesClient.NewListByServicePager +// method. +type AllPoliciesClientListByServiceOptions struct { + // placeholder for future optional parameters +} + // AuthorizationAccessPolicyClientCreateOrUpdateOptions contains the optional parameters for the AuthorizationAccessPolicyClient.CreateOrUpdate // method. type AuthorizationAccessPolicyClientCreateOrUpdateOptions struct { @@ -881,7 +948,7 @@ type CertificateClientRefreshSecretOptions struct { // ClientBeginPerformConnectivityCheckAsyncOptions contains the optional parameters for the Client.BeginPerformConnectivityCheckAsync // method. type ClientBeginPerformConnectivityCheckAsyncOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -965,7 +1032,7 @@ type DelegationSettingsClientUpdateOptions struct { // DeletedServicesClientBeginPurgeOptions contains the optional parameters for the DeletedServicesClient.BeginPurge method. type DeletedServicesClientBeginPurgeOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -1197,6 +1264,12 @@ type GatewayClientGetOptions struct { // placeholder for future optional parameters } +// GatewayClientInvalidateDebugCredentialsOptions contains the optional parameters for the GatewayClient.InvalidateDebugCredentials +// method. +type GatewayClientInvalidateDebugCredentialsOptions struct { + // placeholder for future optional parameters +} + // GatewayClientListByServiceOptions contains the optional parameters for the GatewayClient.NewListByServicePager method. type GatewayClientListByServiceOptions struct { // | Field | Usage | Supported operators | Supported functions | @@ -1213,11 +1286,21 @@ type GatewayClientListByServiceOptions struct { Top *int32 } +// GatewayClientListDebugCredentialsOptions contains the optional parameters for the GatewayClient.ListDebugCredentials method. +type GatewayClientListDebugCredentialsOptions struct { + // placeholder for future optional parameters +} + // GatewayClientListKeysOptions contains the optional parameters for the GatewayClient.ListKeys method. type GatewayClientListKeysOptions struct { // placeholder for future optional parameters } +// GatewayClientListTraceOptions contains the optional parameters for the GatewayClient.ListTrace method. +type GatewayClientListTraceOptions struct { + // placeholder for future optional parameters +} + // GatewayClientRegenerateKeyOptions contains the optional parameters for the GatewayClient.RegenerateKey method. type GatewayClientRegenerateKeyOptions struct { // placeholder for future optional parameters @@ -1269,13 +1352,19 @@ type GatewayHostnameConfigurationClientListByServiceOptions struct { Top *int32 } +// GatewaySKUsClientListAvailableSKUsOptions contains the optional parameters for the GatewaySKUsClient.NewListAvailableSKUsPager +// method. +type GatewaySKUsClientListAvailableSKUsOptions struct { + // placeholder for future optional parameters +} + // GlobalSchemaClientBeginCreateOrUpdateOptions contains the optional parameters for the GlobalSchemaClient.BeginCreateOrUpdate // method. type GlobalSchemaClientBeginCreateOrUpdateOptions struct { // ETag of the Entity. Not required when creating an entity, but required when updating an entity. IfMatch *string - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -1575,20 +1664,20 @@ type NamedValueClientBeginCreateOrUpdateOptions struct { // ETag of the Entity. Not required when creating an entity, but required when updating an entity. IfMatch *string - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // NamedValueClientBeginRefreshSecretOptions contains the optional parameters for the NamedValueClient.BeginRefreshSecret // method. type NamedValueClientBeginRefreshSecretOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // NamedValueClientBeginUpdateOptions contains the optional parameters for the NamedValueClient.BeginUpdate method. type NamedValueClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -1781,11 +1870,21 @@ type OperationClientListByTagsOptions struct { Top *int32 } +// OperationStatusClientGetOptions contains the optional parameters for the OperationStatusClient.Get method. +type OperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} + // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } +// OperationsResultsClientGetOptions contains the optional parameters for the OperationsResultsClient.Get method. +type OperationsResultsClientGetOptions struct { + // placeholder for future optional parameters +} + // OutboundNetworkDependenciesEndpointsClientListByServiceOptions contains the optional parameters for the OutboundNetworkDependenciesEndpointsClient.ListByService // method. type OutboundNetworkDependenciesEndpointsClientListByServiceOptions struct { @@ -1814,7 +1913,7 @@ type PolicyClientGetOptions struct { Format *PolicyExportFormat } -// PolicyClientListByServiceOptions contains the optional parameters for the PolicyClient.ListByService method. +// PolicyClientListByServiceOptions contains the optional parameters for the PolicyClient.NewListByServicePager method. type PolicyClientListByServiceOptions struct { // placeholder for future optional parameters } @@ -1832,7 +1931,7 @@ type PolicyFragmentClientBeginCreateOrUpdateOptions struct { // ETag of the Entity. Not required when creating an entity, but required when updating an entity. IfMatch *string - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -1852,7 +1951,8 @@ type PolicyFragmentClientGetOptions struct { Format *PolicyFragmentContentFormat } -// PolicyFragmentClientListByServiceOptions contains the optional parameters for the PolicyFragmentClient.ListByService method. +// PolicyFragmentClientListByServiceOptions contains the optional parameters for the PolicyFragmentClient.NewListByServicePager +// method. type PolicyFragmentClientListByServiceOptions struct { // | Field | Usage | Supported operators | Supported functions | // |-------------|-------------|-------------|-------------| @@ -1881,6 +1981,48 @@ type PolicyFragmentClientListReferencesOptions struct { Top *int32 } +// PolicyRestrictionClientCreateOrUpdateOptions contains the optional parameters for the PolicyRestrictionClient.CreateOrUpdate +// method. +type PolicyRestrictionClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// PolicyRestrictionClientDeleteOptions contains the optional parameters for the PolicyRestrictionClient.Delete method. +type PolicyRestrictionClientDeleteOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// PolicyRestrictionClientGetEntityTagOptions contains the optional parameters for the PolicyRestrictionClient.GetEntityTag +// method. +type PolicyRestrictionClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// PolicyRestrictionClientGetOptions contains the optional parameters for the PolicyRestrictionClient.Get method. +type PolicyRestrictionClientGetOptions struct { + // placeholder for future optional parameters +} + +// PolicyRestrictionClientListByServiceOptions contains the optional parameters for the PolicyRestrictionClient.NewListByServicePager +// method. +type PolicyRestrictionClientListByServiceOptions struct { + // placeholder for future optional parameters +} + +// PolicyRestrictionClientUpdateOptions contains the optional parameters for the PolicyRestrictionClient.Update method. +type PolicyRestrictionClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// PolicyRestrictionValidationsClientBeginByServiceOptions contains the optional parameters for the PolicyRestrictionValidationsClient.BeginByService +// method. +type PolicyRestrictionValidationsClientBeginByServiceOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + // PortalConfigClientCreateOrUpdateOptions contains the optional parameters for the PortalConfigClient.CreateOrUpdate method. type PortalConfigClientCreateOrUpdateOptions struct { // placeholder for future optional parameters @@ -1896,7 +2038,8 @@ type PortalConfigClientGetOptions struct { // placeholder for future optional parameters } -// PortalConfigClientListByServiceOptions contains the optional parameters for the PortalConfigClient.ListByService method. +// PortalConfigClientListByServiceOptions contains the optional parameters for the PortalConfigClient.NewListByServicePager +// method. type PortalConfigClientListByServiceOptions struct { // placeholder for future optional parameters } @@ -1909,13 +2052,13 @@ type PortalConfigClientUpdateOptions struct { // PortalRevisionClientBeginCreateOrUpdateOptions contains the optional parameters for the PortalRevisionClient.BeginCreateOrUpdate // method. type PortalRevisionClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // PortalRevisionClientBeginUpdateOptions contains the optional parameters for the PortalRevisionClient.BeginUpdate method. type PortalRevisionClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -1952,14 +2095,14 @@ type PortalSettingsClientListByServiceOptions struct { // PrivateEndpointConnectionClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionClient.BeginCreateOrUpdate // method. type PrivateEndpointConnectionClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // PrivateEndpointConnectionClientBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnectionClient.BeginDelete // method. type PrivateEndpointConnectionClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -2020,6 +2163,37 @@ type ProductAPIClientListByProductOptions struct { Top *int32 } +// ProductAPILinkClientCreateOrUpdateOptions contains the optional parameters for the ProductAPILinkClient.CreateOrUpdate +// method. +type ProductAPILinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProductAPILinkClientDeleteOptions contains the optional parameters for the ProductAPILinkClient.Delete method. +type ProductAPILinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ProductAPILinkClientGetOptions contains the optional parameters for the ProductAPILinkClient.Get method. +type ProductAPILinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProductAPILinkClientListByProductOptions contains the optional parameters for the ProductAPILinkClient.NewListByProductPager +// method. +type ProductAPILinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | apiId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + // ProductClientCreateOrUpdateOptions contains the optional parameters for the ProductClient.CreateOrUpdate method. type ProductClientCreateOrUpdateOptions struct { // ETag of the Entity. Not required when creating an entity, but required when updating an entity. @@ -2126,6 +2300,37 @@ type ProductGroupClientListByProductOptions struct { Top *int32 } +// ProductGroupLinkClientCreateOrUpdateOptions contains the optional parameters for the ProductGroupLinkClient.CreateOrUpdate +// method. +type ProductGroupLinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProductGroupLinkClientDeleteOptions contains the optional parameters for the ProductGroupLinkClient.Delete method. +type ProductGroupLinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ProductGroupLinkClientGetOptions contains the optional parameters for the ProductGroupLinkClient.Get method. +type ProductGroupLinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProductGroupLinkClientListByProductOptions contains the optional parameters for the ProductGroupLinkClient.NewListByProductPager +// method. +type ProductGroupLinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | groupId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + // ProductPolicyClientCreateOrUpdateOptions contains the optional parameters for the ProductPolicyClient.CreateOrUpdate method. type ProductPolicyClientCreateOrUpdateOptions struct { // ETag of the Entity. Not required when creating an entity, but required when updating an entity. @@ -2148,7 +2353,8 @@ type ProductPolicyClientGetOptions struct { Format *PolicyExportFormat } -// ProductPolicyClientListByProductOptions contains the optional parameters for the ProductPolicyClient.ListByProduct method. +// ProductPolicyClientListByProductOptions contains the optional parameters for the ProductPolicyClient.NewListByProductPager +// method. type ProductPolicyClientListByProductOptions struct { // placeholder for future optional parameters } @@ -2346,43 +2552,46 @@ type ServiceClientBeginApplyNetworkConfigurationUpdatesOptions struct { // incurring downtime in the region. Parameters *ServiceApplyNetworkConfigurationParameters - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ServiceClientBeginBackupOptions contains the optional parameters for the ServiceClient.BeginBackup method. type ServiceClientBeginBackupOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ServiceClientBeginCreateOrUpdateOptions contains the optional parameters for the ServiceClient.BeginCreateOrUpdate method. type ServiceClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ServiceClientBeginDeleteOptions contains the optional parameters for the ServiceClient.BeginDelete method. type ServiceClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ServiceClientBeginMigrateToStv2Options contains the optional parameters for the ServiceClient.BeginMigrateToStv2 method. type ServiceClientBeginMigrateToStv2Options struct { - // Resumes the LRO from the provided token. + // Optional parameters supplied to migrate service. + Parameters *MigrateToStv2Contract + + // Resumes the long-running operation from the provided token. ResumeToken string } // ServiceClientBeginRestoreOptions contains the optional parameters for the ServiceClient.BeginRestore method. type ServiceClientBeginRestoreOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ServiceClientBeginUpdateOptions contains the optional parameters for the ServiceClient.BeginUpdate method. type ServiceClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -2548,6 +2757,35 @@ type SubscriptionClientUpdateOptions struct { Notify *bool } +// TagAPILinkClientCreateOrUpdateOptions contains the optional parameters for the TagAPILinkClient.CreateOrUpdate method. +type TagAPILinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// TagAPILinkClientDeleteOptions contains the optional parameters for the TagAPILinkClient.Delete method. +type TagAPILinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// TagAPILinkClientGetOptions contains the optional parameters for the TagAPILinkClient.Get method. +type TagAPILinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// TagAPILinkClientListByProductOptions contains the optional parameters for the TagAPILinkClient.NewListByProductPager method. +type TagAPILinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | apiId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + // TagClientAssignToAPIOptions contains the optional parameters for the TagClient.AssignToAPI method. type TagClientAssignToAPIOptions struct { // placeholder for future optional parameters @@ -2698,6 +2936,68 @@ type TagClientUpdateOptions struct { // placeholder for future optional parameters } +// TagOperationLinkClientCreateOrUpdateOptions contains the optional parameters for the TagOperationLinkClient.CreateOrUpdate +// method. +type TagOperationLinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// TagOperationLinkClientDeleteOptions contains the optional parameters for the TagOperationLinkClient.Delete method. +type TagOperationLinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// TagOperationLinkClientGetOptions contains the optional parameters for the TagOperationLinkClient.Get method. +type TagOperationLinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// TagOperationLinkClientListByProductOptions contains the optional parameters for the TagOperationLinkClient.NewListByProductPager +// method. +type TagOperationLinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | operationId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// TagProductLinkClientCreateOrUpdateOptions contains the optional parameters for the TagProductLinkClient.CreateOrUpdate +// method. +type TagProductLinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// TagProductLinkClientDeleteOptions contains the optional parameters for the TagProductLinkClient.Delete method. +type TagProductLinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// TagProductLinkClientGetOptions contains the optional parameters for the TagProductLinkClient.Get method. +type TagProductLinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// TagProductLinkClientListByProductOptions contains the optional parameters for the TagProductLinkClient.NewListByProductPager +// method. +type TagProductLinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + // TagResourceClientListByServiceOptions contains the optional parameters for the TagResourceClient.NewListByServicePager // method. type TagResourceClientListByServiceOptions struct { @@ -2784,21 +3084,21 @@ type TenantAccessGitClientRegenerateSecondaryKeyOptions struct { // TenantConfigurationClientBeginDeployOptions contains the optional parameters for the TenantConfigurationClient.BeginDeploy // method. type TenantConfigurationClientBeginDeployOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // TenantConfigurationClientBeginSaveOptions contains the optional parameters for the TenantConfigurationClient.BeginSave // method. type TenantConfigurationClientBeginSaveOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // TenantConfigurationClientBeginValidateOptions contains the optional parameters for the TenantConfigurationClient.BeginValidate // method. type TenantConfigurationClientBeginValidateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -2820,17 +3120,8 @@ type TenantSettingsClientListByServiceOptions struct { Filter *string } -// UserClientCreateOrUpdateOptions contains the optional parameters for the UserClient.CreateOrUpdate method. -type UserClientCreateOrUpdateOptions struct { - // ETag of the Entity. Not required when creating an entity, but required when updating an entity. - IfMatch *string - - // Send an Email notification to the User. - Notify *bool -} - -// UserClientDeleteOptions contains the optional parameters for the UserClient.Delete method. -type UserClientDeleteOptions struct { +// UserClientBeginDeleteOptions contains the optional parameters for the UserClient.BeginDelete method. +type UserClientBeginDeleteOptions struct { // Determines the type of application which send the create user request. Default is legacy publisher portal. AppType *AppType @@ -2839,6 +3130,18 @@ type UserClientDeleteOptions struct { // Send an Account Closed Email notification to the User. Notify *bool + + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// UserClientCreateOrUpdateOptions contains the optional parameters for the UserClient.CreateOrUpdate method. +type UserClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string + + // Send an Email notification to the User. + Notify *bool } // UserClientGenerateSsoURLOptions contains the optional parameters for the UserClient.GenerateSsoURL method. @@ -2942,3 +3245,1319 @@ type UserSubscriptionClientListOptions struct { // Number of records to return. Top *int32 } + +// WorkspaceAPIClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIClient.BeginCreateOrUpdate +// method. +type WorkspaceAPIClientBeginCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string + + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkspaceAPIClientDeleteOptions contains the optional parameters for the WorkspaceAPIClient.Delete method. +type WorkspaceAPIClientDeleteOptions struct { + // Delete all revisions of the Api. + DeleteRevisions *bool +} + +// WorkspaceAPIClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIClient.GetEntityTag method. +type WorkspaceAPIClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIClientGetOptions contains the optional parameters for the WorkspaceAPIClient.Get method. +type WorkspaceAPIClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIClientListByServiceOptions contains the optional parameters for the WorkspaceAPIClient.NewListByServicePager +// method. +type WorkspaceAPIClientListByServiceOptions struct { + // Include full ApiVersionSet resource in response + ExpandAPIVersionSet *bool + + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | isCurrent | filter | eq, ne | | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Include tags in the response. + Tags *string + + // Number of records to return. + Top *int32 +} + +// WorkspaceAPIClientUpdateOptions contains the optional parameters for the WorkspaceAPIClient.Update method. +type WorkspaceAPIClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIDiagnosticClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.CreateOrUpdate +// method. +type WorkspaceAPIDiagnosticClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceAPIDiagnosticClientDeleteOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.Delete +// method. +type WorkspaceAPIDiagnosticClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIDiagnosticClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.GetEntityTag +// method. +type WorkspaceAPIDiagnosticClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIDiagnosticClientGetOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.Get method. +type WorkspaceAPIDiagnosticClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIDiagnosticClientListByWorkspaceOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.NewListByWorkspacePager +// method. +type WorkspaceAPIDiagnosticClientListByWorkspaceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceAPIDiagnosticClientUpdateOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.Update +// method. +type WorkspaceAPIDiagnosticClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIExportClientGetOptions contains the optional parameters for the WorkspaceAPIExportClient.Get method. +type WorkspaceAPIExportClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIOperationClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIOperationClient.CreateOrUpdate +// method. +type WorkspaceAPIOperationClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceAPIOperationClientDeleteOptions contains the optional parameters for the WorkspaceAPIOperationClient.Delete method. +type WorkspaceAPIOperationClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIOperationClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIOperationClient.GetEntityTag +// method. +type WorkspaceAPIOperationClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIOperationClientGetOptions contains the optional parameters for the WorkspaceAPIOperationClient.Get method. +type WorkspaceAPIOperationClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIOperationClientListByAPIOptions contains the optional parameters for the WorkspaceAPIOperationClient.NewListByAPIPager +// method. +type WorkspaceAPIOperationClientListByAPIOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Include tags in the response. + Tags *string + + // Number of records to return. + Top *int32 +} + +// WorkspaceAPIOperationClientUpdateOptions contains the optional parameters for the WorkspaceAPIOperationClient.Update method. +type WorkspaceAPIOperationClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIOperationPolicyClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.CreateOrUpdate +// method. +type WorkspaceAPIOperationPolicyClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceAPIOperationPolicyClientDeleteOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.Delete +// method. +type WorkspaceAPIOperationPolicyClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIOperationPolicyClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.GetEntityTag +// method. +type WorkspaceAPIOperationPolicyClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIOperationPolicyClientGetOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.Get +// method. +type WorkspaceAPIOperationPolicyClientGetOptions struct { + // Policy Export Format. + Format *PolicyExportFormat +} + +// WorkspaceAPIOperationPolicyClientListByOperationOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.NewListByOperationPager +// method. +type WorkspaceAPIOperationPolicyClientListByOperationOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIPolicyClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIPolicyClient.CreateOrUpdate +// method. +type WorkspaceAPIPolicyClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceAPIPolicyClientDeleteOptions contains the optional parameters for the WorkspaceAPIPolicyClient.Delete method. +type WorkspaceAPIPolicyClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIPolicyClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIPolicyClient.GetEntityTag +// method. +type WorkspaceAPIPolicyClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIPolicyClientGetOptions contains the optional parameters for the WorkspaceAPIPolicyClient.Get method. +type WorkspaceAPIPolicyClientGetOptions struct { + // Policy Export Format. + Format *PolicyExportFormat +} + +// WorkspaceAPIPolicyClientListByAPIOptions contains the optional parameters for the WorkspaceAPIPolicyClient.NewListByAPIPager +// method. +type WorkspaceAPIPolicyClientListByAPIOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIReleaseClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIReleaseClient.CreateOrUpdate +// method. +type WorkspaceAPIReleaseClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceAPIReleaseClientDeleteOptions contains the optional parameters for the WorkspaceAPIReleaseClient.Delete method. +type WorkspaceAPIReleaseClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIReleaseClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIReleaseClient.GetEntityTag +// method. +type WorkspaceAPIReleaseClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIReleaseClientGetOptions contains the optional parameters for the WorkspaceAPIReleaseClient.Get method. +type WorkspaceAPIReleaseClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIReleaseClientListByServiceOptions contains the optional parameters for the WorkspaceAPIReleaseClient.NewListByServicePager +// method. +type WorkspaceAPIReleaseClientListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | notes | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceAPIReleaseClientUpdateOptions contains the optional parameters for the WorkspaceAPIReleaseClient.Update method. +type WorkspaceAPIReleaseClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIRevisionClientListByServiceOptions contains the optional parameters for the WorkspaceAPIRevisionClient.NewListByServicePager +// method. +type WorkspaceAPIRevisionClientListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceAPISchemaClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPISchemaClient.BeginCreateOrUpdate +// method. +type WorkspaceAPISchemaClientBeginCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string + + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkspaceAPISchemaClientDeleteOptions contains the optional parameters for the WorkspaceAPISchemaClient.Delete method. +type WorkspaceAPISchemaClientDeleteOptions struct { + // If true removes all references to the schema before deleting it. + Force *bool +} + +// WorkspaceAPISchemaClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPISchemaClient.GetEntityTag +// method. +type WorkspaceAPISchemaClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPISchemaClientGetOptions contains the optional parameters for the WorkspaceAPISchemaClient.Get method. +type WorkspaceAPISchemaClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPISchemaClientListByAPIOptions contains the optional parameters for the WorkspaceAPISchemaClient.NewListByAPIPager +// method. +type WorkspaceAPISchemaClientListByAPIOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | contentType | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceAPIVersionSetClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.CreateOrUpdate +// method. +type WorkspaceAPIVersionSetClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceAPIVersionSetClientDeleteOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.Delete +// method. +type WorkspaceAPIVersionSetClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIVersionSetClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.GetEntityTag +// method. +type WorkspaceAPIVersionSetClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIVersionSetClientGetOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.Get method. +type WorkspaceAPIVersionSetClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceAPIVersionSetClientListByServiceOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.NewListByServicePager +// method. +type WorkspaceAPIVersionSetClientListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceAPIVersionSetClientUpdateOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.Update +// method. +type WorkspaceAPIVersionSetClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceBackendClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceBackendClient.CreateOrUpdate +// method. +type WorkspaceBackendClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceBackendClientDeleteOptions contains the optional parameters for the WorkspaceBackendClient.Delete method. +type WorkspaceBackendClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceBackendClientGetEntityTagOptions contains the optional parameters for the WorkspaceBackendClient.GetEntityTag +// method. +type WorkspaceBackendClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceBackendClientGetOptions contains the optional parameters for the WorkspaceBackendClient.Get method. +type WorkspaceBackendClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceBackendClientListByWorkspaceOptions contains the optional parameters for the WorkspaceBackendClient.NewListByWorkspacePager +// method. +type WorkspaceBackendClientListByWorkspaceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | title | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | url | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceBackendClientUpdateOptions contains the optional parameters for the WorkspaceBackendClient.Update method. +type WorkspaceBackendClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceCertificateClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceCertificateClient.CreateOrUpdate +// method. +type WorkspaceCertificateClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceCertificateClientDeleteOptions contains the optional parameters for the WorkspaceCertificateClient.Delete method. +type WorkspaceCertificateClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceCertificateClientGetEntityTagOptions contains the optional parameters for the WorkspaceCertificateClient.GetEntityTag +// method. +type WorkspaceCertificateClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceCertificateClientGetOptions contains the optional parameters for the WorkspaceCertificateClient.Get method. +type WorkspaceCertificateClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceCertificateClientListByWorkspaceOptions contains the optional parameters for the WorkspaceCertificateClient.NewListByWorkspacePager +// method. +type WorkspaceCertificateClientListByWorkspaceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | subject | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | thumbprint | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | expirationDate | filter | ge, le, eq, ne, gt, lt | | + Filter *string + + // When set to true, the response contains only certificates entities which failed refresh. + IsKeyVaultRefreshFailed *bool + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceCertificateClientRefreshSecretOptions contains the optional parameters for the WorkspaceCertificateClient.RefreshSecret +// method. +type WorkspaceCertificateClientRefreshSecretOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceClient.CreateOrUpdate method. +type WorkspaceClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceClientDeleteOptions contains the optional parameters for the WorkspaceClient.Delete method. +type WorkspaceClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceClientGetEntityTagOptions contains the optional parameters for the WorkspaceClient.GetEntityTag method. +type WorkspaceClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceClientGetOptions contains the optional parameters for the WorkspaceClient.Get method. +type WorkspaceClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceClientListByServiceOptions contains the optional parameters for the WorkspaceClient.NewListByServicePager method. +type WorkspaceClientListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceClientUpdateOptions contains the optional parameters for the WorkspaceClient.Update method. +type WorkspaceClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceDiagnosticClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceDiagnosticClient.CreateOrUpdate +// method. +type WorkspaceDiagnosticClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceDiagnosticClientDeleteOptions contains the optional parameters for the WorkspaceDiagnosticClient.Delete method. +type WorkspaceDiagnosticClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceDiagnosticClientGetEntityTagOptions contains the optional parameters for the WorkspaceDiagnosticClient.GetEntityTag +// method. +type WorkspaceDiagnosticClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceDiagnosticClientGetOptions contains the optional parameters for the WorkspaceDiagnosticClient.Get method. +type WorkspaceDiagnosticClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceDiagnosticClientListByWorkspaceOptions contains the optional parameters for the WorkspaceDiagnosticClient.NewListByWorkspacePager +// method. +type WorkspaceDiagnosticClientListByWorkspaceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceDiagnosticClientUpdateOptions contains the optional parameters for the WorkspaceDiagnosticClient.Update method. +type WorkspaceDiagnosticClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.BeginCreateOrUpdate +// method. +type WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string + + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkspaceGlobalSchemaClientDeleteOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.Delete method. +type WorkspaceGlobalSchemaClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGlobalSchemaClientGetEntityTagOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.GetEntityTag +// method. +type WorkspaceGlobalSchemaClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGlobalSchemaClientGetOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.Get method. +type WorkspaceGlobalSchemaClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGlobalSchemaClientListByServiceOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.NewListByServicePager +// method. +type WorkspaceGlobalSchemaClientListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceGroupClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceGroupClient.CreateOrUpdate +// method. +type WorkspaceGroupClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceGroupClientDeleteOptions contains the optional parameters for the WorkspaceGroupClient.Delete method. +type WorkspaceGroupClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGroupClientGetEntityTagOptions contains the optional parameters for the WorkspaceGroupClient.GetEntityTag method. +type WorkspaceGroupClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGroupClientGetOptions contains the optional parameters for the WorkspaceGroupClient.Get method. +type WorkspaceGroupClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGroupClientListByServiceOptions contains the optional parameters for the WorkspaceGroupClient.NewListByServicePager +// method. +type WorkspaceGroupClientListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | externalId | filter | eq | | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceGroupClientUpdateOptions contains the optional parameters for the WorkspaceGroupClient.Update method. +type WorkspaceGroupClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGroupUserClientCheckEntityExistsOptions contains the optional parameters for the WorkspaceGroupUserClient.CheckEntityExists +// method. +type WorkspaceGroupUserClientCheckEntityExistsOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGroupUserClientCreateOptions contains the optional parameters for the WorkspaceGroupUserClient.Create method. +type WorkspaceGroupUserClientCreateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGroupUserClientDeleteOptions contains the optional parameters for the WorkspaceGroupUserClient.Delete method. +type WorkspaceGroupUserClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceGroupUserClientListOptions contains the optional parameters for the WorkspaceGroupUserClient.NewListPager method. +type WorkspaceGroupUserClientListOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | firstName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | registrationDate | filter | ge, le, eq, ne, gt, lt | | + // | note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceLinkClientGetOptions contains the optional parameters for the WorkspaceLinkClient.Get method. +type WorkspaceLinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceLinksClientListByServiceOptions contains the optional parameters for the WorkspaceLinksClient.NewListByServicePager +// method. +type WorkspaceLinksClientListByServiceOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceLoggerClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceLoggerClient.CreateOrUpdate +// method. +type WorkspaceLoggerClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceLoggerClientDeleteOptions contains the optional parameters for the WorkspaceLoggerClient.Delete method. +type WorkspaceLoggerClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceLoggerClientGetEntityTagOptions contains the optional parameters for the WorkspaceLoggerClient.GetEntityTag method. +type WorkspaceLoggerClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceLoggerClientGetOptions contains the optional parameters for the WorkspaceLoggerClient.Get method. +type WorkspaceLoggerClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceLoggerClientListByWorkspaceOptions contains the optional parameters for the WorkspaceLoggerClient.NewListByWorkspacePager +// method. +type WorkspaceLoggerClientListByWorkspaceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | loggerType | filter | eq | | + // | resourceId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceLoggerClientUpdateOptions contains the optional parameters for the WorkspaceLoggerClient.Update method. +type WorkspaceLoggerClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNamedValueClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspaceNamedValueClient.BeginCreateOrUpdate +// method. +type WorkspaceNamedValueClientBeginCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string + + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkspaceNamedValueClientBeginRefreshSecretOptions contains the optional parameters for the WorkspaceNamedValueClient.BeginRefreshSecret +// method. +type WorkspaceNamedValueClientBeginRefreshSecretOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkspaceNamedValueClientBeginUpdateOptions contains the optional parameters for the WorkspaceNamedValueClient.BeginUpdate +// method. +type WorkspaceNamedValueClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkspaceNamedValueClientDeleteOptions contains the optional parameters for the WorkspaceNamedValueClient.Delete method. +type WorkspaceNamedValueClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNamedValueClientGetEntityTagOptions contains the optional parameters for the WorkspaceNamedValueClient.GetEntityTag +// method. +type WorkspaceNamedValueClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNamedValueClientGetOptions contains the optional parameters for the WorkspaceNamedValueClient.Get method. +type WorkspaceNamedValueClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNamedValueClientListByServiceOptions contains the optional parameters for the WorkspaceNamedValueClient.NewListByServicePager +// method. +type WorkspaceNamedValueClientListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | tags | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith, any, all | + // | displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Query parameter to fetch named value entities based on refresh status. + IsKeyVaultRefreshFailed *KeyVaultRefreshState + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceNamedValueClientListValueOptions contains the optional parameters for the WorkspaceNamedValueClient.ListValue +// method. +type WorkspaceNamedValueClientListValueOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNotificationClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceNotificationClient.CreateOrUpdate +// method. +type WorkspaceNotificationClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceNotificationClientGetOptions contains the optional parameters for the WorkspaceNotificationClient.Get method. +type WorkspaceNotificationClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNotificationClientListByServiceOptions contains the optional parameters for the WorkspaceNotificationClient.NewListByServicePager +// method. +type WorkspaceNotificationClientListByServiceOptions struct { + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceNotificationRecipientEmailClientCheckEntityExistsOptions contains the optional parameters for the WorkspaceNotificationRecipientEmailClient.CheckEntityExists +// method. +type WorkspaceNotificationRecipientEmailClientCheckEntityExistsOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNotificationRecipientEmailClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceNotificationRecipientEmailClient.CreateOrUpdate +// method. +type WorkspaceNotificationRecipientEmailClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNotificationRecipientEmailClientDeleteOptions contains the optional parameters for the WorkspaceNotificationRecipientEmailClient.Delete +// method. +type WorkspaceNotificationRecipientEmailClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNotificationRecipientEmailClientListByNotificationOptions contains the optional parameters for the WorkspaceNotificationRecipientEmailClient.ListByNotification +// method. +type WorkspaceNotificationRecipientEmailClientListByNotificationOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNotificationRecipientUserClientCheckEntityExistsOptions contains the optional parameters for the WorkspaceNotificationRecipientUserClient.CheckEntityExists +// method. +type WorkspaceNotificationRecipientUserClientCheckEntityExistsOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNotificationRecipientUserClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceNotificationRecipientUserClient.CreateOrUpdate +// method. +type WorkspaceNotificationRecipientUserClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNotificationRecipientUserClientDeleteOptions contains the optional parameters for the WorkspaceNotificationRecipientUserClient.Delete +// method. +type WorkspaceNotificationRecipientUserClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceNotificationRecipientUserClientListByNotificationOptions contains the optional parameters for the WorkspaceNotificationRecipientUserClient.ListByNotification +// method. +type WorkspaceNotificationRecipientUserClientListByNotificationOptions struct { + // placeholder for future optional parameters +} + +// WorkspacePolicyClientCreateOrUpdateOptions contains the optional parameters for the WorkspacePolicyClient.CreateOrUpdate +// method. +type WorkspacePolicyClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspacePolicyClientDeleteOptions contains the optional parameters for the WorkspacePolicyClient.Delete method. +type WorkspacePolicyClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspacePolicyClientGetEntityTagOptions contains the optional parameters for the WorkspacePolicyClient.GetEntityTag method. +type WorkspacePolicyClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspacePolicyClientGetOptions contains the optional parameters for the WorkspacePolicyClient.Get method. +type WorkspacePolicyClientGetOptions struct { + // Policy Export Format. + Format *PolicyExportFormat +} + +// WorkspacePolicyClientListByAPIOptions contains the optional parameters for the WorkspacePolicyClient.NewListByAPIPager +// method. +type WorkspacePolicyClientListByAPIOptions struct { + // placeholder for future optional parameters +} + +// WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspacePolicyFragmentClient.BeginCreateOrUpdate +// method. +type WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string + + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkspacePolicyFragmentClientDeleteOptions contains the optional parameters for the WorkspacePolicyFragmentClient.Delete +// method. +type WorkspacePolicyFragmentClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspacePolicyFragmentClientGetEntityTagOptions contains the optional parameters for the WorkspacePolicyFragmentClient.GetEntityTag +// method. +type WorkspacePolicyFragmentClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspacePolicyFragmentClientGetOptions contains the optional parameters for the WorkspacePolicyFragmentClient.Get method. +type WorkspacePolicyFragmentClientGetOptions struct { + // Policy fragment content format. + Format *PolicyFragmentContentFormat +} + +// WorkspacePolicyFragmentClientListByServiceOptions contains the optional parameters for the WorkspacePolicyFragmentClient.NewListByServicePager +// method. +type WorkspacePolicyFragmentClientListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter, orderBy | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | value | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // OData order by query option. + Orderby *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspacePolicyFragmentClientListReferencesOptions contains the optional parameters for the WorkspacePolicyFragmentClient.ListReferences +// method. +type WorkspacePolicyFragmentClientListReferencesOptions struct { + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceProductAPILinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceProductAPILinkClient.CreateOrUpdate +// method. +type WorkspaceProductAPILinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductAPILinkClientDeleteOptions contains the optional parameters for the WorkspaceProductAPILinkClient.Delete +// method. +type WorkspaceProductAPILinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductAPILinkClientGetOptions contains the optional parameters for the WorkspaceProductAPILinkClient.Get method. +type WorkspaceProductAPILinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductAPILinkClientListByProductOptions contains the optional parameters for the WorkspaceProductAPILinkClient.NewListByProductPager +// method. +type WorkspaceProductAPILinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | apiId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceProductClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceProductClient.CreateOrUpdate +// method. +type WorkspaceProductClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceProductClientDeleteOptions contains the optional parameters for the WorkspaceProductClient.Delete method. +type WorkspaceProductClientDeleteOptions struct { + // Delete existing subscriptions associated with the product or not. + DeleteSubscriptions *bool +} + +// WorkspaceProductClientGetEntityTagOptions contains the optional parameters for the WorkspaceProductClient.GetEntityTag +// method. +type WorkspaceProductClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductClientGetOptions contains the optional parameters for the WorkspaceProductClient.Get method. +type WorkspaceProductClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductClientListByServiceOptions contains the optional parameters for the WorkspaceProductClient.NewListByServicePager +// method. +type WorkspaceProductClientListByServiceOptions struct { + // When set to true, the response contains an array of groups that have visibility to the product. The default is false. + ExpandGroups *bool + + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | state | filter | eq | | + // | groups | expand | | | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Products which are part of a specific tag. + Tags *string + + // Number of records to return. + Top *int32 +} + +// WorkspaceProductClientUpdateOptions contains the optional parameters for the WorkspaceProductClient.Update method. +type WorkspaceProductClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductGroupLinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceProductGroupLinkClient.CreateOrUpdate +// method. +type WorkspaceProductGroupLinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductGroupLinkClientDeleteOptions contains the optional parameters for the WorkspaceProductGroupLinkClient.Delete +// method. +type WorkspaceProductGroupLinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductGroupLinkClientGetOptions contains the optional parameters for the WorkspaceProductGroupLinkClient.Get +// method. +type WorkspaceProductGroupLinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductGroupLinkClientListByProductOptions contains the optional parameters for the WorkspaceProductGroupLinkClient.NewListByProductPager +// method. +type WorkspaceProductGroupLinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | groupId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceProductPolicyClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceProductPolicyClient.CreateOrUpdate +// method. +type WorkspaceProductPolicyClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceProductPolicyClientDeleteOptions contains the optional parameters for the WorkspaceProductPolicyClient.Delete +// method. +type WorkspaceProductPolicyClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductPolicyClientGetEntityTagOptions contains the optional parameters for the WorkspaceProductPolicyClient.GetEntityTag +// method. +type WorkspaceProductPolicyClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceProductPolicyClientGetOptions contains the optional parameters for the WorkspaceProductPolicyClient.Get method. +type WorkspaceProductPolicyClientGetOptions struct { + // Policy Export Format. + Format *PolicyExportFormat +} + +// WorkspaceProductPolicyClientListByProductOptions contains the optional parameters for the WorkspaceProductPolicyClient.ListByProduct +// method. +type WorkspaceProductPolicyClientListByProductOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceSubscriptionClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceSubscriptionClient.CreateOrUpdate +// method. +type WorkspaceSubscriptionClientCreateOrUpdateOptions struct { + // Determines the type of application which send the create user request. Default is legacy publisher portal. + AppType *AppType + + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string + + // Notify change in Subscription State. + // * If false, do not send any email notification for change of state of subscription + // * If true, send email notification of change of state of subscription + Notify *bool +} + +// WorkspaceSubscriptionClientDeleteOptions contains the optional parameters for the WorkspaceSubscriptionClient.Delete method. +type WorkspaceSubscriptionClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceSubscriptionClientGetEntityTagOptions contains the optional parameters for the WorkspaceSubscriptionClient.GetEntityTag +// method. +type WorkspaceSubscriptionClientGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceSubscriptionClientGetOptions contains the optional parameters for the WorkspaceSubscriptionClient.Get method. +type WorkspaceSubscriptionClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceSubscriptionClientListOptions contains the optional parameters for the WorkspaceSubscriptionClient.NewListPager +// method. +type WorkspaceSubscriptionClientListOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | ownerId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | state | filter | eq | | + // | user | expand | | | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceSubscriptionClientListSecretsOptions contains the optional parameters for the WorkspaceSubscriptionClient.ListSecrets +// method. +type WorkspaceSubscriptionClientListSecretsOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceSubscriptionClientRegeneratePrimaryKeyOptions contains the optional parameters for the WorkspaceSubscriptionClient.RegeneratePrimaryKey +// method. +type WorkspaceSubscriptionClientRegeneratePrimaryKeyOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceSubscriptionClientRegenerateSecondaryKeyOptions contains the optional parameters for the WorkspaceSubscriptionClient.RegenerateSecondaryKey +// method. +type WorkspaceSubscriptionClientRegenerateSecondaryKeyOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceSubscriptionClientUpdateOptions contains the optional parameters for the WorkspaceSubscriptionClient.Update method. +type WorkspaceSubscriptionClientUpdateOptions struct { + // Determines the type of application which send the create user request. Default is legacy publisher portal. + AppType *AppType + + // Notify change in Subscription State. + // * If false, do not send any email notification for change of state of subscription + // * If true, send email notification of change of state of subscription + Notify *bool +} + +// WorkspaceTagAPILinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceTagAPILinkClient.CreateOrUpdate +// method. +type WorkspaceTagAPILinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagAPILinkClientDeleteOptions contains the optional parameters for the WorkspaceTagAPILinkClient.Delete method. +type WorkspaceTagAPILinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagAPILinkClientGetOptions contains the optional parameters for the WorkspaceTagAPILinkClient.Get method. +type WorkspaceTagAPILinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagAPILinkClientListByProductOptions contains the optional parameters for the WorkspaceTagAPILinkClient.NewListByProductPager +// method. +type WorkspaceTagAPILinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | apiId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceTagClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceTagClient.CreateOrUpdate method. +type WorkspaceTagClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// WorkspaceTagClientDeleteOptions contains the optional parameters for the WorkspaceTagClient.Delete method. +type WorkspaceTagClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagClientGetEntityStateOptions contains the optional parameters for the WorkspaceTagClient.GetEntityState method. +type WorkspaceTagClientGetEntityStateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagClientGetOptions contains the optional parameters for the WorkspaceTagClient.Get method. +type WorkspaceTagClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagClientListByServiceOptions contains the optional parameters for the WorkspaceTagClient.NewListByServicePager +// method. +type WorkspaceTagClientListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + // | displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Scope like 'apis', 'products' or 'apis/{apiId} + Scope *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceTagClientUpdateOptions contains the optional parameters for the WorkspaceTagClient.Update method. +type WorkspaceTagClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagOperationLinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceTagOperationLinkClient.CreateOrUpdate +// method. +type WorkspaceTagOperationLinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagOperationLinkClientDeleteOptions contains the optional parameters for the WorkspaceTagOperationLinkClient.Delete +// method. +type WorkspaceTagOperationLinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagOperationLinkClientGetOptions contains the optional parameters for the WorkspaceTagOperationLinkClient.Get +// method. +type WorkspaceTagOperationLinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagOperationLinkClientListByProductOptions contains the optional parameters for the WorkspaceTagOperationLinkClient.NewListByProductPager +// method. +type WorkspaceTagOperationLinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | operationId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} + +// WorkspaceTagProductLinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceTagProductLinkClient.CreateOrUpdate +// method. +type WorkspaceTagProductLinkClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagProductLinkClientDeleteOptions contains the optional parameters for the WorkspaceTagProductLinkClient.Delete +// method. +type WorkspaceTagProductLinkClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagProductLinkClientGetOptions contains the optional parameters for the WorkspaceTagProductLinkClient.Get method. +type WorkspaceTagProductLinkClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspaceTagProductLinkClientListByProductOptions contains the optional parameters for the WorkspaceTagProductLinkClient.NewListByProductPager +// method. +type WorkspaceTagProductLinkClientListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions | + // |-------------|-------------|-------------|-------------| + // | productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | + Filter *string + + // Number of records to skip. + Skip *int32 + + // Number of records to return. + Top *int32 +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/outboundnetworkdependenciesendpoints_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/outboundnetworkdependenciesendpoints_client.go index 6d3a222d452d..fbd8ce87fb6e 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/outboundnetworkdependenciesendpoints_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/outboundnetworkdependenciesendpoints_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type OutboundNetworkDependenciesEndpointsClient struct { } // NewOutboundNetworkDependenciesEndpointsClient creates a new instance of OutboundNetworkDependenciesEndpointsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewOutboundNetworkDependenciesEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OutboundNetworkDependenciesEndpointsClient, error) { @@ -46,7 +43,7 @@ func NewOutboundNetworkDependenciesEndpointsClient(subscriptionID string, creden // ListByService - Gets the network endpoints of all outbound dependencies of a ApiManagement service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - OutboundNetworkDependenciesEndpointsClientListByServiceOptions contains the optional parameters for the OutboundNetworkDependenciesEndpointsClient.ListByService @@ -74,7 +71,7 @@ func (client *OutboundNetworkDependenciesEndpointsClient) ListByService(ctx cont } // listByServiceCreateRequest creates the ListByService request. -func (client *OutboundNetworkDependenciesEndpointsClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *OutboundNetworkDependenciesEndpointsClientListByServiceOptions) (*policy.Request, error) { +func (client *OutboundNetworkDependenciesEndpointsClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *OutboundNetworkDependenciesEndpointsClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -93,7 +90,7 @@ func (client *OutboundNetworkDependenciesEndpointsClient) listByServiceCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/outboundnetworkdependenciesendpoints_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/outboundnetworkdependenciesendpoints_client_example_test.go deleted file mode 100644 index 3a2b6edbac12..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/outboundnetworkdependenciesendpoints_client_example_test.go +++ /dev/null @@ -1,441 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetOutboundNetworkDependenciesEndpoints.json -func ExampleOutboundNetworkDependenciesEndpointsClient_ListByService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOutboundNetworkDependenciesEndpointsClient().ListByService(ctx, "rg1", "apimService1", 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.OutboundEnvironmentEndpointList = armapimanagement.OutboundEnvironmentEndpointList{ - // Value: []*armapimanagement.OutboundEnvironmentEndpoint{ - // { - // Category: to.Ptr("Azure SMTP"), - // Endpoints: []*armapimanagement.EndpointDependency{ - // { - // DomainName: to.Ptr("smtpi-ch1.msn.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](25028), - // Region: to.Ptr("West US"), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("Azure SQL"), - // Endpoints: []*armapimanagement.EndpointDependency{ - // { - // DomainName: to.Ptr("xxxx1345234.database.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](1433), - // Region: to.Ptr("West US"), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("Azure Storage"), - // Endpoints: []*armapimanagement.EndpointDependency{ - // { - // DomainName: to.Ptr("xxxx32storagedgfbay.blob.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx1362629927xt.blob.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx1362629927xt.table.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx141483183xt.blob.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx141483183xt.table.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx1949864718xt.blob.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx1949864718xt.table.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx3292114122xt.blob.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx3292114122xt.table.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx32tst4oto8t0mlesawmm.blob.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx32tst4oto8t0mlesawmm.file.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](445), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx32tst4oto8t0mlesawmm.queue.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx32tst4oto8t0mlesawmm.table.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("Azure Event Hub"), - // Endpoints: []*armapimanagement.EndpointDependency{ - // { - // DomainName: to.Ptr("xxxx1362629927eh.servicebus.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }, - // { - // Port: to.Ptr[int32](5671), - // Region: to.Ptr("West US"), - // }, - // { - // Port: to.Ptr[int32](5672), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx1949864718eh.servicebus.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }, - // { - // Port: to.Ptr[int32](5671), - // Region: to.Ptr("West US"), - // }, - // { - // Port: to.Ptr[int32](5672), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx3292114122eh.servicebus.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }, - // { - // Port: to.Ptr[int32](5671), - // Region: to.Ptr("West US"), - // }, - // { - // Port: to.Ptr[int32](5672), - // Region: to.Ptr("West US"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxxx141483183eh.servicebus.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("West US"), - // }, - // { - // Port: to.Ptr[int32](5671), - // Region: to.Ptr("West US"), - // }, - // { - // Port: to.Ptr[int32](5672), - // Region: to.Ptr("West US"), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("SSL Certificate Verification"), - // Endpoints: []*armapimanagement.EndpointDependency{ - // { - // DomainName: to.Ptr("ocsp.msocsp.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](80), - // Region: to.Ptr("Global"), - // }, - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("mscrl.microsoft.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](80), - // Region: to.Ptr("Global"), - // }, - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("crl.microsoft.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](80), - // Region: to.Ptr("Global"), - // }, - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("crl3.digicert.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](80), - // Region: to.Ptr("Global"), - // }, - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("ocsp.digicert.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](80), - // Region: to.Ptr("Global"), - // }, - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("cacerts.digicert.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](80), - // Region: to.Ptr("Global"), - // }, - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("Azure Monitor"), - // Endpoints: []*armapimanagement.EndpointDependency{ - // { - // DomainName: to.Ptr("gcs.ppe.monitoring.core.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("global.prod.microsoftmetrics.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxx3.prod.microsoftmetrics.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](1886), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxx3-red.prod.microsoftmetrics.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](1886), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("xxx3-black.prod.microsoftmetrics.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](1886), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("gcs.ppe.warm.ingestion.monitoring.azure.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("metrichost23.prod.microsoftmetrics.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("metrichost23-red.prod.microsoftmetrics.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("metrichost23-black.prod.microsoftmetrics.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("Portal Captcha"), - // Endpoints: []*armapimanagement.EndpointDependency{ - // { - // DomainName: to.Ptr("client.xxx.live.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("partner.xxx.live.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("Azure Active Directory"), - // Endpoints: []*armapimanagement.EndpointDependency{ - // { - // DomainName: to.Ptr("login.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("graph.windows.net"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }, - // { - // DomainName: to.Ptr("login.microsoftonline.com"), - // EndpointDetails: []*armapimanagement.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // Region: to.Ptr("Global"), - // }}, - // }}, - // }}, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/policy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/policy_client.go index e3ffebb63259..676c2371c30a 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/policy_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/policy_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type PolicyClient struct { } // NewPolicyClient creates a new instance of PolicyClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyClient, error) { @@ -46,7 +43,7 @@ func NewPolicyClient(subscriptionID string, credential azcore.TokenCredential, o // CreateOrUpdate - Creates or updates the global policy configuration of the Api Management service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - policyID - The identifier of the Policy. @@ -98,12 +95,12 @@ func (client *PolicyClient) createOrUpdateCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -125,7 +122,7 @@ func (client *PolicyClient) createOrUpdateHandleResponse(resp *http.Response) (P // Delete - Deletes the global policy configuration of the Api Management Service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - policyID - The identifier of the Policy. @@ -154,7 +151,7 @@ func (client *PolicyClient) Delete(ctx context.Context, resourceGroupName string } // deleteCreateRequest creates the Delete request. -func (client *PolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, ifMatch string, options *PolicyClientDeleteOptions) (*policy.Request, error) { +func (client *PolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, ifMatch string, _ *PolicyClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -177,17 +174,17 @@ func (client *PolicyClient) deleteCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Get the Global policy definition of the Api Management service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - policyID - The identifier of the Policy. @@ -238,10 +235,10 @@ func (client *PolicyClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Format != nil { reqQP.Set("format", string(*options.Format)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -261,7 +258,7 @@ func (client *PolicyClient) getHandleResponse(resp *http.Response) (PolicyClient // GetEntityTag - Gets the entity state (Etag) version of the Global policy definition in the Api Management service. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - policyID - The identifier of the Policy. @@ -289,7 +286,7 @@ func (client *PolicyClient) GetEntityTag(ctx context.Context, resourceGroupName } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *PolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, options *PolicyClientGetEntityTagOptions) (*policy.Request, error) { +func (client *PolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, _ *PolicyClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -312,7 +309,7 @@ func (client *PolicyClient) getEntityTagCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -327,37 +324,38 @@ func (client *PolicyClient) getEntityTagHandleResponse(resp *http.Response) (Pol return result, nil } -// ListByService - Lists all the Global Policy definitions of the Api Management service. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListByServicePager - Lists all the Global Policy definitions of the Api Management service. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. -// - options - PolicyClientListByServiceOptions contains the optional parameters for the PolicyClient.ListByService method. -func (client *PolicyClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, options *PolicyClientListByServiceOptions) (PolicyClientListByServiceResponse, error) { - var err error - const operationName = "PolicyClient.ListByService" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) - if err != nil { - return PolicyClientListByServiceResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PolicyClientListByServiceResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return PolicyClientListByServiceResponse{}, err - } - resp, err := client.listByServiceHandleResponse(httpResp) - return resp, err +// - options - PolicyClientListByServiceOptions contains the optional parameters for the PolicyClient.NewListByServicePager +// method. +func (client *PolicyClient) NewListByServicePager(resourceGroupName string, serviceName string, options *PolicyClientListByServiceOptions) *runtime.Pager[PolicyClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[PolicyClientListByServiceResponse]{ + More: func(page PolicyClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PolicyClientListByServiceResponse) (PolicyClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PolicyClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, nil) + if err != nil { + return PolicyClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listByServiceCreateRequest creates the ListByService request. -func (client *PolicyClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PolicyClientListByServiceOptions) (*policy.Request, error) { +func (client *PolicyClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *PolicyClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -376,7 +374,7 @@ func (client *PolicyClient) listByServiceCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/policy_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/policy_client_example_test.go deleted file mode 100644 index e8de33379658..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/policy_client_example_test.go +++ /dev/null @@ -1,175 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPolicies.json -func ExamplePolicyClient_ListByService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPolicyClient().ListByService(ctx, "rg1", "apimService1", 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.PolicyCollection = armapimanagement.PolicyCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.PolicyContract{ - // { - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n\r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadPolicy.json -func ExamplePolicyClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewPolicyClient().GetEntityTag(ctx, "rg1", "apimService1", armapimanagement.PolicyIDNamePolicy, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPolicy.json -func ExamplePolicyClient_Get_apiManagementGetPolicy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPolicyClient().Get(ctx, "rg1", "apimService1", armapimanagement.PolicyIDNamePolicy, &armapimanagement.PolicyClientGetOptions{Format: 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n\r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPolicyFormat.json -func ExamplePolicyClient_Get_apiManagementGetPolicyFormat() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPolicyClient().Get(ctx, "rg1", "apimService1", armapimanagement.PolicyIDNamePolicy, &armapimanagement.PolicyClientGetOptions{Format: to.Ptr(armapimanagement.PolicyExportFormatRawxml)}) - 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Format: to.Ptr(armapimanagement.PolicyContentFormatRawxml), - // Value: to.Ptr("\r\n\r\n \r\n \r\n @{\n var guidBinary = new byte[16];\n Array.Copy(Guid.NewGuid().ToByteArray(), 0, guidBinary, 0, 10);\n long time = DateTime.Now.Ticks;\n byte[] bytes = new byte[6];\n unchecked\n {\n bytes[5] = (byte)(time >> 40);\n bytes[4] = (byte)(time >> 32);\n bytes[3] = (byte)(time >> 24);\n bytes[2] = (byte)(time >> 16);\n bytes[1] = (byte)(time >> 8);\n bytes[0] = (byte)(time);\n }\n Array.Copy(bytes, 0, guidBinary, 10, 6);\n return new Guid(guidBinary).ToString();\n }\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreatePolicy.json -func ExamplePolicyClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPolicyClient().CreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.PolicyIDNamePolicy, armapimanagement.PolicyContract{ - Properties: &armapimanagement.PolicyContractProperties{ - Format: to.Ptr(armapimanagement.PolicyContentFormatXML), - Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n"), - }, - }, &armapimanagement.PolicyClientCreateOrUpdateOptions{IfMatch: 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletePolicy.json -func ExamplePolicyClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewPolicyClient().Delete(ctx, "rg1", "apimService1", armapimanagement.PolicyIDNamePolicy, "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/policydescription_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/policydescription_client.go index d101c7685d97..335ccd00a0dd 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/policydescription_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/policydescription_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type PolicyDescriptionClient struct { } // NewPolicyDescriptionClient creates a new instance of PolicyDescriptionClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewPolicyDescriptionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyDescriptionClient, error) { @@ -46,7 +43,7 @@ func NewPolicyDescriptionClient(subscriptionID string, credential azcore.TokenCr // ListByService - Lists all policy descriptions. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - PolicyDescriptionClientListByServiceOptions contains the optional parameters for the PolicyDescriptionClient.ListByService @@ -93,10 +90,10 @@ func (client *PolicyDescriptionClient) listByServiceCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Scope != nil { reqQP.Set("scope", string(*options.Scope)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/policydescription_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/policydescription_client_example_test.go deleted file mode 100644 index f6edf93ae47f..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/policydescription_client_example_test.go +++ /dev/null @@ -1,61 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPolicyDescriptions.json -func ExamplePolicyDescriptionClient_ListByService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPolicyDescriptionClient().ListByService(ctx, "rg1", "apimService1", &armapimanagement.PolicyDescriptionClientListByServiceOptions{Scope: to.Ptr(armapimanagement.PolicyScopeContractAPI)}) - 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.PolicyDescriptionCollection = armapimanagement.PolicyDescriptionCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.PolicyDescriptionContract{ - // { - // Name: to.Ptr("authentication-basic"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policyDescriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policyDescriptions/authentication-basic"), - // Properties: &armapimanagement.PolicyDescriptionContractProperties{ - // Description: to.Ptr("Authenticate with the backend service using Basic authentication. Use in the inbound section at API scope."), - // Scope: to.Ptr[int64](268435471), - // }, - // }, - // { - // Name: to.Ptr("authentication-certificate"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policyDescriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policyDescriptions/authentication-certificate"), - // Properties: &armapimanagement.PolicyDescriptionContractProperties{ - // Description: to.Ptr("Authenticate with the backend service using a client certificate. Use in the inbound section at API scope."), - // Scope: to.Ptr[int64](268435471), - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/policyfragment_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/policyfragment_client.go index 4c1a6803af12..078408786b53 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/policyfragment_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/policyfragment_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type PolicyFragmentClient struct { } // NewPolicyFragmentClient creates a new instance of PolicyFragmentClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewPolicyFragmentClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyFragmentClient, error) { @@ -47,7 +44,7 @@ func NewPolicyFragmentClient(subscriptionID string, credential azcore.TokenCrede // BeginCreateOrUpdate - Creates or updates a policy fragment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - id - A resource identifier. @@ -75,7 +72,7 @@ func (client *PolicyFragmentClient) BeginCreateOrUpdate(ctx context.Context, res // CreateOrUpdate - Creates or updates a policy fragment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *PolicyFragmentClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, id string, parameters PolicyFragmentContract, options *PolicyFragmentClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "PolicyFragmentClient.BeginCreateOrUpdate" @@ -90,7 +87,7 @@ func (client *PolicyFragmentClient) createOrUpdate(ctx context.Context, resource if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -121,12 +118,12 @@ func (client *PolicyFragmentClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -136,7 +133,7 @@ func (client *PolicyFragmentClient) createOrUpdateCreateRequest(ctx context.Cont // Delete - Deletes a policy fragment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - id - A resource identifier. @@ -165,7 +162,7 @@ func (client *PolicyFragmentClient) Delete(ctx context.Context, resourceGroupNam } // deleteCreateRequest creates the Delete request. -func (client *PolicyFragmentClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, id string, ifMatch string, options *PolicyFragmentClientDeleteOptions) (*policy.Request, error) { +func (client *PolicyFragmentClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, id string, ifMatch string, _ *PolicyFragmentClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -188,17 +185,17 @@ func (client *PolicyFragmentClient) deleteCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets a policy fragment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - id - A resource identifier. @@ -249,7 +246,7 @@ func (client *PolicyFragmentClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Format != nil { reqQP.Set("format", string(*options.Format)) } @@ -272,7 +269,7 @@ func (client *PolicyFragmentClient) getHandleResponse(resp *http.Response) (Poli // GetEntityTag - Gets the entity state (Etag) version of a policy fragment. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - id - A resource identifier. @@ -301,7 +298,7 @@ func (client *PolicyFragmentClient) GetEntityTag(ctx context.Context, resourceGr } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *PolicyFragmentClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, id string, options *PolicyFragmentClientGetEntityTagOptions) (*policy.Request, error) { +func (client *PolicyFragmentClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, id string, _ *PolicyFragmentClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -324,7 +321,7 @@ func (client *PolicyFragmentClient) getEntityTagCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -339,34 +336,34 @@ func (client *PolicyFragmentClient) getEntityTagHandleResponse(resp *http.Respon return result, nil } -// ListByService - Gets all policy fragments. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListByServicePager - Gets all policy fragments. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. -// - options - PolicyFragmentClientListByServiceOptions contains the optional parameters for the PolicyFragmentClient.ListByService +// - options - PolicyFragmentClientListByServiceOptions contains the optional parameters for the PolicyFragmentClient.NewListByServicePager // method. -func (client *PolicyFragmentClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, options *PolicyFragmentClientListByServiceOptions) (PolicyFragmentClientListByServiceResponse, error) { - var err error - const operationName = "PolicyFragmentClient.ListByService" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) - if err != nil { - return PolicyFragmentClientListByServiceResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PolicyFragmentClientListByServiceResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return PolicyFragmentClientListByServiceResponse{}, err - } - resp, err := client.listByServiceHandleResponse(httpResp) - return resp, err +func (client *PolicyFragmentClient) NewListByServicePager(resourceGroupName string, serviceName string, options *PolicyFragmentClientListByServiceOptions) *runtime.Pager[PolicyFragmentClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[PolicyFragmentClientListByServiceResponse]{ + More: func(page PolicyFragmentClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PolicyFragmentClientListByServiceResponse) (PolicyFragmentClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PolicyFragmentClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, nil) + if err != nil { + return PolicyFragmentClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listByServiceCreateRequest creates the ListByService request. @@ -389,19 +386,19 @@ func (client *PolicyFragmentClient) listByServiceCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } if options != nil && options.Orderby != nil { reqQP.Set("$orderby", *options.Orderby) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -419,7 +416,7 @@ func (client *PolicyFragmentClient) listByServiceHandleResponse(resp *http.Respo // ListReferences - Lists policy resources that reference the policy fragment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - id - A resource identifier. @@ -471,13 +468,13 @@ func (client *PolicyFragmentClient) listReferencesCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/policyfragment_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/policyfragment_client_example_test.go deleted file mode 100644 index 9ad39cf8fe6f..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/policyfragment_client_example_test.go +++ /dev/null @@ -1,222 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPolicyFragments.json -func ExamplePolicyFragmentClient_ListByService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPolicyFragmentClient().ListByService(ctx, "rg1", "apimService1", &armapimanagement.PolicyFragmentClientListByServiceOptions{Filter: nil, - Orderby: nil, - Top: nil, - Skip: 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.PolicyFragmentCollection = armapimanagement.PolicyFragmentCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.PolicyFragmentContract{ - // { - // Name: to.Ptr("policyFragment1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policyFragments"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policyFragments/policyFragment1"), - // Properties: &armapimanagement.PolicyFragmentContractProperties{ - // Format: to.Ptr(armapimanagement.PolicyFragmentContentFormatXML), - // Description: to.Ptr("A policy fragment example"), - // Value: to.Ptr(""), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadPolicyFragment.json -func ExamplePolicyFragmentClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewPolicyFragmentClient().GetEntityTag(ctx, "rg1", "apimService1", "policyFragment1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPolicyFragment.json -func ExamplePolicyFragmentClient_Get_apiManagementGetPolicyFragment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPolicyFragmentClient().Get(ctx, "rg1", "apimService1", "policyFragment1", &armapimanagement.PolicyFragmentClientGetOptions{Format: 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.PolicyFragmentContract = armapimanagement.PolicyFragmentContract{ - // Name: to.Ptr("policyFragment1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policyFragments"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policyFragments/policyFragment1"), - // Properties: &armapimanagement.PolicyFragmentContractProperties{ - // Format: to.Ptr(armapimanagement.PolicyFragmentContentFormatXML), - // Description: to.Ptr("A policy fragment example"), - // Value: to.Ptr(""), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPolicyFragmentFormat.json -func ExamplePolicyFragmentClient_Get_apiManagementGetPolicyFragmentFormat() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPolicyFragmentClient().Get(ctx, "rg1", "apimService1", "policyFragment1", &armapimanagement.PolicyFragmentClientGetOptions{Format: to.Ptr(armapimanagement.PolicyFragmentContentFormatRawxml)}) - 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.PolicyFragmentContract = armapimanagement.PolicyFragmentContract{ - // Name: to.Ptr("policyFragment1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policyFragments"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policyFragments/policyFragment1"), - // Properties: &armapimanagement.PolicyFragmentContractProperties{ - // Format: to.Ptr(armapimanagement.PolicyFragmentContentFormatRawxml), - // Description: to.Ptr("A policy fragment example"), - // Value: to.Ptr("\r\n @{\n var guidBinary = new byte[16];\n Array.Copy(Guid.NewGuid().ToByteArray(), 0, guidBinary, 0, 10);\n long time = DateTime.Now.Ticks;\n byte[] bytes = new byte[6];\n unchecked\n {\n bytes[5] = (byte)(time >> 40);\n bytes[4] = (byte)(time >> 32);\n bytes[3] = (byte)(time >> 24);\n bytes[2] = (byte)(time >> 16);\n bytes[1] = (byte)(time >> 8);\n bytes[0] = (byte)(time);\n }\n Array.Copy(bytes, 0, guidBinary, 10, 6);\n return new Guid(guidBinary).ToString();\n }\n \r\n "), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreatePolicyFragment.json -func ExamplePolicyFragmentClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPolicyFragmentClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "policyFragment1", armapimanagement.PolicyFragmentContract{ - Properties: &armapimanagement.PolicyFragmentContractProperties{ - Format: to.Ptr(armapimanagement.PolicyFragmentContentFormatXML), - Description: to.Ptr("A policy fragment example"), - Value: to.Ptr(""), - }, - }, &armapimanagement.PolicyFragmentClientBeginCreateOrUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PolicyFragmentContract = armapimanagement.PolicyFragmentContract{ - // Name: to.Ptr("policyFragment1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policyFragments"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policyFragments/policyFragment1"), - // Properties: &armapimanagement.PolicyFragmentContractProperties{ - // Format: to.Ptr(armapimanagement.PolicyFragmentContentFormatXML), - // Description: to.Ptr("A policy fragment example"), - // Value: to.Ptr(""), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletePolicyFragment.json -func ExamplePolicyFragmentClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewPolicyFragmentClient().Delete(ctx, "rg1", "apimService1", "policyFragment1", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPolicyFragmentReferences.json -func ExamplePolicyFragmentClient_ListReferences() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPolicyFragmentClient().ListReferences(ctx, "rg1", "apimService1", "policyFragment1", &armapimanagement.PolicyFragmentClientListReferencesOptions{Top: nil, - Skip: 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.ResourceCollection = armapimanagement.ResourceCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.ResourceCollectionValueItem{ - // { - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/policies/policy"), - // }}, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/policyrestriction_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/policyrestriction_client.go new file mode 100644 index 000000000000..474557247b5b --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/policyrestriction_client.go @@ -0,0 +1,470 @@ +// 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 armapimanagement + +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" +) + +// PolicyRestrictionClient contains the methods for the PolicyRestriction group. +// Don't use this type directly, use NewPolicyRestrictionClient() instead. +type PolicyRestrictionClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPolicyRestrictionClient creates a new instance of PolicyRestrictionClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPolicyRestrictionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyRestrictionClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PolicyRestrictionClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates the policy restriction configuration of the Api Management service. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - policyRestrictionID - Policy restrictions after an entity level +// - parameters - The policy restriction to apply. +// - options - PolicyRestrictionClientCreateOrUpdateOptions contains the optional parameters for the PolicyRestrictionClient.CreateOrUpdate +// method. +func (client *PolicyRestrictionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, parameters PolicyRestrictionContract, options *PolicyRestrictionClientCreateOrUpdateOptions) (PolicyRestrictionClientCreateOrUpdateResponse, error) { + var err error + const operationName = "PolicyRestrictionClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, policyRestrictionID, parameters, options) + if err != nil { + return PolicyRestrictionClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PolicyRestrictionClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return PolicyRestrictionClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PolicyRestrictionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, parameters PolicyRestrictionContract, options *PolicyRestrictionClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if policyRestrictionID == "" { + return nil, errors.New("parameter policyRestrictionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyRestrictionId}", url.PathEscape(policyRestrictionID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PolicyRestrictionClient) createOrUpdateHandleResponse(resp *http.Response) (PolicyRestrictionClientCreateOrUpdateResponse, error) { + result := PolicyRestrictionClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyRestrictionContract); err != nil { + return PolicyRestrictionClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the policy restriction configuration of the Api Management Service. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - policyRestrictionID - Policy restrictions after an entity level +// - options - PolicyRestrictionClientDeleteOptions contains the optional parameters for the PolicyRestrictionClient.Delete +// method. +func (client *PolicyRestrictionClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, options *PolicyRestrictionClientDeleteOptions) (PolicyRestrictionClientDeleteResponse, error) { + var err error + const operationName = "PolicyRestrictionClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, policyRestrictionID, options) + if err != nil { + return PolicyRestrictionClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PolicyRestrictionClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return PolicyRestrictionClientDeleteResponse{}, err + } + return PolicyRestrictionClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PolicyRestrictionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, options *PolicyRestrictionClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if policyRestrictionID == "" { + return nil, errors.New("parameter policyRestrictionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyRestrictionId}", url.PathEscape(policyRestrictionID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + return req, nil +} + +// Get - Get the policy restriction of the Api Management service. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - policyRestrictionID - Policy restrictions after an entity level +// - options - PolicyRestrictionClientGetOptions contains the optional parameters for the PolicyRestrictionClient.Get method. +func (client *PolicyRestrictionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, options *PolicyRestrictionClientGetOptions) (PolicyRestrictionClientGetResponse, error) { + var err error + const operationName = "PolicyRestrictionClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, policyRestrictionID, options) + if err != nil { + return PolicyRestrictionClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PolicyRestrictionClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PolicyRestrictionClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PolicyRestrictionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, _ *PolicyRestrictionClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if policyRestrictionID == "" { + return nil, errors.New("parameter policyRestrictionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyRestrictionId}", url.PathEscape(policyRestrictionID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PolicyRestrictionClient) getHandleResponse(resp *http.Response) (PolicyRestrictionClientGetResponse, error) { + result := PolicyRestrictionClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyRestrictionContract); err != nil { + return PolicyRestrictionClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the policy restriction in the Api Management service. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - policyRestrictionID - Policy restrictions after an entity level +// - options - PolicyRestrictionClientGetEntityTagOptions contains the optional parameters for the PolicyRestrictionClient.GetEntityTag +// method. +func (client *PolicyRestrictionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, options *PolicyRestrictionClientGetEntityTagOptions) (PolicyRestrictionClientGetEntityTagResponse, error) { + var err error + const operationName = "PolicyRestrictionClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, policyRestrictionID, options) + if err != nil { + return PolicyRestrictionClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PolicyRestrictionClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PolicyRestrictionClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *PolicyRestrictionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, _ *PolicyRestrictionClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if policyRestrictionID == "" { + return nil, errors.New("parameter policyRestrictionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyRestrictionId}", url.PathEscape(policyRestrictionID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *PolicyRestrictionClient) getEntityTagHandleResponse(resp *http.Response) (PolicyRestrictionClientGetEntityTagResponse, error) { + result := PolicyRestrictionClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Gets all policy restrictions of API Management services. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - options - PolicyRestrictionClientListByServiceOptions contains the optional parameters for the PolicyRestrictionClient.NewListByServicePager +// method. +func (client *PolicyRestrictionClient) NewListByServicePager(resourceGroupName string, serviceName string, options *PolicyRestrictionClientListByServiceOptions) *runtime.Pager[PolicyRestrictionClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[PolicyRestrictionClientListByServiceResponse]{ + More: func(page PolicyRestrictionClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PolicyRestrictionClientListByServiceResponse) (PolicyRestrictionClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PolicyRestrictionClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, nil) + if err != nil { + return PolicyRestrictionClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *PolicyRestrictionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *PolicyRestrictionClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions" + 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 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *PolicyRestrictionClient) listByServiceHandleResponse(resp *http.Response) (PolicyRestrictionClientListByServiceResponse, error) { + result := PolicyRestrictionClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyRestrictionCollection); err != nil { + return PolicyRestrictionClientListByServiceResponse{}, err + } + return result, nil +} + +// Update - Updates the policy restriction configuration of the Api Management service. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - policyRestrictionID - Policy restrictions after an entity level +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - The policy restriction to apply. +// - options - PolicyRestrictionClientUpdateOptions contains the optional parameters for the PolicyRestrictionClient.Update +// method. +func (client *PolicyRestrictionClient) Update(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, ifMatch string, parameters PolicyRestrictionUpdateContract, options *PolicyRestrictionClientUpdateOptions) (PolicyRestrictionClientUpdateResponse, error) { + var err error + const operationName = "PolicyRestrictionClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, policyRestrictionID, ifMatch, parameters, options) + if err != nil { + return PolicyRestrictionClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PolicyRestrictionClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PolicyRestrictionClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *PolicyRestrictionClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyRestrictionID string, ifMatch string, parameters PolicyRestrictionUpdateContract, _ *PolicyRestrictionClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if policyRestrictionID == "" { + return nil, errors.New("parameter policyRestrictionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyRestrictionId}", url.PathEscape(policyRestrictionID)) + 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", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *PolicyRestrictionClient) updateHandleResponse(resp *http.Response) (PolicyRestrictionClientUpdateResponse, error) { + result := PolicyRestrictionClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyRestrictionContract); err != nil { + return PolicyRestrictionClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/policyrestrictionvalidations_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/policyrestrictionvalidations_client.go new file mode 100644 index 000000000000..761480ec1f06 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/policyrestrictionvalidations_client.go @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armapimanagement + +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" +) + +// PolicyRestrictionValidationsClient contains the methods for the PolicyRestrictionValidations group. +// Don't use this type directly, use NewPolicyRestrictionValidationsClient() instead. +type PolicyRestrictionValidationsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPolicyRestrictionValidationsClient creates a new instance of PolicyRestrictionValidationsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPolicyRestrictionValidationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyRestrictionValidationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PolicyRestrictionValidationsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginByService - Validate all policies of API Management services. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - options - PolicyRestrictionValidationsClientBeginByServiceOptions contains the optional parameters for the PolicyRestrictionValidationsClient.BeginByService +// method. +func (client *PolicyRestrictionValidationsClient) BeginByService(ctx context.Context, resourceGroupName string, serviceName string, options *PolicyRestrictionValidationsClientBeginByServiceOptions) (*runtime.Poller[PolicyRestrictionValidationsClientByServiceResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.byService(ctx, resourceGroupName, serviceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PolicyRestrictionValidationsClientByServiceResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PolicyRestrictionValidationsClientByServiceResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ByService - Validate all policies of API Management services. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *PolicyRestrictionValidationsClient) byService(ctx context.Context, resourceGroupName string, serviceName string, options *PolicyRestrictionValidationsClientBeginByServiceOptions) (*http.Response, error) { + var err error + const operationName = "PolicyRestrictionValidationsClient.BeginByService" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.byServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// byServiceCreateRequest creates the ByService request. +func (client *PolicyRestrictionValidationsClient) byServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *PolicyRestrictionValidationsClientBeginByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/validatePolicies" + 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.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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/portalconfig_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/portalconfig_client.go index 06706bacfd03..0c273bf6f260 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/portalconfig_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/portalconfig_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type PortalConfigClient struct { } // NewPortalConfigClient creates a new instance of PortalConfigClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewPortalConfigClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PortalConfigClient, error) { @@ -46,7 +43,7 @@ func NewPortalConfigClient(subscriptionID string, credential azcore.TokenCredent // CreateOrUpdate - Create or update the developer portal configuration. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - portalConfigID - Portal configuration identifier. @@ -78,7 +75,7 @@ func (client *PortalConfigClient) CreateOrUpdate(ctx context.Context, resourceGr } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *PortalConfigClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, ifMatch string, parameters PortalConfigContract, options *PortalConfigClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *PortalConfigClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, ifMatch string, parameters PortalConfigContract, _ *PortalConfigClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -101,10 +98,10 @@ func (client *PortalConfigClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -123,7 +120,7 @@ func (client *PortalConfigClient) createOrUpdateHandleResponse(resp *http.Respon // Get - Get the developer portal configuration. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - portalConfigID - Portal configuration identifier. @@ -151,7 +148,7 @@ func (client *PortalConfigClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *PortalConfigClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, options *PortalConfigClientGetOptions) (*policy.Request, error) { +func (client *PortalConfigClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, _ *PortalConfigClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -174,7 +171,7 @@ func (client *PortalConfigClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -194,7 +191,7 @@ func (client *PortalConfigClient) getHandleResponse(resp *http.Response) (Portal // GetEntityTag - Gets the entity state (Etag) version of the developer portal configuration. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - portalConfigID - Portal configuration identifier. @@ -223,7 +220,7 @@ func (client *PortalConfigClient) GetEntityTag(ctx context.Context, resourceGrou } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *PortalConfigClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, options *PortalConfigClientGetEntityTagOptions) (*policy.Request, error) { +func (client *PortalConfigClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, _ *PortalConfigClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -246,7 +243,7 @@ func (client *PortalConfigClient) getEntityTagCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -261,38 +258,38 @@ func (client *PortalConfigClient) getEntityTagHandleResponse(resp *http.Response return result, nil } -// ListByService - Lists the developer portal configurations. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListByServicePager - Lists the developer portal configurations. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. -// - options - PortalConfigClientListByServiceOptions contains the optional parameters for the PortalConfigClient.ListByService +// - options - PortalConfigClientListByServiceOptions contains the optional parameters for the PortalConfigClient.NewListByServicePager // method. -func (client *PortalConfigClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, options *PortalConfigClientListByServiceOptions) (PortalConfigClientListByServiceResponse, error) { - var err error - const operationName = "PortalConfigClient.ListByService" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) - if err != nil { - return PortalConfigClientListByServiceResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PortalConfigClientListByServiceResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return PortalConfigClientListByServiceResponse{}, err - } - resp, err := client.listByServiceHandleResponse(httpResp) - return resp, err +func (client *PortalConfigClient) NewListByServicePager(resourceGroupName string, serviceName string, options *PortalConfigClientListByServiceOptions) *runtime.Pager[PortalConfigClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[PortalConfigClientListByServiceResponse]{ + More: func(page PortalConfigClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PortalConfigClientListByServiceResponse) (PortalConfigClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PortalConfigClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, nil) + if err != nil { + return PortalConfigClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listByServiceCreateRequest creates the ListByService request. -func (client *PortalConfigClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PortalConfigClientListByServiceOptions) (*policy.Request, error) { +func (client *PortalConfigClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *PortalConfigClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -311,7 +308,7 @@ func (client *PortalConfigClient) listByServiceCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -329,7 +326,7 @@ func (client *PortalConfigClient) listByServiceHandleResponse(resp *http.Respons // Update - Update the developer portal configuration. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - portalConfigID - Portal configuration identifier. @@ -360,7 +357,7 @@ func (client *PortalConfigClient) Update(ctx context.Context, resourceGroupName } // updateCreateRequest creates the Update request. -func (client *PortalConfigClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, ifMatch string, parameters PortalConfigContract, options *PortalConfigClientUpdateOptions) (*policy.Request, error) { +func (client *PortalConfigClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, ifMatch string, parameters PortalConfigContract, _ *PortalConfigClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -383,10 +380,10 @@ func (client *PortalConfigClient) updateCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/portalconfig_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/portalconfig_client_example_test.go deleted file mode 100644 index 0cee11abc437..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/portalconfig_client_example_test.go +++ /dev/null @@ -1,303 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPortalConfig.json -func ExamplePortalConfigClient_ListByService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPortalConfigClient().ListByService(ctx, "rg1", "apimService1", 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.PortalConfigCollection = armapimanagement.PortalConfigCollection{ - // Value: []*armapimanagement.PortalConfigContract{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalconfigs"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalconfigs/default"), - // Properties: &armapimanagement.PortalConfigProperties{ - // Cors: &armapimanagement.PortalConfigCorsProperties{ - // AllowedOrigins: []*string{ - // to.Ptr("https://contoso.com")}, - // }, - // Csp: &armapimanagement.PortalConfigCspProperties{ - // AllowedSources: []*string{ - // to.Ptr("*.contoso.com")}, - // Mode: to.Ptr(armapimanagement.PortalSettingsCspModeReportOnly), - // ReportURI: []*string{ - // to.Ptr("https://report.contoso.com")}, - // }, - // Delegation: &armapimanagement.PortalConfigDelegationProperties{ - // DelegateRegistration: to.Ptr(false), - // DelegateSubscription: to.Ptr(false), - // }, - // EnableBasicAuth: to.Ptr(true), - // Signin: &armapimanagement.PortalConfigPropertiesSignin{ - // Require: to.Ptr(false), - // }, - // Signup: &armapimanagement.PortalConfigPropertiesSignup{ - // TermsOfService: &armapimanagement.PortalConfigTermsOfServiceProperties{ - // RequireConsent: to.Ptr(false), - // Text: to.Ptr("I agree to the service terms and conditions."), - // }, - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadPortalConfig.json -func ExamplePortalConfigClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewPortalConfigClient().GetEntityTag(ctx, "rg1", "apimService1", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalConfig.json -func ExamplePortalConfigClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPortalConfigClient().Get(ctx, "rg1", "apimService1", "default", 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.PortalConfigContract = armapimanagement.PortalConfigContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalconfigs"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalconfigs/default"), - // Properties: &armapimanagement.PortalConfigProperties{ - // Cors: &armapimanagement.PortalConfigCorsProperties{ - // AllowedOrigins: []*string{ - // to.Ptr("https://contoso.com")}, - // }, - // Csp: &armapimanagement.PortalConfigCspProperties{ - // AllowedSources: []*string{ - // to.Ptr("*.contoso.com")}, - // Mode: to.Ptr(armapimanagement.PortalSettingsCspModeReportOnly), - // ReportURI: []*string{ - // to.Ptr("https://report.contoso.com")}, - // }, - // Delegation: &armapimanagement.PortalConfigDelegationProperties{ - // DelegateRegistration: to.Ptr(false), - // DelegateSubscription: to.Ptr(false), - // }, - // EnableBasicAuth: to.Ptr(true), - // Signin: &armapimanagement.PortalConfigPropertiesSignin{ - // Require: to.Ptr(false), - // }, - // Signup: &armapimanagement.PortalConfigPropertiesSignup{ - // TermsOfService: &armapimanagement.PortalConfigTermsOfServiceProperties{ - // RequireConsent: to.Ptr(false), - // Text: to.Ptr("I agree to the service terms and conditions."), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdatePortalConfig.json -func ExamplePortalConfigClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPortalConfigClient().Update(ctx, "rg1", "apimService1", "default", "*", armapimanagement.PortalConfigContract{ - Properties: &armapimanagement.PortalConfigProperties{ - Cors: &armapimanagement.PortalConfigCorsProperties{ - AllowedOrigins: []*string{ - to.Ptr("https://contoso.com")}, - }, - Csp: &armapimanagement.PortalConfigCspProperties{ - AllowedSources: []*string{ - to.Ptr("*.contoso.com")}, - Mode: to.Ptr(armapimanagement.PortalSettingsCspModeReportOnly), - ReportURI: []*string{ - to.Ptr("https://report.contoso.com")}, - }, - Delegation: &armapimanagement.PortalConfigDelegationProperties{ - DelegateRegistration: to.Ptr(false), - DelegateSubscription: to.Ptr(false), - }, - EnableBasicAuth: to.Ptr(true), - Signin: &armapimanagement.PortalConfigPropertiesSignin{ - Require: to.Ptr(false), - }, - Signup: &armapimanagement.PortalConfigPropertiesSignup{ - TermsOfService: &armapimanagement.PortalConfigTermsOfServiceProperties{ - RequireConsent: to.Ptr(false), - Text: to.Ptr("I agree to the service terms and conditions."), - }, - }, - }, - }, 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.PortalConfigContract = armapimanagement.PortalConfigContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalconfigs"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalconfigs/default"), - // Properties: &armapimanagement.PortalConfigProperties{ - // Cors: &armapimanagement.PortalConfigCorsProperties{ - // AllowedOrigins: []*string{ - // to.Ptr("https://contoso.com")}, - // }, - // Csp: &armapimanagement.PortalConfigCspProperties{ - // AllowedSources: []*string{ - // to.Ptr("*.contoso.com")}, - // Mode: to.Ptr(armapimanagement.PortalSettingsCspModeReportOnly), - // ReportURI: []*string{ - // to.Ptr("https://report.contoso.com")}, - // }, - // Delegation: &armapimanagement.PortalConfigDelegationProperties{ - // DelegateRegistration: to.Ptr(false), - // DelegateSubscription: to.Ptr(false), - // }, - // EnableBasicAuth: to.Ptr(true), - // Signin: &armapimanagement.PortalConfigPropertiesSignin{ - // Require: to.Ptr(false), - // }, - // Signup: &armapimanagement.PortalConfigPropertiesSignup{ - // TermsOfService: &armapimanagement.PortalConfigTermsOfServiceProperties{ - // RequireConsent: to.Ptr(false), - // Text: to.Ptr("I agree to the service terms and conditions."), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreatePortalConfig.json -func ExamplePortalConfigClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPortalConfigClient().CreateOrUpdate(ctx, "rg1", "apimService1", "default", "*", armapimanagement.PortalConfigContract{ - Properties: &armapimanagement.PortalConfigProperties{ - Cors: &armapimanagement.PortalConfigCorsProperties{ - AllowedOrigins: []*string{ - to.Ptr("https://contoso.com")}, - }, - Csp: &armapimanagement.PortalConfigCspProperties{ - AllowedSources: []*string{ - to.Ptr("*.contoso.com")}, - Mode: to.Ptr(armapimanagement.PortalSettingsCspModeReportOnly), - ReportURI: []*string{ - to.Ptr("https://report.contoso.com")}, - }, - Delegation: &armapimanagement.PortalConfigDelegationProperties{ - DelegateRegistration: to.Ptr(false), - DelegateSubscription: to.Ptr(false), - }, - EnableBasicAuth: to.Ptr(true), - Signin: &armapimanagement.PortalConfigPropertiesSignin{ - Require: to.Ptr(false), - }, - Signup: &armapimanagement.PortalConfigPropertiesSignup{ - TermsOfService: &armapimanagement.PortalConfigTermsOfServiceProperties{ - RequireConsent: to.Ptr(false), - Text: to.Ptr("I agree to the service terms and conditions."), - }, - }, - }, - }, 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.PortalConfigContract = armapimanagement.PortalConfigContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalconfigs"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalconfigs/default"), - // Properties: &armapimanagement.PortalConfigProperties{ - // Cors: &armapimanagement.PortalConfigCorsProperties{ - // AllowedOrigins: []*string{ - // to.Ptr("https://contoso.com")}, - // }, - // Csp: &armapimanagement.PortalConfigCspProperties{ - // AllowedSources: []*string{ - // to.Ptr("*.contoso.com")}, - // Mode: to.Ptr(armapimanagement.PortalSettingsCspModeReportOnly), - // ReportURI: []*string{ - // to.Ptr("https://report.contoso.com")}, - // }, - // Delegation: &armapimanagement.PortalConfigDelegationProperties{ - // DelegateRegistration: to.Ptr(false), - // DelegateSubscription: to.Ptr(false), - // }, - // EnableBasicAuth: to.Ptr(true), - // Signin: &armapimanagement.PortalConfigPropertiesSignin{ - // Require: to.Ptr(false), - // }, - // Signup: &armapimanagement.PortalConfigPropertiesSignup{ - // TermsOfService: &armapimanagement.PortalConfigTermsOfServiceProperties{ - // RequireConsent: to.Ptr(false), - // Text: to.Ptr("I agree to the service terms and conditions."), - // }, - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/portalrevision_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/portalrevision_client.go index c8169af87e09..f5843c37497d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/portalrevision_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/portalrevision_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type PortalRevisionClient struct { } // NewPortalRevisionClient creates a new instance of PortalRevisionClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewPortalRevisionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PortalRevisionClient, error) { @@ -48,7 +45,7 @@ func NewPortalRevisionClient(subscriptionID string, credential azcore.TokenCrede // indicates if the revision is publicly accessible. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - portalRevisionID - Portal revision identifier. Must be unique in the current API Management service instance. @@ -76,7 +73,7 @@ func (client *PortalRevisionClient) BeginCreateOrUpdate(ctx context.Context, res // if the revision is publicly accessible. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *PortalRevisionClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, options *PortalRevisionClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "PortalRevisionClient.BeginCreateOrUpdate" @@ -91,7 +88,7 @@ func (client *PortalRevisionClient) createOrUpdate(ctx context.Context, resource if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -99,7 +96,7 @@ func (client *PortalRevisionClient) createOrUpdate(ctx context.Context, resource } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *PortalRevisionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, options *PortalRevisionClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *PortalRevisionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, _ *PortalRevisionClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -122,7 +119,7 @@ func (client *PortalRevisionClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -134,7 +131,7 @@ func (client *PortalRevisionClient) createOrUpdateCreateRequest(ctx context.Cont // Get - Gets the developer portal's revision specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - portalRevisionID - Portal revision identifier. Must be unique in the current API Management service instance. @@ -162,7 +159,7 @@ func (client *PortalRevisionClient) Get(ctx context.Context, resourceGroupName s } // getCreateRequest creates the Get request. -func (client *PortalRevisionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, options *PortalRevisionClientGetOptions) (*policy.Request, error) { +func (client *PortalRevisionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, _ *PortalRevisionClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -185,7 +182,7 @@ func (client *PortalRevisionClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -205,7 +202,7 @@ func (client *PortalRevisionClient) getHandleResponse(resp *http.Response) (Port // GetEntityTag - Gets the developer portal revision specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - portalRevisionID - Portal revision identifier. Must be unique in the current API Management service instance. @@ -234,7 +231,7 @@ func (client *PortalRevisionClient) GetEntityTag(ctx context.Context, resourceGr } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *PortalRevisionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, options *PortalRevisionClientGetEntityTagOptions) (*policy.Request, error) { +func (client *PortalRevisionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, _ *PortalRevisionClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -257,7 +254,7 @@ func (client *PortalRevisionClient) getEntityTagCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -274,7 +271,7 @@ func (client *PortalRevisionClient) getEntityTagHandleResponse(resp *http.Respon // NewListByServicePager - Lists developer portal's revisions. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - PortalRevisionClientListByServiceOptions contains the optional parameters for the PortalRevisionClient.NewListByServicePager @@ -325,13 +322,13 @@ func (client *PortalRevisionClient) listByServiceCreateRequest(ctx context.Conte if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -349,7 +346,7 @@ func (client *PortalRevisionClient) listByServiceHandleResponse(resp *http.Respo // BeginUpdate - Updates the description of specified portal revision or makes it current. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - portalRevisionID - Portal revision identifier. Must be unique in the current API Management service instance. @@ -378,7 +375,7 @@ func (client *PortalRevisionClient) BeginUpdate(ctx context.Context, resourceGro // Update - Updates the description of specified portal revision or makes it current. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *PortalRevisionClient) update(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, ifMatch string, parameters PortalRevisionContract, options *PortalRevisionClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "PortalRevisionClient.BeginUpdate" @@ -401,7 +398,7 @@ func (client *PortalRevisionClient) update(ctx context.Context, resourceGroupNam } // updateCreateRequest creates the Update request. -func (client *PortalRevisionClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, ifMatch string, parameters PortalRevisionContract, options *PortalRevisionClientBeginUpdateOptions) (*policy.Request, error) { +func (client *PortalRevisionClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, ifMatch string, parameters PortalRevisionContract, _ *PortalRevisionClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -424,10 +421,10 @@ func (client *PortalRevisionClient) updateCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/portalrevision_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/portalrevision_client_example_test.go deleted file mode 100644 index c802c6a09fb2..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/portalrevision_client_example_test.go +++ /dev/null @@ -1,190 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPortalRevisions.json -func ExamplePortalRevisionClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPortalRevisionClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.PortalRevisionClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.PortalRevisionCollection = armapimanagement.PortalRevisionCollection{ - // Value: []*armapimanagement.PortalRevisionContract{ - // { - // Name: to.Ptr("20201112000000"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalRevisions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalRevisions/20201112000000"), - // Properties: &armapimanagement.PortalRevisionContractProperties{ - // Description: to.Ptr("portal revision"), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T22:10:09.673Z"); return t}()), - // IsCurrent: to.Ptr(false), - // Status: to.Ptr(armapimanagement.PortalRevisionStatusCompleted), - // UpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T22:12:41.460Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("20201112101010"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalRevisions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalRevisions/20201112101010"), - // Properties: &armapimanagement.PortalRevisionContractProperties{ - // Description: to.Ptr("portal revision 1"), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T22:51:36.470Z"); return t}()), - // IsCurrent: to.Ptr(true), - // Status: to.Ptr(armapimanagement.PortalRevisionStatusCompleted), - // UpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T22:52:00.097Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadPortalRevision.json -func ExamplePortalRevisionClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewPortalRevisionClient().GetEntityTag(ctx, "rg1", "apimService1", "20201112101010", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPortalRevision.json -func ExamplePortalRevisionClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPortalRevisionClient().Get(ctx, "rg1", "apimService1", "20201112101010", 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.PortalRevisionContract = armapimanagement.PortalRevisionContract{ - // Name: to.Ptr("20201112101010"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalRevisions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalRevisions/20201112101010"), - // Properties: &armapimanagement.PortalRevisionContractProperties{ - // Description: to.Ptr("portal revision 1"), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T22:51:36.470Z"); return t}()), - // IsCurrent: to.Ptr(true), - // Status: to.Ptr(armapimanagement.PortalRevisionStatusCompleted), - // UpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-12T22:52:00.097Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreatePortalRevision.json -func ExamplePortalRevisionClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPortalRevisionClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "20201112101010", armapimanagement.PortalRevisionContract{ - Properties: &armapimanagement.PortalRevisionContractProperties{ - Description: to.Ptr("portal revision 1"), - IsCurrent: to.Ptr(true), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdatePortalRevision.json -func ExamplePortalRevisionClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPortalRevisionClient().BeginUpdate(ctx, "rg1", "apimService1", "20201112101010", "*", armapimanagement.PortalRevisionContract{ - Properties: &armapimanagement.PortalRevisionContractProperties{ - Description: to.Ptr("portal revision update"), - IsCurrent: to.Ptr(true), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PortalRevisionContract = armapimanagement.PortalRevisionContract{ - // Name: to.Ptr("20201112101010"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalRevisions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/namedValues/testprop2"), - // Properties: &armapimanagement.PortalRevisionContractProperties{ - // Description: to.Ptr("portal revision update"), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-13T22:47:13.397Z"); return t}()), - // IsCurrent: to.Ptr(true), - // Status: to.Ptr(armapimanagement.PortalRevisionStatusCompleted), - // UpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-13T23:29:25.340Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/portalsettings_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/portalsettings_client.go index 043d702d0f3c..4921fe48aa32 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/portalsettings_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/portalsettings_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type PortalSettingsClient struct { } // NewPortalSettingsClient creates a new instance of PortalSettingsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewPortalSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PortalSettingsClient, error) { @@ -46,7 +43,7 @@ func NewPortalSettingsClient(subscriptionID string, credential azcore.TokenCrede // ListByService - Lists a collection of portalsettings defined within a service instance.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - PortalSettingsClientListByServiceOptions contains the optional parameters for the PortalSettingsClient.ListByService @@ -74,7 +71,7 @@ func (client *PortalSettingsClient) ListByService(ctx context.Context, resourceG } // listByServiceCreateRequest creates the ListByService request. -func (client *PortalSettingsClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PortalSettingsClientListByServiceOptions) (*policy.Request, error) { +func (client *PortalSettingsClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *PortalSettingsClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -93,7 +90,7 @@ func (client *PortalSettingsClient) listByServiceCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/portalsettings_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/portalsettings_client_example_test.go deleted file mode 100644 index ceb1cf69b86e..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/portalsettings_client_example_test.go +++ /dev/null @@ -1,77 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPortalSettings.json -func ExamplePortalSettingsClient_ListByService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPortalSettingsClient().ListByService(ctx, "rg1", "apimService1", 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.PortalSettingsCollection = armapimanagement.PortalSettingsCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.PortalSettingsContract{ - // { - // Name: to.Ptr("delegation"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalsettings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalsettings/delegation"), - // Properties: &armapimanagement.PortalSettingsContractProperties{ - // Enabled: to.Ptr(false), - // Subscriptions: &armapimanagement.SubscriptionsDelegationSettingsProperties{ - // Enabled: to.Ptr(false), - // }, - // UserRegistration: &armapimanagement.RegistrationDelegationSettingsProperties{ - // Enabled: to.Ptr(false), - // }, - // }, - // }, - // { - // Name: to.Ptr("signin"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalsettings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalsettings/signin"), - // Properties: &armapimanagement.PortalSettingsContractProperties{ - // Enabled: to.Ptr(false), - // }, - // }, - // { - // Name: to.Ptr("signup"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalsettings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalsettings/signup"), - // Properties: &armapimanagement.PortalSettingsContractProperties{ - // Enabled: to.Ptr(true), - // TermsOfService: &armapimanagement.TermsOfServiceProperties{ - // ConsentRequired: to.Ptr(false), - // Enabled: to.Ptr(false), - // Text: to.Ptr("Terms of service"), - // }, - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/privateendpointconnection_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/privateendpointconnection_client.go index ebe927deacc5..50430df89542 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/privateendpointconnection_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/privateendpointconnection_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type PrivateEndpointConnectionClient struct { } // NewPrivateEndpointConnectionClient creates a new instance of PrivateEndpointConnectionClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewPrivateEndpointConnectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionClient, error) { @@ -46,7 +43,7 @@ func NewPrivateEndpointConnectionClient(subscriptionID string, credential azcore // BeginCreateOrUpdate - Creates a new Private Endpoint Connection or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - privateEndpointConnectionName - Name of the private endpoint connection. @@ -72,7 +69,7 @@ func (client *PrivateEndpointConnectionClient) BeginCreateOrUpdate(ctx context.C // CreateOrUpdate - Creates a new Private Endpoint Connection or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *PrivateEndpointConnectionClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, privateEndpointConnectionName string, privateEndpointConnectionRequest PrivateEndpointConnectionRequest, options *PrivateEndpointConnectionClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionClient.BeginCreateOrUpdate" @@ -95,7 +92,7 @@ func (client *PrivateEndpointConnectionClient) createOrUpdate(ctx context.Contex } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *PrivateEndpointConnectionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, privateEndpointConnectionName string, privateEndpointConnectionRequest PrivateEndpointConnectionRequest, options *PrivateEndpointConnectionClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, privateEndpointConnectionName string, privateEndpointConnectionRequest PrivateEndpointConnectionRequest, _ *PrivateEndpointConnectionClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -118,7 +115,7 @@ func (client *PrivateEndpointConnectionClient) createOrUpdateCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, privateEndpointConnectionRequest); err != nil { @@ -130,7 +127,7 @@ func (client *PrivateEndpointConnectionClient) createOrUpdateCreateRequest(ctx c // BeginDelete - Deletes the specified Private Endpoint Connection. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - privateEndpointConnectionName - Name of the private endpoint connection. @@ -156,7 +153,7 @@ func (client *PrivateEndpointConnectionClient) BeginDelete(ctx context.Context, // Delete - Deletes the specified Private Endpoint Connection. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *PrivateEndpointConnectionClient) deleteOperation(ctx context.Context, resourceGroupName string, serviceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionClient.BeginDelete" @@ -179,7 +176,7 @@ func (client *PrivateEndpointConnectionClient) deleteOperation(ctx context.Conte } // deleteCreateRequest creates the Delete request. -func (client *PrivateEndpointConnectionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionClientBeginDeleteOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -202,7 +199,7 @@ func (client *PrivateEndpointConnectionClient) deleteCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -211,7 +208,7 @@ func (client *PrivateEndpointConnectionClient) deleteCreateRequest(ctx context.C // GetByName - Gets the details of the Private Endpoint Connection specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - privateEndpointConnectionName - Name of the private endpoint connection. @@ -240,7 +237,7 @@ func (client *PrivateEndpointConnectionClient) GetByName(ctx context.Context, re } // getByNameCreateRequest creates the GetByName request. -func (client *PrivateEndpointConnectionClient) getByNameCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionClientGetByNameOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionClient) getByNameCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, privateEndpointConnectionName string, _ *PrivateEndpointConnectionClientGetByNameOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -263,7 +260,7 @@ func (client *PrivateEndpointConnectionClient) getByNameCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -281,7 +278,7 @@ func (client *PrivateEndpointConnectionClient) getByNameHandleResponse(resp *htt // GetPrivateLinkResource - Gets the private link resources // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - privateLinkSubResourceName - Name of the private link resource. @@ -310,7 +307,7 @@ func (client *PrivateEndpointConnectionClient) GetPrivateLinkResource(ctx contex } // getPrivateLinkResourceCreateRequest creates the GetPrivateLinkResource request. -func (client *PrivateEndpointConnectionClient) getPrivateLinkResourceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, privateLinkSubResourceName string, options *PrivateEndpointConnectionClientGetPrivateLinkResourceOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionClient) getPrivateLinkResourceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, privateLinkSubResourceName string, _ *PrivateEndpointConnectionClientGetPrivateLinkResourceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -333,7 +330,7 @@ func (client *PrivateEndpointConnectionClient) getPrivateLinkResourceCreateReque return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -350,7 +347,7 @@ func (client *PrivateEndpointConnectionClient) getPrivateLinkResourceHandleRespo // NewListByServicePager - Lists all private endpoint connections of the API Management service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - PrivateEndpointConnectionClientListByServiceOptions contains the optional parameters for the PrivateEndpointConnectionClient.NewListByServicePager @@ -380,7 +377,7 @@ func (client *PrivateEndpointConnectionClient) NewListByServicePager(resourceGro } // listByServiceCreateRequest creates the ListByService request. -func (client *PrivateEndpointConnectionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PrivateEndpointConnectionClientListByServiceOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *PrivateEndpointConnectionClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -399,7 +396,7 @@ func (client *PrivateEndpointConnectionClient) listByServiceCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -417,7 +414,7 @@ func (client *PrivateEndpointConnectionClient) listByServiceHandleResponse(resp // ListPrivateLinkResources - Gets the private link resources // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - PrivateEndpointConnectionClientListPrivateLinkResourcesOptions contains the optional parameters for the PrivateEndpointConnectionClient.ListPrivateLinkResources @@ -445,7 +442,7 @@ func (client *PrivateEndpointConnectionClient) ListPrivateLinkResources(ctx cont } // listPrivateLinkResourcesCreateRequest creates the ListPrivateLinkResources request. -func (client *PrivateEndpointConnectionClient) listPrivateLinkResourcesCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PrivateEndpointConnectionClientListPrivateLinkResourcesOptions) (*policy.Request, error) { +func (client *PrivateEndpointConnectionClient) listPrivateLinkResourcesCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *PrivateEndpointConnectionClientListPrivateLinkResourcesOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -464,7 +461,7 @@ func (client *PrivateEndpointConnectionClient) listPrivateLinkResourcesCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/privateendpointconnection_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/privateendpointconnection_client_example_test.go deleted file mode 100644 index 8b3cec43a6e0..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/privateendpointconnection_client_example_test.go +++ /dev/null @@ -1,250 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPrivateEndpointConnections.json -func ExamplePrivateEndpointConnectionClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPrivateEndpointConnectionClient().NewListByServicePager("rg1", "apimService1", 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.PrivateEndpointConnectionListResult = armapimanagement.PrivateEndpointConnectionListResult{ - // Value: []*armapimanagement.PrivateEndpointConnection{ - // { - // Name: to.Ptr("privateEndpointProxyName"), - // Type: to.Ptr("Microsoft.ApiManagement/service/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/connectionName"), - // Properties: &armapimanagement.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armapimanagement.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), - // }, - // PrivateLinkServiceConnectionState: &armapimanagement.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Please approve my request, thanks"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armapimanagement.PrivateEndpointServiceConnectionStatusPending), - // }, - // ProvisioningState: to.Ptr(armapimanagement.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }, - // { - // Name: to.Ptr("privateEndpointProxyName2"), - // Type: to.Ptr("Microsoft.ApiManagement/service/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/privateEndpointProxyName2"), - // Properties: &armapimanagement.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armapimanagement.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/privateEndpoints/privateEndpointName2"), - // }, - // PrivateLinkServiceConnectionState: &armapimanagement.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Please approve my request, thanks"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armapimanagement.PrivateEndpointServiceConnectionStatusPending), - // }, - // ProvisioningState: to.Ptr(armapimanagement.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPrivateEndpointConnection.json -func ExamplePrivateEndpointConnectionClient_GetByName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPrivateEndpointConnectionClient().GetByName(ctx, "rg1", "apimService1", "privateEndpointConnectionName", 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.PrivateEndpointConnection = armapimanagement.PrivateEndpointConnection{ - // Name: to.Ptr("privateEndpointProxyName"), - // Type: to.Ptr("Microsoft.ApiManagement/service/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/privateEndpointConnectionName"), - // Properties: &armapimanagement.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armapimanagement.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), - // }, - // PrivateLinkServiceConnectionState: &armapimanagement.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Please approve my request, thanks"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armapimanagement.PrivateEndpointServiceConnectionStatusPending), - // }, - // ProvisioningState: to.Ptr(armapimanagement.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementApproveOrRejectPrivateEndpointConnection.json -func ExamplePrivateEndpointConnectionClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPrivateEndpointConnectionClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", "privateEndpointConnectionName", armapimanagement.PrivateEndpointConnectionRequest{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/connectionName"), - Properties: &armapimanagement.PrivateEndpointConnectionRequestProperties{ - PrivateLinkServiceConnectionState: &armapimanagement.PrivateLinkServiceConnectionState{ - Description: to.Ptr("The Private Endpoint Connection is approved."), - Status: to.Ptr(armapimanagement.PrivateEndpointServiceConnectionStatusApproved), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PrivateEndpointConnection = armapimanagement.PrivateEndpointConnection{ - // Name: to.Ptr("privateEndpointConnectionName"), - // Type: to.Ptr("Microsoft.ApiManagement/service/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/privateEndpointConnectionName"), - // Properties: &armapimanagement.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armapimanagement.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), - // }, - // PrivateLinkServiceConnectionState: &armapimanagement.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("The request has been approved."), - // Status: to.Ptr(armapimanagement.PrivateEndpointServiceConnectionStatus("Succeeded")), - // }, - // ProvisioningState: to.Ptr(armapimanagement.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeletePrivateEndpointConnection.json -func ExamplePrivateEndpointConnectionClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPrivateEndpointConnectionClient().BeginDelete(ctx, "rg1", "apimService1", "privateEndpointConnectionName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListPrivateLinkGroupResources.json -func ExamplePrivateEndpointConnectionClient_ListPrivateLinkResources() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPrivateEndpointConnectionClient().ListPrivateLinkResources(ctx, "rg1", "apimService1", 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.PrivateLinkResourceListResult = armapimanagement.PrivateLinkResourceListResult{ - // Value: []*armapimanagement.PrivateLinkResource{ - // { - // Name: to.Ptr("Gateway"), - // Type: to.Ptr("Microsoft.ApiManagement/service/privateLinkResources"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateLinkResources/Gateway"), - // Properties: &armapimanagement.PrivateLinkResourceProperties{ - // GroupID: to.Ptr("Gateway"), - // RequiredMembers: []*string{ - // to.Ptr("Gateway")}, - // RequiredZoneNames: []*string{ - // to.Ptr("privateLink.azure-api.net")}, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetPrivateLinkGroupResource.json -func ExamplePrivateEndpointConnectionClient_GetPrivateLinkResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPrivateEndpointConnectionClient().GetPrivateLinkResource(ctx, "rg1", "apimService1", "privateLinkSubResourceName", 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.PrivateLinkResource = armapimanagement.PrivateLinkResource{ - // Name: to.Ptr("Gateway"), - // Type: to.Ptr("Microsoft.ApiManagement/service/privateLinkResources"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateLinkResources/Gateway"), - // Properties: &armapimanagement.PrivateLinkResourceProperties{ - // GroupID: to.Ptr("Gateway"), - // RequiredMembers: []*string{ - // to.Ptr("Gateway")}, - // RequiredZoneNames: []*string{ - // to.Ptr("privateLink.azure-api.net")}, - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/product_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/product_client.go index 8642be182f03..019731b756f6 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/product_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/product_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type ProductClient struct { } // NewProductClient creates a new instance of ProductClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewProductClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductClient, error) { @@ -47,7 +44,7 @@ func NewProductClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Creates or Updates a product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -99,12 +96,12 @@ func (client *ProductClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -126,7 +123,7 @@ func (client *ProductClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - Delete product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -178,20 +175,20 @@ func (client *ProductClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.DeleteSubscriptions != nil { reqQP.Set("deleteSubscriptions", strconv.FormatBool(*options.DeleteSubscriptions)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the product specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -219,7 +216,7 @@ func (client *ProductClient) Get(ctx context.Context, resourceGroupName string, } // getCreateRequest creates the Get request. -func (client *ProductClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductClientGetOptions) (*policy.Request, error) { +func (client *ProductClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, _ *ProductClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -242,7 +239,7 @@ func (client *ProductClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -262,7 +259,7 @@ func (client *ProductClient) getHandleResponse(resp *http.Response) (ProductClie // GetEntityTag - Gets the entity state (Etag) version of the product specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -290,7 +287,7 @@ func (client *ProductClient) GetEntityTag(ctx context.Context, resourceGroupName } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *ProductClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductClientGetEntityTagOptions) (*policy.Request, error) { +func (client *ProductClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, _ *ProductClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -313,7 +310,7 @@ func (client *ProductClient) getEntityTagCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -330,7 +327,7 @@ func (client *ProductClient) getEntityTagHandleResponse(resp *http.Response) (Pr // NewListByServicePager - Lists a collection of products in the specified service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - ProductClientListByServiceOptions contains the optional parameters for the ProductClient.NewListByServicePager @@ -381,19 +378,19 @@ func (client *ProductClient) listByServiceCreateRequest(ctx context.Context, res if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.ExpandGroups != nil { reqQP.Set("expandGroups", strconv.FormatBool(*options.ExpandGroups)) } if options != nil && options.Tags != nil { reqQP.Set("tags", *options.Tags) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -410,7 +407,7 @@ func (client *ProductClient) listByServiceHandleResponse(resp *http.Response) (P // NewListByTagsPager - Lists a collection of products associated with tags. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - ProductClientListByTagsOptions contains the optional parameters for the ProductClient.NewListByTagsPager method. @@ -460,16 +457,16 @@ func (client *ProductClient) listByTagsCreateRequest(ctx context.Context, resour if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.IncludeNotTaggedProducts != nil { reqQP.Set("includeNotTaggedProducts", strconv.FormatBool(*options.IncludeNotTaggedProducts)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -487,7 +484,7 @@ func (client *ProductClient) listByTagsHandleResponse(resp *http.Response) (Prod // Update - Update existing product details. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -518,7 +515,7 @@ func (client *ProductClient) Update(ctx context.Context, resourceGroupName strin } // updateCreateRequest creates the Update request. -func (client *ProductClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, parameters ProductUpdateParameters, options *ProductClientUpdateOptions) (*policy.Request, error) { +func (client *ProductClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, parameters ProductUpdateParameters, _ *ProductClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -541,10 +538,10 @@ func (client *ProductClient) updateCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/product_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/product_client_example_test.go deleted file mode 100644 index cede358f7aa2..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/product_client_example_test.go +++ /dev/null @@ -1,279 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProducts.json -func ExampleProductClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewProductClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.ProductClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: nil, - ExpandGroups: nil, - Tags: 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.ProductCollection = armapimanagement.ProductCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.ProductContract{ - // { - // Name: to.Ptr("kjoshiarmtemplateCert1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/kjoshiarmtemplateCert1"), - // Properties: &armapimanagement.ProductContractProperties{ - // Description: to.Ptr("Development Product"), - // State: to.Ptr(armapimanagement.ProductStatePublished), - // SubscriptionRequired: to.Ptr(false), - // DisplayName: to.Ptr("Dev"), - // }, - // }, - // { - // Name: to.Ptr("starter"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/starter"), - // Properties: &armapimanagement.ProductContractProperties{ - // Description: to.Ptr("Subscribers will be able to run 5 calls/minute up to a maximum of 100 calls/week."), - // ApprovalRequired: to.Ptr(false), - // State: to.Ptr(armapimanagement.ProductStatePublished), - // SubscriptionRequired: to.Ptr(true), - // SubscriptionsLimit: to.Ptr[int32](1), - // Terms: to.Ptr(""), - // DisplayName: to.Ptr("Starter"), - // }, - // }, - // { - // Name: to.Ptr("unlimited"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/unlimited"), - // Properties: &armapimanagement.ProductContractProperties{ - // Description: to.Ptr("Subscribers have completely unlimited access to the API. Administrator approval is required."), - // ApprovalRequired: to.Ptr(true), - // State: to.Ptr(armapimanagement.ProductStatePublished), - // SubscriptionRequired: to.Ptr(true), - // SubscriptionsLimit: to.Ptr[int32](1), - // DisplayName: to.Ptr("Unlimited"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProduct.json -func ExampleProductClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductClient().GetEntityTag(ctx, "rg1", "apimService1", "unlimited", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetProduct.json -func ExampleProductClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductClient().Get(ctx, "rg1", "apimService1", "unlimited", 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.ProductContract = armapimanagement.ProductContract{ - // Name: to.Ptr("unlimited"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/unlimited"), - // Properties: &armapimanagement.ProductContractProperties{ - // Description: to.Ptr("Subscribers have completely unlimited access to the API. Administrator approval is required."), - // ApprovalRequired: to.Ptr(true), - // State: to.Ptr(armapimanagement.ProductStatePublished), - // SubscriptionRequired: to.Ptr(true), - // SubscriptionsLimit: to.Ptr[int32](1), - // DisplayName: to.Ptr("Unlimited"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProduct.json -func ExampleProductClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductClient().CreateOrUpdate(ctx, "rg1", "apimService1", "testproduct", armapimanagement.ProductContract{ - Properties: &armapimanagement.ProductContractProperties{ - DisplayName: to.Ptr("Test Template ProductName 4"), - }, - }, &armapimanagement.ProductClientCreateOrUpdateOptions{IfMatch: 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.ProductContract = armapimanagement.ProductContract{ - // Name: to.Ptr("testproduct"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/testproduct"), - // Properties: &armapimanagement.ProductContractProperties{ - // ApprovalRequired: to.Ptr(false), - // State: to.Ptr(armapimanagement.ProductStateNotPublished), - // SubscriptionRequired: to.Ptr(true), - // DisplayName: to.Ptr("Test Template ProductName 4"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateProduct.json -func ExampleProductClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductClient().Update(ctx, "rg1", "apimService1", "testproduct", "*", armapimanagement.ProductUpdateParameters{ - Properties: &armapimanagement.ProductUpdateProperties{ - DisplayName: to.Ptr("Test Template ProductName 4"), - }, - }, 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.ProductContract = armapimanagement.ProductContract{ - // Name: to.Ptr("testproduct"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/testproduct"), - // Properties: &armapimanagement.ProductContractProperties{ - // Description: to.Ptr("Subscribers have completely unlimited access to the API. Administrator approval is required."), - // ApprovalRequired: to.Ptr(true), - // State: to.Ptr(armapimanagement.ProductStatePublished), - // SubscriptionRequired: to.Ptr(true), - // SubscriptionsLimit: to.Ptr[int32](1), - // DisplayName: to.Ptr("Test Template ProductName 4"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProduct.json -func ExampleProductClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductClient().Delete(ctx, "rg1", "apimService1", "testproduct", "*", &armapimanagement.ProductClientDeleteOptions{DeleteSubscriptions: to.Ptr(true)}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductsByTags.json -func ExampleProductClient_NewListByTagsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewProductClient().NewListByTagsPager("rg1", "apimService1", &armapimanagement.ProductClientListByTagsOptions{Filter: nil, - Top: nil, - Skip: nil, - IncludeNotTaggedProducts: 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.TagResourceCollection = armapimanagement.TagResourceCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.TagResourceContract{ - // { - // Product: &armapimanagement.ProductTagResourceContractProperties{ - // Description: to.Ptr("Subscribers will be able to run 5 calls/minute up to a maximum of 100 calls/week."), - // ApprovalRequired: to.Ptr(false), - // State: to.Ptr(armapimanagement.ProductStatePublished), - // SubscriptionRequired: to.Ptr(true), - // SubscriptionsLimit: to.Ptr[int32](1), - // Terms: to.Ptr(""), - // Name: to.Ptr("Starter"), - // ID: to.Ptr("/products/starter"), - // }, - // Tag: &armapimanagement.TagResourceContractProperties{ - // Name: to.Ptr("awesomeTag"), - // ID: to.Ptr("/tags/apitag123"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productapi_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/productapi_client.go index c968dc525a77..9fe26f1c88ac 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productapi_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/productapi_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type ProductAPIClient struct { } // NewProductAPIClient creates a new instance of ProductAPIClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewProductAPIClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductAPIClient, error) { @@ -46,7 +43,7 @@ func NewProductAPIClient(subscriptionID string, credential azcore.TokenCredentia // CheckEntityExists - Checks that API entity specified by identifier is associated with the Product entity. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -76,7 +73,7 @@ func (client *ProductAPIClient) CheckEntityExists(ctx context.Context, resourceG } // checkEntityExistsCreateRequest creates the CheckEntityExists request. -func (client *ProductAPIClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, options *ProductAPIClientCheckEntityExistsOptions) (*policy.Request, error) { +func (client *ProductAPIClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, _ *ProductAPIClientCheckEntityExistsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -103,7 +100,7 @@ func (client *ProductAPIClient) checkEntityExistsCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -112,7 +109,7 @@ func (client *ProductAPIClient) checkEntityExistsCreateRequest(ctx context.Conte // CreateOrUpdate - Adds an API to the specified product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -143,7 +140,7 @@ func (client *ProductAPIClient) CreateOrUpdate(ctx context.Context, resourceGrou } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ProductAPIClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, options *ProductAPIClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ProductAPIClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, _ *ProductAPIClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -170,7 +167,7 @@ func (client *ProductAPIClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -188,7 +185,7 @@ func (client *ProductAPIClient) createOrUpdateHandleResponse(resp *http.Response // Delete - Deletes the specified API from the specified product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -217,7 +214,7 @@ func (client *ProductAPIClient) Delete(ctx context.Context, resourceGroupName st } // deleteCreateRequest creates the Delete request. -func (client *ProductAPIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, options *ProductAPIClientDeleteOptions) (*policy.Request, error) { +func (client *ProductAPIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, _ *ProductAPIClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -244,7 +241,7 @@ func (client *ProductAPIClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -252,7 +249,7 @@ func (client *ProductAPIClient) deleteCreateRequest(ctx context.Context, resourc // NewListByProductPager - Lists a collection of the APIs associated with a product. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -308,13 +305,13 @@ func (client *ProductAPIClient) listByProductCreateRequest(ctx context.Context, if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productapi_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/productapi_client_example_test.go deleted file mode 100644 index cf020b8b9f1f..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productapi_client_example_test.go +++ /dev/null @@ -1,138 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductApis.json -func ExampleProductAPIClient_NewListByProductPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewProductAPIClient().NewListByProductPager("rg1", "apimService1", "5768181ea40f7eb6c49f6ac7", &armapimanagement.ProductAPIClientListByProductOptions{Filter: nil, - Top: nil, - Skip: 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.APICollection = armapimanagement.APICollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.APIContract{ - // { - // Name: to.Ptr("57681820a40f7eb6c49f6aca"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5768181ea40f7eb6c49f6ac7/apis/57681820a40f7eb6c49f6aca"), - // Properties: &armapimanagement.APIContractProperties{ - // Description: to.Ptr("description_57681820a40f7eb6c49f6acc"), - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // Path: to.Ptr("suffix_57681820a40f7eb6c49f6ace"), - // DisplayName: to.Ptr("api_57681820a40f7eb6c49f6acb"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("http://contoso/57681820a40f7eb6c49f6acd"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductApi.json -func ExampleProductAPIClient_CheckEntityExists() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductAPIClient().CheckEntityExists(ctx, "rg1", "apimService1", "5931a75ae4bbd512a88c680b", "59306a29e4bbd510dc24e5f9", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductApi.json -func ExampleProductAPIClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductAPIClient().CreateOrUpdate(ctx, "rg1", "apimService1", "testproduct", "echo-api", 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.APIContract = armapimanagement.APIContract{ - // Name: to.Ptr("5931a75ae4bbd512a88c680b"), - // Type: to.Ptr("Microsoft.ApiManagement/service/apis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5931a75ae4bbd512a88c680b"), - // Properties: &armapimanagement.APIContractProperties{ - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // SubscriptionKeyParameterNames: &armapimanagement.SubscriptionKeyParameterNamesContract{ - // Header: to.Ptr("Ocp-Apim-Subscription-Key"), - // Query: to.Ptr("subscription-key"), - // }, - // Path: to.Ptr(""), - // DisplayName: to.Ptr("EchoApi"), - // Protocols: []*armapimanagement.Protocol{ - // to.Ptr(armapimanagement.ProtocolHTTP), - // to.Ptr(armapimanagement.ProtocolHTTPS)}, - // ServiceURL: to.Ptr("https://contoso.com/apis/echo"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductApi.json -func ExampleProductAPIClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductAPIClient().Delete(ctx, "rg1", "apimService1", "testproduct", "echo-api", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productapilink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/productapilink_client.go new file mode 100644 index 000000000000..9474ba821099 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/productapilink_client.go @@ -0,0 +1,341 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// ProductAPILinkClient contains the methods for the ProductAPILink group. +// Don't use this type directly, use NewProductAPILinkClient() instead. +type ProductAPILinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewProductAPILinkClient creates a new instance of ProductAPILinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewProductAPILinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductAPILinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ProductAPILinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds an API to the specified product via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Product-API link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - ProductAPILinkClientCreateOrUpdateOptions contains the optional parameters for the ProductAPILinkClient.CreateOrUpdate +// method. +func (client *ProductAPILinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiLinkID string, parameters ProductAPILinkContract, options *ProductAPILinkClientCreateOrUpdateOptions) (ProductAPILinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ProductAPILinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, productID, apiLinkID, parameters, options) + if err != nil { + return ProductAPILinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductAPILinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ProductAPILinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProductAPILinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiLinkID string, parameters ProductAPILinkContract, _ *ProductAPILinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks/{apiLinkId}" + 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 productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ProductAPILinkClient) createOrUpdateHandleResponse(resp *http.Response) (ProductAPILinkClientCreateOrUpdateResponse, error) { + result := ProductAPILinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductAPILinkContract); err != nil { + return ProductAPILinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified API from the specified product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Product-API link identifier. Must be unique in the current API Management service instance. +// - options - ProductAPILinkClientDeleteOptions contains the optional parameters for the ProductAPILinkClient.Delete method. +func (client *ProductAPILinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiLinkID string, options *ProductAPILinkClientDeleteOptions) (ProductAPILinkClientDeleteResponse, error) { + var err error + const operationName = "ProductAPILinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, productID, apiLinkID, options) + if err != nil { + return ProductAPILinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductAPILinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ProductAPILinkClientDeleteResponse{}, err + } + return ProductAPILinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProductAPILinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiLinkID string, _ *ProductAPILinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks/{apiLinkId}" + 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 productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the API link for the product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Product-API link identifier. Must be unique in the current API Management service instance. +// - options - ProductAPILinkClientGetOptions contains the optional parameters for the ProductAPILinkClient.Get method. +func (client *ProductAPILinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiLinkID string, options *ProductAPILinkClientGetOptions) (ProductAPILinkClientGetResponse, error) { + var err error + const operationName = "ProductAPILinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, productID, apiLinkID, options) + if err != nil { + return ProductAPILinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductAPILinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ProductAPILinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ProductAPILinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiLinkID string, _ *ProductAPILinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks/{apiLinkId}" + 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 productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProductAPILinkClient) getHandleResponse(resp *http.Response) (ProductAPILinkClientGetResponse, error) { + result := ProductAPILinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.ProductAPILinkContract); err != nil { + return ProductAPILinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the API links associated with a product. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - options - ProductAPILinkClientListByProductOptions contains the optional parameters for the ProductAPILinkClient.NewListByProductPager +// method. +func (client *ProductAPILinkClient) NewListByProductPager(resourceGroupName string, serviceName string, productID string, options *ProductAPILinkClientListByProductOptions) *runtime.Pager[ProductAPILinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[ProductAPILinkClientListByProductResponse]{ + More: func(page ProductAPILinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProductAPILinkClientListByProductResponse) (ProductAPILinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ProductAPILinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + }, nil) + if err != nil { + return ProductAPILinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *ProductAPILinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductAPILinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks" + 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 productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *ProductAPILinkClient) listByProductHandleResponse(resp *http.Response) (ProductAPILinkClientListByProductResponse, error) { + result := ProductAPILinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductAPILinkCollection); err != nil { + return ProductAPILinkClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productgroup_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/productgroup_client.go index 04209e507425..960f37fef586 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productgroup_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/productgroup_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type ProductGroupClient struct { } // NewProductGroupClient creates a new instance of ProductGroupClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewProductGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductGroupClient, error) { @@ -46,7 +43,7 @@ func NewProductGroupClient(subscriptionID string, credential azcore.TokenCredent // CheckEntityExists - Checks that Group entity specified by identifier is associated with the Product entity. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -75,7 +72,7 @@ func (client *ProductGroupClient) CheckEntityExists(ctx context.Context, resourc } // checkEntityExistsCreateRequest creates the CheckEntityExists request. -func (client *ProductGroupClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, options *ProductGroupClientCheckEntityExistsOptions) (*policy.Request, error) { +func (client *ProductGroupClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, _ *ProductGroupClientCheckEntityExistsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -102,7 +99,7 @@ func (client *ProductGroupClient) checkEntityExistsCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -111,7 +108,7 @@ func (client *ProductGroupClient) checkEntityExistsCreateRequest(ctx context.Con // CreateOrUpdate - Adds the association between the specified developer group with the specified product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -141,7 +138,7 @@ func (client *ProductGroupClient) CreateOrUpdate(ctx context.Context, resourceGr } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ProductGroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, options *ProductGroupClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ProductGroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, _ *ProductGroupClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -168,7 +165,7 @@ func (client *ProductGroupClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -186,7 +183,7 @@ func (client *ProductGroupClient) createOrUpdateHandleResponse(resp *http.Respon // Delete - Deletes the association between the specified group and product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -214,7 +211,7 @@ func (client *ProductGroupClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *ProductGroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, options *ProductGroupClientDeleteOptions) (*policy.Request, error) { +func (client *ProductGroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, _ *ProductGroupClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -241,7 +238,7 @@ func (client *ProductGroupClient) deleteCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -249,7 +246,7 @@ func (client *ProductGroupClient) deleteCreateRequest(ctx context.Context, resou // NewListByProductPager - Lists the collection of developer groups associated with the specified product. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -305,13 +302,13 @@ func (client *ProductGroupClient) listByProductCreateRequest(ctx context.Context if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productgroup_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/productgroup_client_example_test.go deleted file mode 100644 index 79aa3fc152e4..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productgroup_client_example_test.go +++ /dev/null @@ -1,148 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductGroups.json -func ExampleProductGroupClient_NewListByProductPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewProductGroupClient().NewListByProductPager("rg1", "apimService1", "5600b57e7e8880006a060002", &armapimanagement.ProductGroupClientListByProductOptions{Filter: nil, - Top: nil, - Skip: 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.GroupCollection = armapimanagement.GroupCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.GroupContract{ - // { - // Name: to.Ptr("5600b57e7e8880006a020001"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b57e7e8880006a060002/groups/5600b57e7e8880006a020001"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeSystem), - // Description: to.Ptr("Administrators is a built-in group. Its membership is managed by the system. Microsoft Azure subscription administrators fall into this group."), - // BuiltIn: to.Ptr(true), - // DisplayName: to.Ptr("Administrators"), - // }, - // }, - // { - // Name: to.Ptr("5600b57e7e8880006a020002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b57e7e8880006a060002/groups/5600b57e7e8880006a020002"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeSystem), - // Description: to.Ptr("Developers is a built-in group. Its membership is managed by the system. Signed-in users fall into this group."), - // BuiltIn: to.Ptr(true), - // DisplayName: to.Ptr("Developers"), - // }, - // }, - // { - // Name: to.Ptr("5600b57e7e8880006a020003"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b57e7e8880006a060002/groups/5600b57e7e8880006a020003"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeSystem), - // Description: to.Ptr("Guests is a built-in group. Its membership is managed by the system. Unauthenticated users visiting the developer portal fall into this group."), - // BuiltIn: to.Ptr(true), - // DisplayName: to.Ptr("Guests"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductGroup.json -func ExampleProductGroupClient_CheckEntityExists() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductGroupClient().CheckEntityExists(ctx, "rg1", "apimService1", "5931a75ae4bbd512a88c680b", "59306a29e4bbd510dc24e5f9", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductGroup.json -func ExampleProductGroupClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductGroupClient().CreateOrUpdate(ctx, "rg1", "apimService1", "testproduct", "templateGroup", 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.GroupContract = armapimanagement.GroupContract{ - // Name: to.Ptr("templateGroup"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/templateGroup"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeCustom), - // Description: to.Ptr("group created via Template"), - // BuiltIn: to.Ptr(false), - // DisplayName: to.Ptr("Template Group"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductGroup.json -func ExampleProductGroupClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductGroupClient().Delete(ctx, "rg1", "apimService1", "testproduct", "templateGroup", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productgrouplink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/productgrouplink_client.go new file mode 100644 index 000000000000..f5f8cf42b13b --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/productgrouplink_client.go @@ -0,0 +1,341 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// ProductGroupLinkClient contains the methods for the ProductGroupLink group. +// Don't use this type directly, use NewProductGroupLinkClient() instead. +type ProductGroupLinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewProductGroupLinkClient creates a new instance of ProductGroupLinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewProductGroupLinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductGroupLinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ProductGroupLinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds a group to the specified product via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - groupLinkID - Product-Group link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - ProductGroupLinkClientCreateOrUpdateOptions contains the optional parameters for the ProductGroupLinkClient.CreateOrUpdate +// method. +func (client *ProductGroupLinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupLinkID string, parameters ProductGroupLinkContract, options *ProductGroupLinkClientCreateOrUpdateOptions) (ProductGroupLinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ProductGroupLinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, productID, groupLinkID, parameters, options) + if err != nil { + return ProductGroupLinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductGroupLinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ProductGroupLinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProductGroupLinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupLinkID string, parameters ProductGroupLinkContract, _ *ProductGroupLinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks/{groupLinkId}" + 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 productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if groupLinkID == "" { + return nil, errors.New("parameter groupLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupLinkId}", url.PathEscape(groupLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ProductGroupLinkClient) createOrUpdateHandleResponse(resp *http.Response) (ProductGroupLinkClientCreateOrUpdateResponse, error) { + result := ProductGroupLinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductGroupLinkContract); err != nil { + return ProductGroupLinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified group from the specified product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - groupLinkID - Product-Group link identifier. Must be unique in the current API Management service instance. +// - options - ProductGroupLinkClientDeleteOptions contains the optional parameters for the ProductGroupLinkClient.Delete method. +func (client *ProductGroupLinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupLinkID string, options *ProductGroupLinkClientDeleteOptions) (ProductGroupLinkClientDeleteResponse, error) { + var err error + const operationName = "ProductGroupLinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, productID, groupLinkID, options) + if err != nil { + return ProductGroupLinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductGroupLinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ProductGroupLinkClientDeleteResponse{}, err + } + return ProductGroupLinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProductGroupLinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupLinkID string, _ *ProductGroupLinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks/{groupLinkId}" + 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 productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if groupLinkID == "" { + return nil, errors.New("parameter groupLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupLinkId}", url.PathEscape(groupLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the group link for the product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - groupLinkID - Product-Group link identifier. Must be unique in the current API Management service instance. +// - options - ProductGroupLinkClientGetOptions contains the optional parameters for the ProductGroupLinkClient.Get method. +func (client *ProductGroupLinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupLinkID string, options *ProductGroupLinkClientGetOptions) (ProductGroupLinkClientGetResponse, error) { + var err error + const operationName = "ProductGroupLinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, productID, groupLinkID, options) + if err != nil { + return ProductGroupLinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProductGroupLinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ProductGroupLinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ProductGroupLinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupLinkID string, _ *ProductGroupLinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks/{groupLinkId}" + 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 productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if groupLinkID == "" { + return nil, errors.New("parameter groupLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupLinkId}", url.PathEscape(groupLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProductGroupLinkClient) getHandleResponse(resp *http.Response) (ProductGroupLinkClientGetResponse, error) { + result := ProductGroupLinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.ProductGroupLinkContract); err != nil { + return ProductGroupLinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the group links associated with a product. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - options - ProductGroupLinkClientListByProductOptions contains the optional parameters for the ProductGroupLinkClient.NewListByProductPager +// method. +func (client *ProductGroupLinkClient) NewListByProductPager(resourceGroupName string, serviceName string, productID string, options *ProductGroupLinkClientListByProductOptions) *runtime.Pager[ProductGroupLinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[ProductGroupLinkClientListByProductResponse]{ + More: func(page ProductGroupLinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProductGroupLinkClientListByProductResponse) (ProductGroupLinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ProductGroupLinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + }, nil) + if err != nil { + return ProductGroupLinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *ProductGroupLinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductGroupLinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks" + 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 productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *ProductGroupLinkClient) listByProductHandleResponse(resp *http.Response) (ProductGroupLinkClientListByProductResponse, error) { + result := ProductGroupLinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductGroupLinkCollection); err != nil { + return ProductGroupLinkClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productpolicy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/productpolicy_client.go index 53e4aedff3f0..52b226b4448b 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productpolicy_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/productpolicy_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type ProductPolicyClient struct { } // NewProductPolicyClient creates a new instance of ProductPolicyClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewProductPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductPolicyClient, error) { @@ -46,7 +43,7 @@ func NewProductPolicyClient(subscriptionID string, credential azcore.TokenCreden // CreateOrUpdate - Creates or updates policy configuration for the Product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -104,12 +101,12 @@ func (client *ProductPolicyClient) createOrUpdateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -131,7 +128,7 @@ func (client *ProductPolicyClient) createOrUpdateHandleResponse(resp *http.Respo // Delete - Deletes the policy configuration at the Product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -161,7 +158,7 @@ func (client *ProductPolicyClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *ProductPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, ifMatch string, options *ProductPolicyClientDeleteOptions) (*policy.Request, error) { +func (client *ProductPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, ifMatch string, _ *ProductPolicyClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -188,17 +185,17 @@ func (client *ProductPolicyClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Get the policy configuration at the Product level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -254,10 +251,10 @@ func (client *ProductPolicyClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Format != nil { reqQP.Set("format", string(*options.Format)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -277,7 +274,7 @@ func (client *ProductPolicyClient) getHandleResponse(resp *http.Response) (Produ // GetEntityTag - Get the ETag of the policy configuration at the Product level. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -307,7 +304,7 @@ func (client *ProductPolicyClient) GetEntityTag(ctx context.Context, resourceGro } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *ProductPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, options *ProductPolicyClientGetEntityTagOptions) (*policy.Request, error) { +func (client *ProductPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, _ *ProductPolicyClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -334,7 +331,7 @@ func (client *ProductPolicyClient) getEntityTagCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -349,39 +346,39 @@ func (client *ProductPolicyClient) getEntityTagHandleResponse(resp *http.Respons return result, nil } -// ListByProduct - Get the policy configuration at the Product level. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListByProductPager - Get the policy configuration at the Product level. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. -// - options - ProductPolicyClientListByProductOptions contains the optional parameters for the ProductPolicyClient.ListByProduct +// - options - ProductPolicyClientListByProductOptions contains the optional parameters for the ProductPolicyClient.NewListByProductPager // method. -func (client *ProductPolicyClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductPolicyClientListByProductOptions) (ProductPolicyClientListByProductResponse, error) { - var err error - const operationName = "ProductPolicyClient.ListByProduct" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, options) - if err != nil { - return ProductPolicyClientListByProductResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ProductPolicyClientListByProductResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ProductPolicyClientListByProductResponse{}, err - } - resp, err := client.listByProductHandleResponse(httpResp) - return resp, err +func (client *ProductPolicyClient) NewListByProductPager(resourceGroupName string, serviceName string, productID string, options *ProductPolicyClientListByProductOptions) *runtime.Pager[ProductPolicyClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[ProductPolicyClientListByProductResponse]{ + More: func(page ProductPolicyClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProductPolicyClientListByProductResponse) (ProductPolicyClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ProductPolicyClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + }, nil) + if err != nil { + return ProductPolicyClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listByProductCreateRequest creates the ListByProduct request. -func (client *ProductPolicyClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductPolicyClientListByProductOptions) (*policy.Request, error) { +func (client *ProductPolicyClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, _ *ProductPolicyClientListByProductOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -404,7 +401,7 @@ func (client *ProductPolicyClient) listByProductCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productpolicy_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/productpolicy_client_example_test.go deleted file mode 100644 index 7764c61a3be6..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productpolicy_client_example_test.go +++ /dev/null @@ -1,146 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductPolicies.json -func ExampleProductPolicyClient_ListByProduct() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductPolicyClient().ListByProduct(ctx, "rg1", "apimService1", "armTemplateProduct4", 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.PolicyCollection = armapimanagement.PolicyCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.PolicyContract{ - // { - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/armTemplateProduct4/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductPolicy.json -func ExampleProductPolicyClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductPolicyClient().GetEntityTag(ctx, "rg1", "apimService1", "unlimited", armapimanagement.PolicyIDNamePolicy, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetProductPolicy.json -func ExampleProductPolicyClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductPolicyClient().Get(ctx, "rg1", "apimService1", "kjoshiarmTemplateProduct4", armapimanagement.PolicyIDNamePolicy, &armapimanagement.ProductPolicyClientGetOptions{Format: 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/kjoshiarmTemplateProduct4/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductPolicy.json -func ExampleProductPolicyClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductPolicyClient().CreateOrUpdate(ctx, "rg1", "apimService1", "5702e97e5157a50f48dce801", armapimanagement.PolicyIDNamePolicy, armapimanagement.PolicyContract{ - Properties: &armapimanagement.PolicyContractProperties{ - Format: to.Ptr(armapimanagement.PolicyContentFormatXML), - Value: to.Ptr("\r\n \r\n \r\n \r\n @( string.Join(\",\", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) ) \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - }, - }, &armapimanagement.ProductPolicyClientCreateOrUpdateOptions{IfMatch: 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.PolicyContract = armapimanagement.PolicyContract{ - // Name: to.Ptr("policy"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/policies"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5702e97e5157a50f48dce801/policies/policy"), - // Properties: &armapimanagement.PolicyContractProperties{ - // Value: to.Ptr("\r\n \r\n \r\n \r\n @( string.Join(\",\", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) ) \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductPolicy.json -func ExampleProductPolicyClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductPolicyClient().Delete(ctx, "rg1", "apimService1", "testproduct", armapimanagement.PolicyIDNamePolicy, "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productsubscriptions_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/productsubscriptions_client.go index 1e22821fddeb..3cdc660cb074 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productsubscriptions_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/productsubscriptions_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type ProductSubscriptionsClient struct { } // NewProductSubscriptionsClient creates a new instance of ProductSubscriptionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewProductSubscriptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductSubscriptionsClient, error) { @@ -46,7 +43,7 @@ func NewProductSubscriptionsClient(subscriptionID string, credential azcore.Toke // NewListPager - Lists the collection of subscriptions to the specified product. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -102,13 +99,13 @@ func (client *ProductSubscriptionsClient) listCreateRequest(ctx context.Context, if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productsubscriptions_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/productsubscriptions_client_example_test.go deleted file mode 100644 index 441208fc867f..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productsubscriptions_client_example_test.go +++ /dev/null @@ -1,61 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductSubscriptions.json -func ExampleProductSubscriptionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewProductSubscriptionsClient().NewListPager("rg1", "apimService1", "5600b57e7e8880006a060002", &armapimanagement.ProductSubscriptionsClientListOptions{Filter: nil, - Top: nil, - Skip: 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.SubscriptionCollection = armapimanagement.SubscriptionCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.SubscriptionContract{ - // { - // Name: to.Ptr("5600b57e7e8880006a070002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b57e7e8880006a060002/subscriptions/5600b57e7e8880006a070002"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2015-09-22T01:57:18.723Z"); return t}()), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b57e7e8880006a060002"), - // State: to.Ptr(armapimanagement.SubscriptionStateActive), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productwiki_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/productwiki_client.go index d4498d8a71c5..95896fa65f08 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productwiki_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/productwiki_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type ProductWikiClient struct { } // NewProductWikiClient creates a new instance of ProductWikiClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewProductWikiClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductWikiClient, error) { @@ -46,7 +43,7 @@ func NewProductWikiClient(subscriptionID string, credential azcore.TokenCredenti // CreateOrUpdate - Creates a new Wiki for a Product or updates an existing one. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -99,12 +96,12 @@ func (client *ProductWikiClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -126,7 +123,7 @@ func (client *ProductWikiClient) createOrUpdateHandleResponse(resp *http.Respons // Delete - Deletes the specified Wiki from a Product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -155,7 +152,7 @@ func (client *ProductWikiClient) Delete(ctx context.Context, resourceGroupName s } // deleteCreateRequest creates the Delete request. -func (client *ProductWikiClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, options *ProductWikiClientDeleteOptions) (*policy.Request, error) { +func (client *ProductWikiClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, _ *ProductWikiClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis/default" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -178,17 +175,17 @@ func (client *ProductWikiClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the details of the Wiki for a Product specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -216,7 +213,7 @@ func (client *ProductWikiClient) Get(ctx context.Context, resourceGroupName stri } // getCreateRequest creates the Get request. -func (client *ProductWikiClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductWikiClientGetOptions) (*policy.Request, error) { +func (client *ProductWikiClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, _ *ProductWikiClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis/default" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -239,7 +236,7 @@ func (client *ProductWikiClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -259,7 +256,7 @@ func (client *ProductWikiClient) getHandleResponse(resp *http.Response) (Product // GetEntityTag - Gets the entity state (Etag) version of the Wiki for a Product specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -288,7 +285,7 @@ func (client *ProductWikiClient) GetEntityTag(ctx context.Context, resourceGroup } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *ProductWikiClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductWikiClientGetEntityTagOptions) (*policy.Request, error) { +func (client *ProductWikiClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, _ *ProductWikiClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis/default" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -311,7 +308,7 @@ func (client *ProductWikiClient) getEntityTagCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -329,7 +326,7 @@ func (client *ProductWikiClient) getEntityTagHandleResponse(resp *http.Response) // Update - Updates the details of the Wiki for a Product specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -360,7 +357,7 @@ func (client *ProductWikiClient) Update(ctx context.Context, resourceGroupName s } // updateCreateRequest creates the Update request. -func (client *ProductWikiClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, parameters WikiUpdateContract, options *ProductWikiClientUpdateOptions) (*policy.Request, error) { +func (client *ProductWikiClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, parameters WikiUpdateContract, _ *ProductWikiClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis/default" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -383,10 +380,10 @@ func (client *ProductWikiClient) updateCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productwiki_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/productwiki_client_example_test.go deleted file mode 100644 index 70a9022160fe..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productwiki_client_example_test.go +++ /dev/null @@ -1,169 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductWiki.json -func ExampleProductWikiClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductWikiClient().GetEntityTag(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetProductWiki.json -func ExampleProductWikiClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductWikiClient().Get(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", 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.WikiContract = armapimanagement.WikiContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/wikis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/57d1f7558aa04f15146d9d8a/wikis/default"), - // Properties: &armapimanagement.WikiContractProperties{ - // Documents: []*armapimanagement.WikiDocumentationContract{ - // { - // DocumentationID: to.Ptr("docId1"), - // }, - // { - // DocumentationID: to.Ptr("docId2"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductWiki.json -func ExampleProductWikiClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductWikiClient().CreateOrUpdate(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", armapimanagement.WikiContract{ - Properties: &armapimanagement.WikiContractProperties{ - Documents: []*armapimanagement.WikiDocumentationContract{ - { - DocumentationID: to.Ptr("docId1"), - }, - { - DocumentationID: to.Ptr("docId2"), - }}, - }, - }, &armapimanagement.ProductWikiClientCreateOrUpdateOptions{IfMatch: 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.WikiContract = armapimanagement.WikiContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/wikis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/57d1f7558aa04f15146d9d8a/wikis/default"), - // Properties: &armapimanagement.WikiContractProperties{ - // Documents: []*armapimanagement.WikiDocumentationContract{ - // { - // DocumentationID: to.Ptr("docId1"), - // }, - // { - // DocumentationID: to.Ptr("docId2"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateProductWiki.json -func ExampleProductWikiClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProductWikiClient().Update(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "*", armapimanagement.WikiUpdateContract{ - Properties: &armapimanagement.WikiContractProperties{ - Documents: []*armapimanagement.WikiDocumentationContract{ - { - DocumentationID: to.Ptr("docId1"), - }}, - }, - }, 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.WikiContract = armapimanagement.WikiContract{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/wikis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/57d1f7558aa04f15146d9d8a/wikis/default"), - // Properties: &armapimanagement.WikiContractProperties{ - // Documents: []*armapimanagement.WikiDocumentationContract{ - // { - // DocumentationID: to.Ptr("docId1"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductWiki.json -func ExampleProductWikiClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewProductWikiClient().Delete(ctx, "rg1", "apimService1", "57d1f7558aa04f15146d9d8a", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productwikis_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/productwikis_client.go index 7f241adaabb0..35b017d25e8c 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productwikis_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/productwikis_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type ProductWikisClient struct { } // NewProductWikisClient creates a new instance of ProductWikisClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewProductWikisClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductWikisClient, error) { @@ -46,7 +43,7 @@ func NewProductWikisClient(subscriptionID string, credential azcore.TokenCredent // NewListPager - Gets the details of the Wiki for a Product specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -101,13 +98,13 @@ func (client *ProductWikisClient) listCreateRequest(ctx context.Context, resourc if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/productwikis_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/productwikis_client_example_test.go deleted file mode 100644 index 0dd83ba6afb1..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/productwikis_client_example_test.go +++ /dev/null @@ -1,63 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductWikis.json -func ExampleProductWikisClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewProductWikisClient().NewListPager("rg1", "apimService1", "57d1f7558aa04f15146d9d8a", &armapimanagement.ProductWikisClientListOptions{Filter: nil, - Top: nil, - Skip: 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.WikiCollection = armapimanagement.WikiCollection{ - // Value: []*armapimanagement.WikiContract{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ApiManagement/service/products/wikis"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/57d1f7558aa04f15146d9d8a/wikis/default"), - // Properties: &armapimanagement.WikiContractProperties{ - // Documents: []*armapimanagement.WikiDocumentationContract{ - // { - // DocumentationID: to.Ptr("docId1"), - // }, - // { - // DocumentationID: to.Ptr("docId2"), - // }}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/quotabycounterkeys_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/quotabycounterkeys_client.go index eb11cd661d30..5bc93ec431bc 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/quotabycounterkeys_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/quotabycounterkeys_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type QuotaByCounterKeysClient struct { } // NewQuotaByCounterKeysClient creates a new instance of QuotaByCounterKeysClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewQuotaByCounterKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QuotaByCounterKeysClient, error) { @@ -47,7 +44,7 @@ func NewQuotaByCounterKeysClient(subscriptionID string, credential azcore.TokenC // on the specified service instance. The api does not support paging yet. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - quotaCounterKey - Quota counter key identifier.This is the result of expression defined in counter-key attribute of the @@ -78,7 +75,7 @@ func (client *QuotaByCounterKeysClient) ListByService(ctx context.Context, resou } // listByServiceCreateRequest creates the ListByService request. -func (client *QuotaByCounterKeysClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, options *QuotaByCounterKeysClientListByServiceOptions) (*policy.Request, error) { +func (client *QuotaByCounterKeysClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, _ *QuotaByCounterKeysClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -101,7 +98,7 @@ func (client *QuotaByCounterKeysClient) listByServiceCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -120,7 +117,7 @@ func (client *QuotaByCounterKeysClient) listByServiceHandleResponse(resp *http.R // service instance. This should be used for reset of the quota counter values. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - quotaCounterKey - Quota counter key identifier.This is the result of expression defined in counter-key attribute of the @@ -152,7 +149,7 @@ func (client *QuotaByCounterKeysClient) Update(ctx context.Context, resourceGrou } // updateCreateRequest creates the Update request. -func (client *QuotaByCounterKeysClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, parameters QuotaCounterValueUpdateContract, options *QuotaByCounterKeysClientUpdateOptions) (*policy.Request, error) { +func (client *QuotaByCounterKeysClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, parameters QuotaCounterValueUpdateContract, _ *QuotaByCounterKeysClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -175,7 +172,7 @@ func (client *QuotaByCounterKeysClient) updateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/quotabycounterkeys_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/quotabycounterkeys_client_example_test.go deleted file mode 100644 index 835eff10a701..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/quotabycounterkeys_client_example_test.go +++ /dev/null @@ -1,90 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetQuotaCounterKeys.json -func ExampleQuotaByCounterKeysClient_ListByService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotaByCounterKeysClient().ListByService(ctx, "rg1", "apimService1", "ba", 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.QuotaCounterCollection = armapimanagement.QuotaCounterCollection{ - // Value: []*armapimanagement.QuotaCounterContract{ - // { - // CounterKey: to.Ptr("ba"), - // PeriodEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T16:54:40.000Z"); return t}()), - // PeriodKey: to.Ptr("0_P3Y6M4DT12H30M5S"), - // PeriodStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2014-08-04T04:24:35.000Z"); return t}()), - // Value: &armapimanagement.QuotaCounterValueContractProperties{ - // CallsCount: to.Ptr[int32](5), - // KbTransferred: to.Ptr[float64](2.5830078125), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateQuotaCounterKey.json -func ExampleQuotaByCounterKeysClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotaByCounterKeysClient().Update(ctx, "rg1", "apimService1", "ba", armapimanagement.QuotaCounterValueUpdateContract{ - Properties: &armapimanagement.QuotaCounterValueContractProperties{ - CallsCount: to.Ptr[int32](0), - KbTransferred: to.Ptr[float64](2.5630078125), - }, - }, 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.QuotaCounterCollection = armapimanagement.QuotaCounterCollection{ - // Value: []*armapimanagement.QuotaCounterContract{ - // { - // CounterKey: to.Ptr("ba"), - // PeriodEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T16:54:40.000Z"); return t}()), - // PeriodKey: to.Ptr("0_P3Y6M4DT12H30M5S"), - // PeriodStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2014-08-04T04:24:35.000Z"); return t}()), - // Value: &armapimanagement.QuotaCounterValueContractProperties{ - // CallsCount: to.Ptr[int32](5), - // KbTransferred: to.Ptr[float64](2.5830078125), - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/quotabyperiodkeys_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/quotabyperiodkeys_client.go index c6faa75cf04d..1949b3901761 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/quotabyperiodkeys_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/quotabyperiodkeys_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type QuotaByPeriodKeysClient struct { } // NewQuotaByPeriodKeysClient creates a new instance of QuotaByPeriodKeysClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewQuotaByPeriodKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QuotaByPeriodKeysClient, error) { @@ -47,7 +44,7 @@ func NewQuotaByPeriodKeysClient(subscriptionID string, credential azcore.TokenCr // instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - quotaCounterKey - Quota counter key identifier.This is the result of expression defined in counter-key attribute of the @@ -78,7 +75,7 @@ func (client *QuotaByPeriodKeysClient) Get(ctx context.Context, resourceGroupNam } // getCreateRequest creates the Get request. -func (client *QuotaByPeriodKeysClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, options *QuotaByPeriodKeysClientGetOptions) (*policy.Request, error) { +func (client *QuotaByPeriodKeysClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, _ *QuotaByPeriodKeysClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -105,7 +102,7 @@ func (client *QuotaByPeriodKeysClient) getCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -123,7 +120,7 @@ func (client *QuotaByPeriodKeysClient) getHandleResponse(resp *http.Response) (Q // Update - Updates an existing quota counter value in the specified service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - quotaCounterKey - Quota counter key identifier.This is the result of expression defined in counter-key attribute of the @@ -156,7 +153,7 @@ func (client *QuotaByPeriodKeysClient) Update(ctx context.Context, resourceGroup } // updateCreateRequest creates the Update request. -func (client *QuotaByPeriodKeysClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, parameters QuotaCounterValueUpdateContract, options *QuotaByPeriodKeysClientUpdateOptions) (*policy.Request, error) { +func (client *QuotaByPeriodKeysClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, parameters QuotaCounterValueUpdateContract, _ *QuotaByPeriodKeysClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -183,7 +180,7 @@ func (client *QuotaByPeriodKeysClient) updateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/quotabyperiodkeys_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/quotabyperiodkeys_client_example_test.go deleted file mode 100644 index bf39122e476b..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/quotabyperiodkeys_client_example_test.go +++ /dev/null @@ -1,84 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetQuotaCounterKeysByQuotaPeriod.json -func ExampleQuotaByPeriodKeysClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotaByPeriodKeysClient().Get(ctx, "rg1", "apimService1", "ba", "0_P3Y6M4DT12H30M5S", 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.QuotaCounterContract = armapimanagement.QuotaCounterContract{ - // CounterKey: to.Ptr("ba"), - // PeriodEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T16:54:40.000Z"); return t}()), - // PeriodKey: to.Ptr("0_P3Y6M4DT12H30M5S"), - // PeriodStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2014-08-04T04:24:35.000Z"); return t}()), - // Value: &armapimanagement.QuotaCounterValueContractProperties{ - // CallsCount: to.Ptr[int32](0), - // KbTransferred: to.Ptr[float64](2.5625), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateQuotaCounterKeyByQuotaPeriod.json -func ExampleQuotaByPeriodKeysClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotaByPeriodKeysClient().Update(ctx, "rg1", "apimService1", "ba", "0_P3Y6M4DT12H30M5S", armapimanagement.QuotaCounterValueUpdateContract{ - Properties: &armapimanagement.QuotaCounterValueContractProperties{ - CallsCount: to.Ptr[int32](0), - KbTransferred: to.Ptr[float64](0), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QuotaCounterContract = armapimanagement.QuotaCounterContract{ - // CounterKey: to.Ptr("ba"), - // PeriodEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-08T16:54:40.000Z"); return t}()), - // PeriodKey: to.Ptr("0_P3Y6M4DT12H30M5S"), - // PeriodStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2014-08-04T04:24:35.000Z"); return t}()), - // Value: &armapimanagement.QuotaCounterValueContractProperties{ - // CallsCount: to.Ptr[int32](0), - // KbTransferred: to.Ptr[float64](2.5625), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/region_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/region_client.go index cf6528894219..0639cb1a9689 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/region_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/region_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type RegionClient struct { } // NewRegionClient creates a new instance of RegionClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewRegionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RegionClient, error) { @@ -45,7 +42,7 @@ func NewRegionClient(subscriptionID string, credential azcore.TokenCredential, o // NewListByServicePager - Lists all azure regions in which the service exists. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - RegionClientListByServiceOptions contains the optional parameters for the RegionClient.NewListByServicePager @@ -74,7 +71,7 @@ func (client *RegionClient) NewListByServicePager(resourceGroupName string, serv } // listByServiceCreateRequest creates the ListByService request. -func (client *RegionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *RegionClientListByServiceOptions) (*policy.Request, error) { +func (client *RegionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *RegionClientListByServiceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -93,7 +90,7 @@ func (client *RegionClient) listByServiceCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/region_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/region_client_example_test.go deleted file mode 100644 index e5df019ad713..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/region_client_example_test.go +++ /dev/null @@ -1,52 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListRegions.json -func ExampleRegionClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewRegionClient().NewListByServicePager("rg1", "apimService1", 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.RegionListResult = armapimanagement.RegionListResult{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.RegionContract{ - // { - // Name: to.Ptr("West US"), - // IsDeleted: to.Ptr(false), - // IsMasterRegion: to.Ptr(true), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/reports_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/reports_client.go index 540928dce79a..87d50333c1b9 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/reports_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/reports_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type ReportsClient struct { } // NewReportsClient creates a new instance of ReportsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewReportsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReportsClient, error) { @@ -46,7 +43,7 @@ func NewReportsClient(subscriptionID string, credential azcore.TokenCredential, // NewListByAPIPager - Lists report records by API. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - filter - The filter to apply on the operation. @@ -95,16 +92,16 @@ func (client *ReportsClient) listByAPICreateRequest(ctx context.Context, resourc } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - if options != nil && options.Orderby != nil { - reqQP.Set("$orderby", *options.Orderby) + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -121,7 +118,7 @@ func (client *ReportsClient) listByAPIHandleResponse(resp *http.Response) (Repor // NewListByGeoPager - Lists report records by geography. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - filter - | Field | Usage | Supported operators | Supported functions | @@ -194,13 +191,13 @@ func (client *ReportsClient) listByGeoCreateRequest(ctx context.Context, resourc } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -217,7 +214,7 @@ func (client *ReportsClient) listByGeoHandleResponse(resp *http.Response) (Repor // NewListByOperationPager - Lists report records by API Operations. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - filter - | Field | Usage | Supported operators | Supported functions | @@ -290,16 +287,16 @@ func (client *ReportsClient) listByOperationCreateRequest(ctx context.Context, r } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - if options != nil && options.Orderby != nil { - reqQP.Set("$orderby", *options.Orderby) + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -316,7 +313,7 @@ func (client *ReportsClient) listByOperationHandleResponse(resp *http.Response) // NewListByProductPager - Lists report records by Product. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - filter - | Field | Usage | Supported operators | Supported functions | @@ -387,16 +384,16 @@ func (client *ReportsClient) listByProductCreateRequest(ctx context.Context, res } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - if options != nil && options.Orderby != nil { - reqQP.Set("$orderby", *options.Orderby) + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -413,7 +410,7 @@ func (client *ReportsClient) listByProductHandleResponse(resp *http.Response) (R // NewListByRequestPager - Lists report records by Request. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - filter - | Field | Usage | Supported operators | Supported functions | @@ -472,13 +469,13 @@ func (client *ReportsClient) listByRequestCreateRequest(ctx context.Context, res } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -495,7 +492,7 @@ func (client *ReportsClient) listByRequestHandleResponse(resp *http.Response) (R // NewListBySubscriptionPager - Lists report records by subscription. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - filter - | Field | Usage | Supported operators | Supported functions | @@ -566,16 +563,16 @@ func (client *ReportsClient) listBySubscriptionCreateRequest(ctx context.Context } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - if options != nil && options.Orderby != nil { - reqQP.Set("$orderby", *options.Orderby) + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -592,7 +589,7 @@ func (client *ReportsClient) listBySubscriptionHandleResponse(resp *http.Respons // NewListByTimePager - Lists report records by Time. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - filter - | Field | Usage | Supported operators | Supported functions | @@ -666,17 +663,17 @@ func (client *ReportsClient) listByTimeCreateRequest(ctx context.Context, resour } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - if options != nil && options.Orderby != nil { - reqQP.Set("$orderby", *options.Orderby) + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2024-05-01") reqQP.Set("interval", interval) - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -693,7 +690,7 @@ func (client *ReportsClient) listByTimeHandleResponse(resp *http.Response) (Repo // NewListByUserPager - Lists report records by User. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - filter - | Field | Usage | Supported operators | Supported functions | @@ -765,16 +762,16 @@ func (client *ReportsClient) listByUserCreateRequest(ctx context.Context, resour } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - if options != nil && options.Orderby != nil { - reqQP.Set("$orderby", *options.Orderby) + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/reports_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/reports_client_example_test.go deleted file mode 100644 index 7815cd6b6dc7..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/reports_client_example_test.go +++ /dev/null @@ -1,607 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetReportsByApi.json -func ExampleReportsClient_NewListByAPIPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReportsClient().NewListByAPIPager("rg1", "apimService1", "timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", &armapimanagement.ReportsClientListByAPIOptions{Top: nil, - Skip: nil, - Orderby: 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.ReportCollection = armapimanagement.ReportCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.ReportRecordContract{ - // { - // Name: to.Ptr("Echo API"), - // APIID: to.Ptr("/apis/5600b59475ff190048040001"), - // APITimeAvg: to.Ptr[float64](0), - // APITimeMax: to.Ptr[float64](0), - // APITimeMin: to.Ptr[float64](0), - // Bandwidth: to.Ptr[int64](0), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](0), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](0), - // CallCountTotal: to.Ptr[int32](0), - // ServiceTimeAvg: to.Ptr[float64](0), - // ServiceTimeMax: to.Ptr[float64](0), - // ServiceTimeMin: to.Ptr[float64](0), - // }, - // { - // Name: to.Ptr("httpbin"), - // APIID: to.Ptr("/apis/57a03a13e4bbd5119c8b19e9"), - // APITimeAvg: to.Ptr[float64](1015.7607923076923), - // APITimeMax: to.Ptr[float64](1819.2173), - // APITimeMin: to.Ptr[float64](330.3206), - // Bandwidth: to.Ptr[int64](11019), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](1), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](13), - // CallCountTotal: to.Ptr[int32](14), - // ServiceTimeAvg: to.Ptr[float64](957.094776923077), - // ServiceTimeMax: to.Ptr[float64](1697.3612), - // ServiceTimeMin: to.Ptr[float64](215.24), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetReportsByUser.json -func ExampleReportsClient_NewListByUserPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReportsClient().NewListByUserPager("rg1", "apimService1", "timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", &armapimanagement.ReportsClientListByUserOptions{Top: nil, - Skip: nil, - Orderby: 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.ReportCollection = armapimanagement.ReportCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.ReportRecordContract{ - // { - // Name: to.Ptr("Administrator"), - // APITimeAvg: to.Ptr[float64](1015.7607923076923), - // APITimeMax: to.Ptr[float64](1819.2173), - // APITimeMin: to.Ptr[float64](330.3206), - // Bandwidth: to.Ptr[int64](11019), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](1), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](13), - // CallCountTotal: to.Ptr[int32](14), - // ServiceTimeAvg: to.Ptr[float64](957.094776923077), - // ServiceTimeMax: to.Ptr[float64](1697.3612), - // ServiceTimeMin: to.Ptr[float64](215.24), - // UserID: to.Ptr("/users/1"), - // }, - // { - // Name: to.Ptr("Samir Solanki"), - // APITimeAvg: to.Ptr[float64](0), - // APITimeMax: to.Ptr[float64](0), - // APITimeMin: to.Ptr[float64](0), - // Bandwidth: to.Ptr[int64](0), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](0), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](0), - // CallCountTotal: to.Ptr[int32](0), - // ServiceTimeAvg: to.Ptr[float64](0), - // ServiceTimeMax: to.Ptr[float64](0), - // ServiceTimeMin: to.Ptr[float64](0), - // UserID: to.Ptr("/users/56eaec62baf08b06e46d27fd"), - // }, - // { - // Name: to.Ptr("Anonymous"), - // APITimeAvg: to.Ptr[float64](0), - // APITimeMax: to.Ptr[float64](0), - // APITimeMin: to.Ptr[float64](0), - // Bandwidth: to.Ptr[int64](0), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](0), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](0), - // CallCountTotal: to.Ptr[int32](0), - // ServiceTimeAvg: to.Ptr[float64](0), - // ServiceTimeMax: to.Ptr[float64](0), - // ServiceTimeMin: to.Ptr[float64](0), - // UserID: to.Ptr("/users/54c800b332965a0035030000"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetReportsByOperation.json -func ExampleReportsClient_NewListByOperationPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReportsClient().NewListByOperationPager("rg1", "apimService1", "timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", &armapimanagement.ReportsClientListByOperationOptions{Top: nil, - Skip: nil, - Orderby: 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.ReportCollection = armapimanagement.ReportCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.ReportRecordContract{ - // { - // Name: to.Ptr("get"), - // OperationID: to.Ptr("/apis/57a03a13e4bbd5119c8b19e9/operations/57a03a1dd8d14f0a780d7d14"), - // APIID: to.Ptr("/apis/57a03a13e4bbd5119c8b19e9"), - // APITimeAvg: to.Ptr[float64](1015.7607923076923), - // APITimeMax: to.Ptr[float64](1819.2173), - // APITimeMin: to.Ptr[float64](330.3206), - // Bandwidth: to.Ptr[int64](11019), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](1), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](13), - // CallCountTotal: to.Ptr[int32](14), - // ServiceTimeAvg: to.Ptr[float64](957.094776923077), - // ServiceTimeMax: to.Ptr[float64](1697.3612), - // ServiceTimeMin: to.Ptr[float64](215.24), - // }, - // { - // Name: to.Ptr("GetWeatherInformation"), - // OperationID: to.Ptr("/apis/57c999d1e4bbd50c988cb2c3/operations/57c999d1e4bbd50df889c93e"), - // APIID: to.Ptr("/apis/57c999d1e4bbd50c988cb2c3"), - // APITimeAvg: to.Ptr[float64](0), - // APITimeMax: to.Ptr[float64](0), - // APITimeMin: to.Ptr[float64](0), - // Bandwidth: to.Ptr[int64](0), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](0), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](0), - // CallCountTotal: to.Ptr[int32](0), - // ServiceTimeAvg: to.Ptr[float64](0), - // ServiceTimeMax: to.Ptr[float64](0), - // ServiceTimeMin: to.Ptr[float64](0), - // }, - // { - // Name: to.Ptr("GetCityForecastByZIP"), - // OperationID: to.Ptr("/apis/57c999d1e4bbd50c988cb2c3/operations/57c999d1e4bbd50df889c93f"), - // APIID: to.Ptr("/apis/57c999d1e4bbd50c988cb2c3"), - // APITimeAvg: to.Ptr[float64](0), - // APITimeMax: to.Ptr[float64](0), - // APITimeMin: to.Ptr[float64](0), - // Bandwidth: to.Ptr[int64](0), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](0), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](0), - // CallCountTotal: to.Ptr[int32](0), - // ServiceTimeAvg: to.Ptr[float64](0), - // ServiceTimeMax: to.Ptr[float64](0), - // ServiceTimeMin: to.Ptr[float64](0), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetReportsByProduct.json -func ExampleReportsClient_NewListByProductPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReportsClient().NewListByProductPager("rg1", "apimService1", "timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", &armapimanagement.ReportsClientListByProductOptions{Top: nil, - Skip: nil, - Orderby: 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.ReportCollection = armapimanagement.ReportCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.ReportRecordContract{ - // { - // Name: to.Ptr("Starter"), - // APITimeAvg: to.Ptr[float64](0), - // APITimeMax: to.Ptr[float64](0), - // APITimeMin: to.Ptr[float64](0), - // Bandwidth: to.Ptr[int64](0), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](0), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](0), - // CallCountTotal: to.Ptr[int32](0), - // ProductID: to.Ptr("/products/5600b59475ff190048060001"), - // ServiceTimeAvg: to.Ptr[float64](0), - // ServiceTimeMax: to.Ptr[float64](0), - // ServiceTimeMin: to.Ptr[float64](0), - // }, - // { - // Name: to.Ptr("Unlimited"), - // APITimeAvg: to.Ptr[float64](1015.7607923076923), - // APITimeMax: to.Ptr[float64](1819.2173), - // APITimeMin: to.Ptr[float64](330.3206), - // Bandwidth: to.Ptr[int64](11019), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](1), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](13), - // CallCountTotal: to.Ptr[int32](14), - // ProductID: to.Ptr("/products/5600b59475ff190048060002"), - // ServiceTimeAvg: to.Ptr[float64](957.094776923077), - // ServiceTimeMax: to.Ptr[float64](1697.3612), - // ServiceTimeMin: to.Ptr[float64](215.24), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetReportsByGeo.json -func ExampleReportsClient_NewListByGeoPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReportsClient().NewListByGeoPager("rg1", "apimService1", "timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", &armapimanagement.ReportsClientListByGeoOptions{Top: nil, - Skip: 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.ReportCollection = armapimanagement.ReportCollection{ - // Value: []*armapimanagement.ReportRecordContract{ - // { - // APITimeAvg: to.Ptr[float64](1015.7607923076923), - // APITimeMax: to.Ptr[float64](1819.2173), - // APITimeMin: to.Ptr[float64](330.3206), - // Bandwidth: to.Ptr[int64](11019), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](1), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](13), - // CallCountTotal: to.Ptr[int32](14), - // Country: to.Ptr("US"), - // Region: to.Ptr("WA"), - // ServiceTimeAvg: to.Ptr[float64](957.094776923077), - // ServiceTimeMax: to.Ptr[float64](1697.3612), - // ServiceTimeMin: to.Ptr[float64](215.24), - // Zip: to.Ptr("98052"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetReportsBySubscription.json -func ExampleReportsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReportsClient().NewListBySubscriptionPager("rg1", "apimService1", "timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", &armapimanagement.ReportsClientListBySubscriptionOptions{Top: nil, - Skip: nil, - Orderby: 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.ReportCollection = armapimanagement.ReportCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.ReportRecordContract{ - // { - // Name: to.Ptr(""), - // APITimeAvg: to.Ptr[float64](0), - // APITimeMax: to.Ptr[float64](0), - // APITimeMin: to.Ptr[float64](0), - // Bandwidth: to.Ptr[int64](0), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](0), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](0), - // CallCountTotal: to.Ptr[int32](0), - // ProductID: to.Ptr("/products/5600b59475ff190048060001"), - // ServiceTimeAvg: to.Ptr[float64](0), - // ServiceTimeMax: to.Ptr[float64](0), - // ServiceTimeMin: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("/subscriptions/5600b59475ff190048070001"), - // UserID: to.Ptr("/users/1"), - // }, - // { - // Name: to.Ptr(""), - // APITimeAvg: to.Ptr[float64](1015.7607923076923), - // APITimeMax: to.Ptr[float64](1819.2173), - // APITimeMin: to.Ptr[float64](330.3206), - // Bandwidth: to.Ptr[int64](11019), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](1), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](13), - // CallCountTotal: to.Ptr[int32](14), - // ProductID: to.Ptr("/products/5600b59475ff190048060002"), - // ServiceTimeAvg: to.Ptr[float64](957.094776923077), - // ServiceTimeMax: to.Ptr[float64](1697.3612), - // ServiceTimeMin: to.Ptr[float64](215.24), - // SubscriptionID: to.Ptr("/subscriptions/5600b59475ff190048070002"), - // UserID: to.Ptr("/users/1"), - // }, - // { - // Name: to.Ptr(""), - // APITimeAvg: to.Ptr[float64](0), - // APITimeMax: to.Ptr[float64](0), - // APITimeMin: to.Ptr[float64](0), - // Bandwidth: to.Ptr[int64](0), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](0), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](0), - // CallCountTotal: to.Ptr[int32](0), - // ProductID: to.Ptr("/products/5702e97e5157a50f48dce801"), - // ServiceTimeAvg: to.Ptr[float64](0), - // ServiceTimeMax: to.Ptr[float64](0), - // ServiceTimeMin: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("/subscriptions/5702e97e5157a50a9c733303"), - // UserID: to.Ptr("/users/1"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetReportsByTime.json -func ExampleReportsClient_NewListByTimePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReportsClient().NewListByTimePager("rg1", "apimService1", "timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", "PT15M", &armapimanagement.ReportsClientListByTimeOptions{Top: nil, - Skip: nil, - Orderby: 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.ReportCollection = armapimanagement.ReportCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.ReportRecordContract{ - // { - // APITimeAvg: to.Ptr[float64](1337.46335), - // APITimeMax: to.Ptr[float64](1819.2173), - // APITimeMin: to.Ptr[float64](885.0839000000001), - // Bandwidth: to.Ptr[int64](3243), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](0), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](4), - // CallCountTotal: to.Ptr[int32](4), - // Interval: to.Ptr("PT15M"), - // ServiceTimeAvg: to.Ptr[float64](1255.917425), - // ServiceTimeMax: to.Ptr[float64](1697.3612), - // ServiceTimeMin: to.Ptr[float64](882.8264), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-03T00:15:00.000Z"); return t}()), - // }, - // { - // APITimeAvg: to.Ptr[float64](872.7818777777778), - // APITimeMax: to.Ptr[float64](1093.8407), - // APITimeMin: to.Ptr[float64](330.3206), - // Bandwidth: to.Ptr[int64](7776), - // CacheHitCount: to.Ptr[int32](0), - // CacheMissCount: to.Ptr[int32](0), - // CallCountBlocked: to.Ptr[int32](1), - // CallCountFailed: to.Ptr[int32](0), - // CallCountOther: to.Ptr[int32](0), - // CallCountSuccess: to.Ptr[int32](9), - // CallCountTotal: to.Ptr[int32](10), - // Interval: to.Ptr("PT15M"), - // ServiceTimeAvg: to.Ptr[float64](824.2847111111112), - // ServiceTimeMax: to.Ptr[float64](973.2262000000001), - // ServiceTimeMin: to.Ptr[float64](215.24), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-03T00:30:00.000Z"); return t}()), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetReportsByRequest.json -func ExampleReportsClient_NewListByRequestPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReportsClient().NewListByRequestPager("rg1", "apimService1", "timestamp ge datetime'2017-06-01T00:00:00' and timestamp le datetime'2017-06-04T00:00:00'", &armapimanagement.ReportsClientListByRequestOptions{Top: nil, - Skip: 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.RequestReportCollection = armapimanagement.RequestReportCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.RequestReportRecordContract{ - // { - // OperationID: to.Ptr("/apis/5931a75ae4bbd512a88c680b/operations/-"), - // Method: to.Ptr("GET"), - // APIID: to.Ptr("/apis/5931a75ae4bbd512a88c680b"), - // APIRegion: to.Ptr("East Asia"), - // APITime: to.Ptr[float64](221.1544), - // Cache: to.Ptr("none"), - // IPAddress: to.Ptr("207.xx.155.xx"), - // ProductID: to.Ptr("/products/-"), - // RequestID: to.Ptr("63e7119c-26aa-433c-96d7-f6f3267ff52f"), - // RequestSize: to.Ptr[int32](0), - // ResponseCode: to.Ptr[int32](404), - // ResponseSize: to.Ptr[int32](405), - // ServiceTime: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("/subscriptions/5600b59475ff190048070002"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-03T00:17:00.164Z"); return t}()), - // URL: to.Ptr("https://apimService1.azure-api.net/echo/resource?param1=sample"), - // UserID: to.Ptr("/users/1"), - // }, - // { - // OperationID: to.Ptr("/apis/5931a75ae4bbd512a88c680b/operations/-"), - // Method: to.Ptr("POST"), - // APIID: to.Ptr("/apis/5931a75ae4bbd512a88c680b"), - // APIRegion: to.Ptr("East Asia"), - // APITime: to.Ptr[float64](6.675400000000001), - // Cache: to.Ptr("none"), - // IPAddress: to.Ptr("207.xx.155.xx"), - // ProductID: to.Ptr("/products/-"), - // RequestID: to.Ptr("e581b7f7-c9ec-4fc6-8ab9-3855d9b00b04"), - // RequestSize: to.Ptr[int32](0), - // ResponseCode: to.Ptr[int32](404), - // ResponseSize: to.Ptr[int32](403), - // ServiceTime: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("/subscriptions/5600b59475ff190048070002"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-03T00:17:20.525Z"); return t}()), - // URL: to.Ptr("https://apimService1.azure-api.net/echo/resource"), - // UserID: to.Ptr("/users/1"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/response_types.go b/sdk/resourcemanager/apimanagement/armapimanagement/responses.go similarity index 63% rename from sdk/resourcemanager/apimanagement/armapimanagement/response_types.go rename to sdk/resourcemanager/apimanagement/armapimanagement/responses.go index 95f5584a911e..6addc32df7b2 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/response_types.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/responses.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -14,7 +11,7 @@ type APIClientCreateOrUpdateResponse struct { APIContract } -// APIClientDeleteResponse contains the response from method APIClient.Delete. +// APIClientDeleteResponse contains the response from method APIClient.BeginDelete. type APIClientDeleteResponse struct { // placeholder for future response values } @@ -111,6 +108,65 @@ type APIExportClientGetResponse struct { APIExportResult } +// APIGatewayClientCreateOrUpdateResponse contains the response from method APIGatewayClient.BeginCreateOrUpdate. +type APIGatewayClientCreateOrUpdateResponse struct { + // A single API Management gateway resource in List or Get response. + GatewayResource +} + +// APIGatewayClientDeleteResponse contains the response from method APIGatewayClient.BeginDelete. +type APIGatewayClientDeleteResponse struct { + // A single API Management gateway resource in List or Get response. + GatewayResource +} + +// APIGatewayClientGetResponse contains the response from method APIGatewayClient.Get. +type APIGatewayClientGetResponse struct { + // A single API Management gateway resource in List or Get response. + GatewayResource +} + +// APIGatewayClientListByResourceGroupResponse contains the response from method APIGatewayClient.NewListByResourceGroupPager. +type APIGatewayClientListByResourceGroupResponse struct { + // The response of the List API Management gateway operation. + GatewayListResult +} + +// APIGatewayClientListResponse contains the response from method APIGatewayClient.NewListPager. +type APIGatewayClientListResponse struct { + // The response of the List API Management gateway operation. + GatewayListResult +} + +// APIGatewayClientUpdateResponse contains the response from method APIGatewayClient.BeginUpdate. +type APIGatewayClientUpdateResponse struct { + // A single API Management gateway resource in List or Get response. + GatewayResource +} + +// APIGatewayConfigConnectionClientCreateOrUpdateResponse contains the response from method APIGatewayConfigConnectionClient.BeginCreateOrUpdate. +type APIGatewayConfigConnectionClientCreateOrUpdateResponse struct { + // A single API Management gateway resource in List or Get response. + GatewayConfigConnectionResource +} + +// APIGatewayConfigConnectionClientDeleteResponse contains the response from method APIGatewayConfigConnectionClient.BeginDelete. +type APIGatewayConfigConnectionClientDeleteResponse struct { + // placeholder for future response values +} + +// APIGatewayConfigConnectionClientGetResponse contains the response from method APIGatewayConfigConnectionClient.Get. +type APIGatewayConfigConnectionClientGetResponse struct { + // A single API Management gateway resource in List or Get response. + GatewayConfigConnectionResource +} + +// APIGatewayConfigConnectionClientListByGatewayResponse contains the response from method APIGatewayConfigConnectionClient.NewListByGatewayPager. +type APIGatewayConfigConnectionClientListByGatewayResponse struct { + // The response of the List API Management gateway operation. + GatewayConfigConnectionListResult +} + // APIIssueAttachmentClientCreateOrUpdateResponse contains the response from method APIIssueAttachmentClient.CreateOrUpdate. type APIIssueAttachmentClientCreateOrUpdateResponse struct { // Issue Attachment Contract details. @@ -583,6 +639,12 @@ type APIWikisClientListResponse struct { WikiCollection } +// AllPoliciesClientListByServiceResponse contains the response from method AllPoliciesClient.NewListByServicePager. +type AllPoliciesClientListByServiceResponse struct { + // The response of All Policies. + AllPoliciesCollection +} + // AuthorizationAccessPolicyClientCreateOrUpdateResponse contains the response from method AuthorizationAccessPolicyClient.CreateOrUpdate. type AuthorizationAccessPolicyClientCreateOrUpdateResponse struct { // Authorization access policy contract. @@ -1253,12 +1315,23 @@ type GatewayClientGetResponse struct { ETag *string } +// GatewayClientInvalidateDebugCredentialsResponse contains the response from method GatewayClient.InvalidateDebugCredentials. +type GatewayClientInvalidateDebugCredentialsResponse struct { + // placeholder for future response values +} + // GatewayClientListByServiceResponse contains the response from method GatewayClient.NewListByServicePager. type GatewayClientListByServiceResponse struct { // Paged Gateway list representation. GatewayCollection } +// GatewayClientListDebugCredentialsResponse contains the response from method GatewayClient.ListDebugCredentials. +type GatewayClientListDebugCredentialsResponse struct { + // Gateway debug credentials. + GatewayDebugCredentialsContract +} + // GatewayClientListKeysResponse contains the response from method GatewayClient.ListKeys. type GatewayClientListKeysResponse struct { // Gateway authentication keys. @@ -1268,6 +1341,12 @@ type GatewayClientListKeysResponse struct { ETag *string } +// GatewayClientListTraceResponse contains the response from method GatewayClient.ListTrace. +type GatewayClientListTraceResponse struct { + // Trace collected in gateway. + Value map[string]any +} + // GatewayClientRegenerateKeyResponse contains the response from method GatewayClient.RegenerateKey. type GatewayClientRegenerateKeyResponse struct { // placeholder for future response values @@ -1320,6 +1399,12 @@ type GatewayHostnameConfigurationClientListByServiceResponse struct { GatewayHostnameConfigurationCollection } +// GatewaySKUsClientListAvailableSKUsResponse contains the response from method GatewaySKUsClient.NewListAvailableSKUsPager. +type GatewaySKUsClientListAvailableSKUsResponse struct { + // The API Management gateway SKUs operation response. + GatewayResourceSKUResults +} + // GlobalSchemaClientCreateOrUpdateResponse contains the response from method GlobalSchemaClient.BeginCreateOrUpdate. type GlobalSchemaClientCreateOrUpdateResponse struct { // Global Schema Contract details. @@ -1822,6 +1907,12 @@ type OperationClientListByTagsResponse struct { TagResourceCollection } +// OperationStatusClientGetResponse contains the response from method OperationStatusClient.Get. +type OperationStatusClientGetResponse struct { + // The current status of an async operation. + OperationStatusResult +} + // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { // Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next @@ -1829,6 +1920,12 @@ type OperationsClientListResponse struct { OperationListResult } +// OperationsResultsClientGetResponse contains the response from method OperationsResultsClient.Get. +type OperationsResultsClientGetResponse struct { + // Location contains the information returned from the Location header response. + Location *string +} + // OutboundNetworkDependenciesEndpointsClientListByServiceResponse contains the response from method OutboundNetworkDependenciesEndpointsClient.ListByService. type OutboundNetworkDependenciesEndpointsClientListByServiceResponse struct { // Collection of Outbound Environment Endpoints @@ -1867,7 +1964,7 @@ type PolicyClientGetResponse struct { ETag *string } -// PolicyClientListByServiceResponse contains the response from method PolicyClient.ListByService. +// PolicyClientListByServiceResponse contains the response from method PolicyClient.NewListByServicePager. type PolicyClientListByServiceResponse struct { // The response of the list policy operation. PolicyCollection @@ -1908,7 +2005,7 @@ type PolicyFragmentClientGetResponse struct { ETag *string } -// PolicyFragmentClientListByServiceResponse contains the response from method PolicyFragmentClient.ListByService. +// PolicyFragmentClientListByServiceResponse contains the response from method PolicyFragmentClient.NewListByServicePager. type PolicyFragmentClientListByServiceResponse struct { // The response of the get policy fragments operation. PolicyFragmentCollection @@ -1920,6 +2017,59 @@ type PolicyFragmentClientListReferencesResponse struct { ResourceCollection } +// PolicyRestrictionClientCreateOrUpdateResponse contains the response from method PolicyRestrictionClient.CreateOrUpdate. +type PolicyRestrictionClientCreateOrUpdateResponse struct { + // Policy restriction contract details. + PolicyRestrictionContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// PolicyRestrictionClientDeleteResponse contains the response from method PolicyRestrictionClient.Delete. +type PolicyRestrictionClientDeleteResponse struct { + // placeholder for future response values +} + +// PolicyRestrictionClientGetEntityTagResponse contains the response from method PolicyRestrictionClient.GetEntityTag. +type PolicyRestrictionClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// PolicyRestrictionClientGetResponse contains the response from method PolicyRestrictionClient.Get. +type PolicyRestrictionClientGetResponse struct { + // Policy restriction contract details. + PolicyRestrictionContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// PolicyRestrictionClientListByServiceResponse contains the response from method PolicyRestrictionClient.NewListByServicePager. +type PolicyRestrictionClientListByServiceResponse struct { + // The response of the get policy restrictions operation. + PolicyRestrictionCollection +} + +// PolicyRestrictionClientUpdateResponse contains the response from method PolicyRestrictionClient.Update. +type PolicyRestrictionClientUpdateResponse struct { + // Policy restriction contract details. + PolicyRestrictionContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// PolicyRestrictionValidationsClientByServiceResponse contains the response from method PolicyRestrictionValidationsClient.BeginByService. +type PolicyRestrictionValidationsClientByServiceResponse struct { + // Long Running Git Operation Results. + OperationResultContract +} + // PortalConfigClientCreateOrUpdateResponse contains the response from method PortalConfigClient.CreateOrUpdate. type PortalConfigClientCreateOrUpdateResponse struct { // The developer portal configuration contract. @@ -1944,7 +2094,7 @@ type PortalConfigClientGetResponse struct { ETag *string } -// PortalConfigClientListByServiceResponse contains the response from method PortalConfigClient.ListByService. +// PortalConfigClientListByServiceResponse contains the response from method PortalConfigClient.NewListByServicePager. type PortalConfigClientListByServiceResponse struct { // The collection of the developer portal configurations. PortalConfigCollection @@ -2056,6 +2206,32 @@ type ProductAPIClientListByProductResponse struct { APICollection } +// ProductAPILinkClientCreateOrUpdateResponse contains the response from method ProductAPILinkClient.CreateOrUpdate. +type ProductAPILinkClientCreateOrUpdateResponse struct { + // Product-API link details. + ProductAPILinkContract +} + +// ProductAPILinkClientDeleteResponse contains the response from method ProductAPILinkClient.Delete. +type ProductAPILinkClientDeleteResponse struct { + // placeholder for future response values +} + +// ProductAPILinkClientGetResponse contains the response from method ProductAPILinkClient.Get. +type ProductAPILinkClientGetResponse struct { + // Product-API link details. + ProductAPILinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ProductAPILinkClientListByProductResponse contains the response from method ProductAPILinkClient.NewListByProductPager. +type ProductAPILinkClientListByProductResponse struct { + // Paged Product-API link list representation. + ProductAPILinkCollection +} + // ProductClientCreateOrUpdateResponse contains the response from method ProductClient.CreateOrUpdate. type ProductClientCreateOrUpdateResponse struct { // Product details. @@ -2132,6 +2308,32 @@ type ProductGroupClientListByProductResponse struct { GroupCollection } +// ProductGroupLinkClientCreateOrUpdateResponse contains the response from method ProductGroupLinkClient.CreateOrUpdate. +type ProductGroupLinkClientCreateOrUpdateResponse struct { + // Product-group link details. + ProductGroupLinkContract +} + +// ProductGroupLinkClientDeleteResponse contains the response from method ProductGroupLinkClient.Delete. +type ProductGroupLinkClientDeleteResponse struct { + // placeholder for future response values +} + +// ProductGroupLinkClientGetResponse contains the response from method ProductGroupLinkClient.Get. +type ProductGroupLinkClientGetResponse struct { + // Product-group link details. + ProductGroupLinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ProductGroupLinkClientListByProductResponse contains the response from method ProductGroupLinkClient.NewListByProductPager. +type ProductGroupLinkClientListByProductResponse struct { + // Paged Product-group link list representation. + ProductGroupLinkCollection +} + // ProductPolicyClientCreateOrUpdateResponse contains the response from method ProductPolicyClient.CreateOrUpdate. type ProductPolicyClientCreateOrUpdateResponse struct { // Policy Contract details. @@ -2164,7 +2366,7 @@ type ProductPolicyClientGetResponse struct { ETag *string } -// ProductPolicyClientListByProductResponse contains the response from method ProductPolicyClient.ListByProduct. +// ProductPolicyClientListByProductResponse contains the response from method ProductPolicyClient.NewListByProductPager. type ProductPolicyClientListByProductResponse struct { // The response of the list policy operation. PolicyCollection @@ -2518,6 +2720,32 @@ type SubscriptionClientUpdateResponse struct { ETag *string } +// TagAPILinkClientCreateOrUpdateResponse contains the response from method TagAPILinkClient.CreateOrUpdate. +type TagAPILinkClientCreateOrUpdateResponse struct { + // Tag-API link details. + TagAPILinkContract +} + +// TagAPILinkClientDeleteResponse contains the response from method TagAPILinkClient.Delete. +type TagAPILinkClientDeleteResponse struct { + // placeholder for future response values +} + +// TagAPILinkClientGetResponse contains the response from method TagAPILinkClient.Get. +type TagAPILinkClientGetResponse struct { + // Tag-API link details. + TagAPILinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagAPILinkClientListByProductResponse contains the response from method TagAPILinkClient.NewListByProductPager. +type TagAPILinkClientListByProductResponse struct { + // Paged Tag-API link list representation. + TagAPILinkCollection +} + // TagClientAssignToAPIResponse contains the response from method TagClient.AssignToAPI. type TagClientAssignToAPIResponse struct { // Tag Contract details. @@ -2673,6 +2901,58 @@ type TagClientUpdateResponse struct { ETag *string } +// TagOperationLinkClientCreateOrUpdateResponse contains the response from method TagOperationLinkClient.CreateOrUpdate. +type TagOperationLinkClientCreateOrUpdateResponse struct { + // Tag-operation link details. + TagOperationLinkContract +} + +// TagOperationLinkClientDeleteResponse contains the response from method TagOperationLinkClient.Delete. +type TagOperationLinkClientDeleteResponse struct { + // placeholder for future response values +} + +// TagOperationLinkClientGetResponse contains the response from method TagOperationLinkClient.Get. +type TagOperationLinkClientGetResponse struct { + // Tag-operation link details. + TagOperationLinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagOperationLinkClientListByProductResponse contains the response from method TagOperationLinkClient.NewListByProductPager. +type TagOperationLinkClientListByProductResponse struct { + // Paged Tag-operation link list representation. + TagOperationLinkCollection +} + +// TagProductLinkClientCreateOrUpdateResponse contains the response from method TagProductLinkClient.CreateOrUpdate. +type TagProductLinkClientCreateOrUpdateResponse struct { + // Tag-product link details. + TagProductLinkContract +} + +// TagProductLinkClientDeleteResponse contains the response from method TagProductLinkClient.Delete. +type TagProductLinkClientDeleteResponse struct { + // placeholder for future response values +} + +// TagProductLinkClientGetResponse contains the response from method TagProductLinkClient.Get. +type TagProductLinkClientGetResponse struct { + // Tag-product link details. + TagProductLinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagProductLinkClientListByProductResponse contains the response from method TagProductLinkClient.NewListByProductPager. +type TagProductLinkClientListByProductResponse struct { + // Paged Tag-product link list representation. + TagProductLinkCollection +} + // TagResourceClientListByServiceResponse contains the response from method TagResourceClient.NewListByServicePager. type TagResourceClientListByServiceResponse struct { // Paged Tag list representation. @@ -2798,7 +3078,7 @@ type UserClientCreateOrUpdateResponse struct { ETag *string } -// UserClientDeleteResponse contains the response from method UserClient.Delete. +// UserClientDeleteResponse contains the response from method UserClient.BeginDelete. type UserClientDeleteResponse struct { // placeholder for future response values } @@ -2879,3 +3159,1237 @@ type UserSubscriptionClientListResponse struct { // Paged Subscriptions list representation. SubscriptionCollection } + +// WorkspaceAPIClientCreateOrUpdateResponse contains the response from method WorkspaceAPIClient.BeginCreateOrUpdate. +type WorkspaceAPIClientCreateOrUpdateResponse struct { + // API details. + APIContract +} + +// WorkspaceAPIClientDeleteResponse contains the response from method WorkspaceAPIClient.Delete. +type WorkspaceAPIClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceAPIClientGetEntityTagResponse contains the response from method WorkspaceAPIClient.GetEntityTag. +type WorkspaceAPIClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceAPIClientGetResponse contains the response from method WorkspaceAPIClient.Get. +type WorkspaceAPIClientGetResponse struct { + // API details. + APIContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIClientListByServiceResponse contains the response from method WorkspaceAPIClient.NewListByServicePager. +type WorkspaceAPIClientListByServiceResponse struct { + // Paged API list representation. + APICollection +} + +// WorkspaceAPIClientUpdateResponse contains the response from method WorkspaceAPIClient.Update. +type WorkspaceAPIClientUpdateResponse struct { + // API details. + APIContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIDiagnosticClientCreateOrUpdateResponse contains the response from method WorkspaceAPIDiagnosticClient.CreateOrUpdate. +type WorkspaceAPIDiagnosticClientCreateOrUpdateResponse struct { + // Diagnostic details. + DiagnosticContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIDiagnosticClientDeleteResponse contains the response from method WorkspaceAPIDiagnosticClient.Delete. +type WorkspaceAPIDiagnosticClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceAPIDiagnosticClientGetEntityTagResponse contains the response from method WorkspaceAPIDiagnosticClient.GetEntityTag. +type WorkspaceAPIDiagnosticClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceAPIDiagnosticClientGetResponse contains the response from method WorkspaceAPIDiagnosticClient.Get. +type WorkspaceAPIDiagnosticClientGetResponse struct { + // Diagnostic details. + DiagnosticContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIDiagnosticClientListByWorkspaceResponse contains the response from method WorkspaceAPIDiagnosticClient.NewListByWorkspacePager. +type WorkspaceAPIDiagnosticClientListByWorkspaceResponse struct { + // Paged Diagnostic list representation. + DiagnosticCollection +} + +// WorkspaceAPIDiagnosticClientUpdateResponse contains the response from method WorkspaceAPIDiagnosticClient.Update. +type WorkspaceAPIDiagnosticClientUpdateResponse struct { + // Diagnostic details. + DiagnosticContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIExportClientGetResponse contains the response from method WorkspaceAPIExportClient.Get. +type WorkspaceAPIExportClientGetResponse struct { + // API Export result. + APIExportResult +} + +// WorkspaceAPIOperationClientCreateOrUpdateResponse contains the response from method WorkspaceAPIOperationClient.CreateOrUpdate. +type WorkspaceAPIOperationClientCreateOrUpdateResponse struct { + // API Operation details. + OperationContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIOperationClientDeleteResponse contains the response from method WorkspaceAPIOperationClient.Delete. +type WorkspaceAPIOperationClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceAPIOperationClientGetEntityTagResponse contains the response from method WorkspaceAPIOperationClient.GetEntityTag. +type WorkspaceAPIOperationClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceAPIOperationClientGetResponse contains the response from method WorkspaceAPIOperationClient.Get. +type WorkspaceAPIOperationClientGetResponse struct { + // API Operation details. + OperationContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIOperationClientListByAPIResponse contains the response from method WorkspaceAPIOperationClient.NewListByAPIPager. +type WorkspaceAPIOperationClientListByAPIResponse struct { + // Paged Operation list representation. + OperationCollection +} + +// WorkspaceAPIOperationClientUpdateResponse contains the response from method WorkspaceAPIOperationClient.Update. +type WorkspaceAPIOperationClientUpdateResponse struct { + // API Operation details. + OperationContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse contains the response from method WorkspaceAPIOperationPolicyClient.CreateOrUpdate. +type WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse struct { + // Policy Contract details. + PolicyContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIOperationPolicyClientDeleteResponse contains the response from method WorkspaceAPIOperationPolicyClient.Delete. +type WorkspaceAPIOperationPolicyClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceAPIOperationPolicyClientGetEntityTagResponse contains the response from method WorkspaceAPIOperationPolicyClient.GetEntityTag. +type WorkspaceAPIOperationPolicyClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceAPIOperationPolicyClientGetResponse contains the response from method WorkspaceAPIOperationPolicyClient.Get. +type WorkspaceAPIOperationPolicyClientGetResponse struct { + // Policy Contract details. + PolicyContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIOperationPolicyClientListByOperationResponse contains the response from method WorkspaceAPIOperationPolicyClient.NewListByOperationPager. +type WorkspaceAPIOperationPolicyClientListByOperationResponse struct { + // The response of the list policy operation. + PolicyCollection +} + +// WorkspaceAPIPolicyClientCreateOrUpdateResponse contains the response from method WorkspaceAPIPolicyClient.CreateOrUpdate. +type WorkspaceAPIPolicyClientCreateOrUpdateResponse struct { + // Policy Contract details. + PolicyContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIPolicyClientDeleteResponse contains the response from method WorkspaceAPIPolicyClient.Delete. +type WorkspaceAPIPolicyClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceAPIPolicyClientGetEntityTagResponse contains the response from method WorkspaceAPIPolicyClient.GetEntityTag. +type WorkspaceAPIPolicyClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceAPIPolicyClientGetResponse contains the response from method WorkspaceAPIPolicyClient.Get. +type WorkspaceAPIPolicyClientGetResponse struct { + // Policy Contract details. + PolicyContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIPolicyClientListByAPIResponse contains the response from method WorkspaceAPIPolicyClient.NewListByAPIPager. +type WorkspaceAPIPolicyClientListByAPIResponse struct { + // The response of the list policy operation. + PolicyCollection +} + +// WorkspaceAPIReleaseClientCreateOrUpdateResponse contains the response from method WorkspaceAPIReleaseClient.CreateOrUpdate. +type WorkspaceAPIReleaseClientCreateOrUpdateResponse struct { + // ApiRelease details. + APIReleaseContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIReleaseClientDeleteResponse contains the response from method WorkspaceAPIReleaseClient.Delete. +type WorkspaceAPIReleaseClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceAPIReleaseClientGetEntityTagResponse contains the response from method WorkspaceAPIReleaseClient.GetEntityTag. +type WorkspaceAPIReleaseClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceAPIReleaseClientGetResponse contains the response from method WorkspaceAPIReleaseClient.Get. +type WorkspaceAPIReleaseClientGetResponse struct { + // ApiRelease details. + APIReleaseContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIReleaseClientListByServiceResponse contains the response from method WorkspaceAPIReleaseClient.NewListByServicePager. +type WorkspaceAPIReleaseClientListByServiceResponse struct { + // Paged ApiRelease list representation. + APIReleaseCollection +} + +// WorkspaceAPIReleaseClientUpdateResponse contains the response from method WorkspaceAPIReleaseClient.Update. +type WorkspaceAPIReleaseClientUpdateResponse struct { + // ApiRelease details. + APIReleaseContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIRevisionClientListByServiceResponse contains the response from method WorkspaceAPIRevisionClient.NewListByServicePager. +type WorkspaceAPIRevisionClientListByServiceResponse struct { + // Paged API Revision list representation. + APIRevisionCollection +} + +// WorkspaceAPISchemaClientCreateOrUpdateResponse contains the response from method WorkspaceAPISchemaClient.BeginCreateOrUpdate. +type WorkspaceAPISchemaClientCreateOrUpdateResponse struct { + // API Schema Contract details. + SchemaContract +} + +// WorkspaceAPISchemaClientDeleteResponse contains the response from method WorkspaceAPISchemaClient.Delete. +type WorkspaceAPISchemaClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceAPISchemaClientGetEntityTagResponse contains the response from method WorkspaceAPISchemaClient.GetEntityTag. +type WorkspaceAPISchemaClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceAPISchemaClientGetResponse contains the response from method WorkspaceAPISchemaClient.Get. +type WorkspaceAPISchemaClientGetResponse struct { + // API Schema Contract details. + SchemaContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPISchemaClientListByAPIResponse contains the response from method WorkspaceAPISchemaClient.NewListByAPIPager. +type WorkspaceAPISchemaClientListByAPIResponse struct { + // The response of the list schema operation. + SchemaCollection +} + +// WorkspaceAPIVersionSetClientCreateOrUpdateResponse contains the response from method WorkspaceAPIVersionSetClient.CreateOrUpdate. +type WorkspaceAPIVersionSetClientCreateOrUpdateResponse struct { + // API Version Set Contract details. + APIVersionSetContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIVersionSetClientDeleteResponse contains the response from method WorkspaceAPIVersionSetClient.Delete. +type WorkspaceAPIVersionSetClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceAPIVersionSetClientGetEntityTagResponse contains the response from method WorkspaceAPIVersionSetClient.GetEntityTag. +type WorkspaceAPIVersionSetClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceAPIVersionSetClientGetResponse contains the response from method WorkspaceAPIVersionSetClient.Get. +type WorkspaceAPIVersionSetClientGetResponse struct { + // API Version Set Contract details. + APIVersionSetContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceAPIVersionSetClientListByServiceResponse contains the response from method WorkspaceAPIVersionSetClient.NewListByServicePager. +type WorkspaceAPIVersionSetClientListByServiceResponse struct { + // Paged API Version Set list representation. + APIVersionSetCollection +} + +// WorkspaceAPIVersionSetClientUpdateResponse contains the response from method WorkspaceAPIVersionSetClient.Update. +type WorkspaceAPIVersionSetClientUpdateResponse struct { + // API Version Set Contract details. + APIVersionSetContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceBackendClientCreateOrUpdateResponse contains the response from method WorkspaceBackendClient.CreateOrUpdate. +type WorkspaceBackendClientCreateOrUpdateResponse struct { + // Backend details. + BackendContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceBackendClientDeleteResponse contains the response from method WorkspaceBackendClient.Delete. +type WorkspaceBackendClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceBackendClientGetEntityTagResponse contains the response from method WorkspaceBackendClient.GetEntityTag. +type WorkspaceBackendClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceBackendClientGetResponse contains the response from method WorkspaceBackendClient.Get. +type WorkspaceBackendClientGetResponse struct { + // Backend details. + BackendContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceBackendClientListByWorkspaceResponse contains the response from method WorkspaceBackendClient.NewListByWorkspacePager. +type WorkspaceBackendClientListByWorkspaceResponse struct { + // Paged Backend list representation. + BackendCollection +} + +// WorkspaceBackendClientUpdateResponse contains the response from method WorkspaceBackendClient.Update. +type WorkspaceBackendClientUpdateResponse struct { + // Backend details. + BackendContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceCertificateClientCreateOrUpdateResponse contains the response from method WorkspaceCertificateClient.CreateOrUpdate. +type WorkspaceCertificateClientCreateOrUpdateResponse struct { + // Certificate details. + CertificateContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceCertificateClientDeleteResponse contains the response from method WorkspaceCertificateClient.Delete. +type WorkspaceCertificateClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceCertificateClientGetEntityTagResponse contains the response from method WorkspaceCertificateClient.GetEntityTag. +type WorkspaceCertificateClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceCertificateClientGetResponse contains the response from method WorkspaceCertificateClient.Get. +type WorkspaceCertificateClientGetResponse struct { + // Certificate details. + CertificateContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceCertificateClientListByWorkspaceResponse contains the response from method WorkspaceCertificateClient.NewListByWorkspacePager. +type WorkspaceCertificateClientListByWorkspaceResponse struct { + // Paged Certificates list representation. + CertificateCollection +} + +// WorkspaceCertificateClientRefreshSecretResponse contains the response from method WorkspaceCertificateClient.RefreshSecret. +type WorkspaceCertificateClientRefreshSecretResponse struct { + // Certificate details. + CertificateContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceClientCreateOrUpdateResponse contains the response from method WorkspaceClient.CreateOrUpdate. +type WorkspaceClientCreateOrUpdateResponse struct { + // Workspace details. + WorkspaceContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceClientDeleteResponse contains the response from method WorkspaceClient.Delete. +type WorkspaceClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceClientGetEntityTagResponse contains the response from method WorkspaceClient.GetEntityTag. +type WorkspaceClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceClientGetResponse contains the response from method WorkspaceClient.Get. +type WorkspaceClientGetResponse struct { + // Workspace details. + WorkspaceContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceClientListByServiceResponse contains the response from method WorkspaceClient.NewListByServicePager. +type WorkspaceClientListByServiceResponse struct { + // Paged workspace list representation. + WorkspaceCollection +} + +// WorkspaceClientUpdateResponse contains the response from method WorkspaceClient.Update. +type WorkspaceClientUpdateResponse struct { + // Workspace details. + WorkspaceContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceDiagnosticClientCreateOrUpdateResponse contains the response from method WorkspaceDiagnosticClient.CreateOrUpdate. +type WorkspaceDiagnosticClientCreateOrUpdateResponse struct { + // Diagnostic details. + DiagnosticContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceDiagnosticClientDeleteResponse contains the response from method WorkspaceDiagnosticClient.Delete. +type WorkspaceDiagnosticClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceDiagnosticClientGetEntityTagResponse contains the response from method WorkspaceDiagnosticClient.GetEntityTag. +type WorkspaceDiagnosticClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceDiagnosticClientGetResponse contains the response from method WorkspaceDiagnosticClient.Get. +type WorkspaceDiagnosticClientGetResponse struct { + // Diagnostic details. + DiagnosticContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceDiagnosticClientListByWorkspaceResponse contains the response from method WorkspaceDiagnosticClient.NewListByWorkspacePager. +type WorkspaceDiagnosticClientListByWorkspaceResponse struct { + // Paged Diagnostic list representation. + DiagnosticCollection +} + +// WorkspaceDiagnosticClientUpdateResponse contains the response from method WorkspaceDiagnosticClient.Update. +type WorkspaceDiagnosticClientUpdateResponse struct { + // Diagnostic details. + DiagnosticContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceGlobalSchemaClientCreateOrUpdateResponse contains the response from method WorkspaceGlobalSchemaClient.BeginCreateOrUpdate. +type WorkspaceGlobalSchemaClientCreateOrUpdateResponse struct { + // Global Schema Contract details. + GlobalSchemaContract +} + +// WorkspaceGlobalSchemaClientDeleteResponse contains the response from method WorkspaceGlobalSchemaClient.Delete. +type WorkspaceGlobalSchemaClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceGlobalSchemaClientGetEntityTagResponse contains the response from method WorkspaceGlobalSchemaClient.GetEntityTag. +type WorkspaceGlobalSchemaClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceGlobalSchemaClientGetResponse contains the response from method WorkspaceGlobalSchemaClient.Get. +type WorkspaceGlobalSchemaClientGetResponse struct { + // Global Schema Contract details. + GlobalSchemaContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceGlobalSchemaClientListByServiceResponse contains the response from method WorkspaceGlobalSchemaClient.NewListByServicePager. +type WorkspaceGlobalSchemaClientListByServiceResponse struct { + // The response of the list schema operation. + GlobalSchemaCollection +} + +// WorkspaceGroupClientCreateOrUpdateResponse contains the response from method WorkspaceGroupClient.CreateOrUpdate. +type WorkspaceGroupClientCreateOrUpdateResponse struct { + // Contract details. + GroupContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceGroupClientDeleteResponse contains the response from method WorkspaceGroupClient.Delete. +type WorkspaceGroupClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceGroupClientGetEntityTagResponse contains the response from method WorkspaceGroupClient.GetEntityTag. +type WorkspaceGroupClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceGroupClientGetResponse contains the response from method WorkspaceGroupClient.Get. +type WorkspaceGroupClientGetResponse struct { + // Contract details. + GroupContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceGroupClientListByServiceResponse contains the response from method WorkspaceGroupClient.NewListByServicePager. +type WorkspaceGroupClientListByServiceResponse struct { + // Paged Group list representation. + GroupCollection +} + +// WorkspaceGroupClientUpdateResponse contains the response from method WorkspaceGroupClient.Update. +type WorkspaceGroupClientUpdateResponse struct { + // Contract details. + GroupContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceGroupUserClientCheckEntityExistsResponse contains the response from method WorkspaceGroupUserClient.CheckEntityExists. +type WorkspaceGroupUserClientCheckEntityExistsResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceGroupUserClientCreateResponse contains the response from method WorkspaceGroupUserClient.Create. +type WorkspaceGroupUserClientCreateResponse struct { + // User details. + UserContract +} + +// WorkspaceGroupUserClientDeleteResponse contains the response from method WorkspaceGroupUserClient.Delete. +type WorkspaceGroupUserClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceGroupUserClientListResponse contains the response from method WorkspaceGroupUserClient.NewListPager. +type WorkspaceGroupUserClientListResponse struct { + // Paged Users list representation. + UserCollection +} + +// WorkspaceLinkClientGetResponse contains the response from method WorkspaceLinkClient.Get. +type WorkspaceLinkClientGetResponse struct { + // A single API Management WorkspaceLinks in List or Get response. + WorkspaceLinksResource +} + +// WorkspaceLinksClientListByServiceResponse contains the response from method WorkspaceLinksClient.NewListByServicePager. +type WorkspaceLinksClientListByServiceResponse struct { + // The response of the List API Management WorkspaceLink operation. + WorkspaceLinksListResult +} + +// WorkspaceLoggerClientCreateOrUpdateResponse contains the response from method WorkspaceLoggerClient.CreateOrUpdate. +type WorkspaceLoggerClientCreateOrUpdateResponse struct { + // Logger details. + LoggerContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceLoggerClientDeleteResponse contains the response from method WorkspaceLoggerClient.Delete. +type WorkspaceLoggerClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceLoggerClientGetEntityTagResponse contains the response from method WorkspaceLoggerClient.GetEntityTag. +type WorkspaceLoggerClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceLoggerClientGetResponse contains the response from method WorkspaceLoggerClient.Get. +type WorkspaceLoggerClientGetResponse struct { + // Logger details. + LoggerContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceLoggerClientListByWorkspaceResponse contains the response from method WorkspaceLoggerClient.NewListByWorkspacePager. +type WorkspaceLoggerClientListByWorkspaceResponse struct { + // Paged Logger list representation. + LoggerCollection +} + +// WorkspaceLoggerClientUpdateResponse contains the response from method WorkspaceLoggerClient.Update. +type WorkspaceLoggerClientUpdateResponse struct { + // Logger details. + LoggerContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceNamedValueClientCreateOrUpdateResponse contains the response from method WorkspaceNamedValueClient.BeginCreateOrUpdate. +type WorkspaceNamedValueClientCreateOrUpdateResponse struct { + // NamedValue details. + NamedValueContract +} + +// WorkspaceNamedValueClientDeleteResponse contains the response from method WorkspaceNamedValueClient.Delete. +type WorkspaceNamedValueClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceNamedValueClientGetEntityTagResponse contains the response from method WorkspaceNamedValueClient.GetEntityTag. +type WorkspaceNamedValueClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceNamedValueClientGetResponse contains the response from method WorkspaceNamedValueClient.Get. +type WorkspaceNamedValueClientGetResponse struct { + // NamedValue details. + NamedValueContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceNamedValueClientListByServiceResponse contains the response from method WorkspaceNamedValueClient.NewListByServicePager. +type WorkspaceNamedValueClientListByServiceResponse struct { + // Paged NamedValue list representation. + NamedValueCollection +} + +// WorkspaceNamedValueClientListValueResponse contains the response from method WorkspaceNamedValueClient.ListValue. +type WorkspaceNamedValueClientListValueResponse struct { + // Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + NamedValueSecretContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceNamedValueClientRefreshSecretResponse contains the response from method WorkspaceNamedValueClient.BeginRefreshSecret. +type WorkspaceNamedValueClientRefreshSecretResponse struct { + // NamedValue details. + NamedValueContract +} + +// WorkspaceNamedValueClientUpdateResponse contains the response from method WorkspaceNamedValueClient.BeginUpdate. +type WorkspaceNamedValueClientUpdateResponse struct { + // NamedValue details. + NamedValueContract +} + +// WorkspaceNotificationClientCreateOrUpdateResponse contains the response from method WorkspaceNotificationClient.CreateOrUpdate. +type WorkspaceNotificationClientCreateOrUpdateResponse struct { + // Notification details. + NotificationContract +} + +// WorkspaceNotificationClientGetResponse contains the response from method WorkspaceNotificationClient.Get. +type WorkspaceNotificationClientGetResponse struct { + // Notification details. + NotificationContract +} + +// WorkspaceNotificationClientListByServiceResponse contains the response from method WorkspaceNotificationClient.NewListByServicePager. +type WorkspaceNotificationClientListByServiceResponse struct { + // Paged Notification list representation. + NotificationCollection +} + +// WorkspaceNotificationRecipientEmailClientCheckEntityExistsResponse contains the response from method WorkspaceNotificationRecipientEmailClient.CheckEntityExists. +type WorkspaceNotificationRecipientEmailClientCheckEntityExistsResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse contains the response from method WorkspaceNotificationRecipientEmailClient.CreateOrUpdate. +type WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse struct { + // Recipient Email details. + RecipientEmailContract +} + +// WorkspaceNotificationRecipientEmailClientDeleteResponse contains the response from method WorkspaceNotificationRecipientEmailClient.Delete. +type WorkspaceNotificationRecipientEmailClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceNotificationRecipientEmailClientListByNotificationResponse contains the response from method WorkspaceNotificationRecipientEmailClient.ListByNotification. +type WorkspaceNotificationRecipientEmailClientListByNotificationResponse struct { + // Paged Recipient User list representation. + RecipientEmailCollection +} + +// WorkspaceNotificationRecipientUserClientCheckEntityExistsResponse contains the response from method WorkspaceNotificationRecipientUserClient.CheckEntityExists. +type WorkspaceNotificationRecipientUserClientCheckEntityExistsResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse contains the response from method WorkspaceNotificationRecipientUserClient.CreateOrUpdate. +type WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse struct { + // Recipient User details. + RecipientUserContract +} + +// WorkspaceNotificationRecipientUserClientDeleteResponse contains the response from method WorkspaceNotificationRecipientUserClient.Delete. +type WorkspaceNotificationRecipientUserClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceNotificationRecipientUserClientListByNotificationResponse contains the response from method WorkspaceNotificationRecipientUserClient.ListByNotification. +type WorkspaceNotificationRecipientUserClientListByNotificationResponse struct { + // Paged Recipient User list representation. + RecipientUserCollection +} + +// WorkspacePolicyClientCreateOrUpdateResponse contains the response from method WorkspacePolicyClient.CreateOrUpdate. +type WorkspacePolicyClientCreateOrUpdateResponse struct { + // Policy Contract details. + PolicyContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspacePolicyClientDeleteResponse contains the response from method WorkspacePolicyClient.Delete. +type WorkspacePolicyClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspacePolicyClientGetEntityTagResponse contains the response from method WorkspacePolicyClient.GetEntityTag. +type WorkspacePolicyClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspacePolicyClientGetResponse contains the response from method WorkspacePolicyClient.Get. +type WorkspacePolicyClientGetResponse struct { + // Policy Contract details. + PolicyContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspacePolicyClientListByAPIResponse contains the response from method WorkspacePolicyClient.NewListByAPIPager. +type WorkspacePolicyClientListByAPIResponse struct { + // The response of the list policy operation. + PolicyCollection +} + +// WorkspacePolicyFragmentClientCreateOrUpdateResponse contains the response from method WorkspacePolicyFragmentClient.BeginCreateOrUpdate. +type WorkspacePolicyFragmentClientCreateOrUpdateResponse struct { + // Policy fragment contract details. + PolicyFragmentContract +} + +// WorkspacePolicyFragmentClientDeleteResponse contains the response from method WorkspacePolicyFragmentClient.Delete. +type WorkspacePolicyFragmentClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspacePolicyFragmentClientGetEntityTagResponse contains the response from method WorkspacePolicyFragmentClient.GetEntityTag. +type WorkspacePolicyFragmentClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspacePolicyFragmentClientGetResponse contains the response from method WorkspacePolicyFragmentClient.Get. +type WorkspacePolicyFragmentClientGetResponse struct { + // Policy fragment contract details. + PolicyFragmentContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspacePolicyFragmentClientListByServiceResponse contains the response from method WorkspacePolicyFragmentClient.NewListByServicePager. +type WorkspacePolicyFragmentClientListByServiceResponse struct { + // The response of the get policy fragments operation. + PolicyFragmentCollection +} + +// WorkspacePolicyFragmentClientListReferencesResponse contains the response from method WorkspacePolicyFragmentClient.ListReferences. +type WorkspacePolicyFragmentClientListReferencesResponse struct { + // A collection of resources. + ResourceCollection +} + +// WorkspaceProductAPILinkClientCreateOrUpdateResponse contains the response from method WorkspaceProductAPILinkClient.CreateOrUpdate. +type WorkspaceProductAPILinkClientCreateOrUpdateResponse struct { + // Product-API link details. + ProductAPILinkContract +} + +// WorkspaceProductAPILinkClientDeleteResponse contains the response from method WorkspaceProductAPILinkClient.Delete. +type WorkspaceProductAPILinkClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceProductAPILinkClientGetResponse contains the response from method WorkspaceProductAPILinkClient.Get. +type WorkspaceProductAPILinkClientGetResponse struct { + // Product-API link details. + ProductAPILinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceProductAPILinkClientListByProductResponse contains the response from method WorkspaceProductAPILinkClient.NewListByProductPager. +type WorkspaceProductAPILinkClientListByProductResponse struct { + // Paged Product-API link list representation. + ProductAPILinkCollection +} + +// WorkspaceProductClientCreateOrUpdateResponse contains the response from method WorkspaceProductClient.CreateOrUpdate. +type WorkspaceProductClientCreateOrUpdateResponse struct { + // Product details. + ProductContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceProductClientDeleteResponse contains the response from method WorkspaceProductClient.Delete. +type WorkspaceProductClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceProductClientGetEntityTagResponse contains the response from method WorkspaceProductClient.GetEntityTag. +type WorkspaceProductClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceProductClientGetResponse contains the response from method WorkspaceProductClient.Get. +type WorkspaceProductClientGetResponse struct { + // Product details. + ProductContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceProductClientListByServiceResponse contains the response from method WorkspaceProductClient.NewListByServicePager. +type WorkspaceProductClientListByServiceResponse struct { + // Paged Products list representation. + ProductCollection +} + +// WorkspaceProductClientUpdateResponse contains the response from method WorkspaceProductClient.Update. +type WorkspaceProductClientUpdateResponse struct { + // Product details. + ProductContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceProductGroupLinkClientCreateOrUpdateResponse contains the response from method WorkspaceProductGroupLinkClient.CreateOrUpdate. +type WorkspaceProductGroupLinkClientCreateOrUpdateResponse struct { + // Product-group link details. + ProductGroupLinkContract +} + +// WorkspaceProductGroupLinkClientDeleteResponse contains the response from method WorkspaceProductGroupLinkClient.Delete. +type WorkspaceProductGroupLinkClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceProductGroupLinkClientGetResponse contains the response from method WorkspaceProductGroupLinkClient.Get. +type WorkspaceProductGroupLinkClientGetResponse struct { + // Product-group link details. + ProductGroupLinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceProductGroupLinkClientListByProductResponse contains the response from method WorkspaceProductGroupLinkClient.NewListByProductPager. +type WorkspaceProductGroupLinkClientListByProductResponse struct { + // Paged Product-group link list representation. + ProductGroupLinkCollection +} + +// WorkspaceProductPolicyClientCreateOrUpdateResponse contains the response from method WorkspaceProductPolicyClient.CreateOrUpdate. +type WorkspaceProductPolicyClientCreateOrUpdateResponse struct { + // Policy Contract details. + PolicyContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceProductPolicyClientDeleteResponse contains the response from method WorkspaceProductPolicyClient.Delete. +type WorkspaceProductPolicyClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceProductPolicyClientGetEntityTagResponse contains the response from method WorkspaceProductPolicyClient.GetEntityTag. +type WorkspaceProductPolicyClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceProductPolicyClientGetResponse contains the response from method WorkspaceProductPolicyClient.Get. +type WorkspaceProductPolicyClientGetResponse struct { + // Policy Contract details. + PolicyContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceProductPolicyClientListByProductResponse contains the response from method WorkspaceProductPolicyClient.ListByProduct. +type WorkspaceProductPolicyClientListByProductResponse struct { + // The response of the list policy operation. + PolicyCollection +} + +// WorkspaceSubscriptionClientCreateOrUpdateResponse contains the response from method WorkspaceSubscriptionClient.CreateOrUpdate. +type WorkspaceSubscriptionClientCreateOrUpdateResponse struct { + // Subscription details. + SubscriptionContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceSubscriptionClientDeleteResponse contains the response from method WorkspaceSubscriptionClient.Delete. +type WorkspaceSubscriptionClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceSubscriptionClientGetEntityTagResponse contains the response from method WorkspaceSubscriptionClient.GetEntityTag. +type WorkspaceSubscriptionClientGetEntityTagResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceSubscriptionClientGetResponse contains the response from method WorkspaceSubscriptionClient.Get. +type WorkspaceSubscriptionClientGetResponse struct { + // Subscription details. + SubscriptionContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceSubscriptionClientListResponse contains the response from method WorkspaceSubscriptionClient.NewListPager. +type WorkspaceSubscriptionClientListResponse struct { + // Paged Subscriptions list representation. + SubscriptionCollection +} + +// WorkspaceSubscriptionClientListSecretsResponse contains the response from method WorkspaceSubscriptionClient.ListSecrets. +type WorkspaceSubscriptionClientListSecretsResponse struct { + // Subscription keys. + SubscriptionKeysContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceSubscriptionClientRegeneratePrimaryKeyResponse contains the response from method WorkspaceSubscriptionClient.RegeneratePrimaryKey. +type WorkspaceSubscriptionClientRegeneratePrimaryKeyResponse struct { + // placeholder for future response values +} + +// WorkspaceSubscriptionClientRegenerateSecondaryKeyResponse contains the response from method WorkspaceSubscriptionClient.RegenerateSecondaryKey. +type WorkspaceSubscriptionClientRegenerateSecondaryKeyResponse struct { + // placeholder for future response values +} + +// WorkspaceSubscriptionClientUpdateResponse contains the response from method WorkspaceSubscriptionClient.Update. +type WorkspaceSubscriptionClientUpdateResponse struct { + // Subscription details. + SubscriptionContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceTagAPILinkClientCreateOrUpdateResponse contains the response from method WorkspaceTagAPILinkClient.CreateOrUpdate. +type WorkspaceTagAPILinkClientCreateOrUpdateResponse struct { + // Tag-API link details. + TagAPILinkContract +} + +// WorkspaceTagAPILinkClientDeleteResponse contains the response from method WorkspaceTagAPILinkClient.Delete. +type WorkspaceTagAPILinkClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceTagAPILinkClientGetResponse contains the response from method WorkspaceTagAPILinkClient.Get. +type WorkspaceTagAPILinkClientGetResponse struct { + // Tag-API link details. + TagAPILinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceTagAPILinkClientListByProductResponse contains the response from method WorkspaceTagAPILinkClient.NewListByProductPager. +type WorkspaceTagAPILinkClientListByProductResponse struct { + // Paged Tag-API link list representation. + TagAPILinkCollection +} + +// WorkspaceTagClientCreateOrUpdateResponse contains the response from method WorkspaceTagClient.CreateOrUpdate. +type WorkspaceTagClientCreateOrUpdateResponse struct { + // Tag Contract details. + TagContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceTagClientDeleteResponse contains the response from method WorkspaceTagClient.Delete. +type WorkspaceTagClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceTagClientGetEntityStateResponse contains the response from method WorkspaceTagClient.GetEntityState. +type WorkspaceTagClientGetEntityStateResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspaceTagClientGetResponse contains the response from method WorkspaceTagClient.Get. +type WorkspaceTagClientGetResponse struct { + // Tag Contract details. + TagContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceTagClientListByServiceResponse contains the response from method WorkspaceTagClient.NewListByServicePager. +type WorkspaceTagClientListByServiceResponse struct { + // Paged Tag list representation. + TagCollection +} + +// WorkspaceTagClientUpdateResponse contains the response from method WorkspaceTagClient.Update. +type WorkspaceTagClientUpdateResponse struct { + // Tag Contract details. + TagContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceTagOperationLinkClientCreateOrUpdateResponse contains the response from method WorkspaceTagOperationLinkClient.CreateOrUpdate. +type WorkspaceTagOperationLinkClientCreateOrUpdateResponse struct { + // Tag-operation link details. + TagOperationLinkContract +} + +// WorkspaceTagOperationLinkClientDeleteResponse contains the response from method WorkspaceTagOperationLinkClient.Delete. +type WorkspaceTagOperationLinkClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceTagOperationLinkClientGetResponse contains the response from method WorkspaceTagOperationLinkClient.Get. +type WorkspaceTagOperationLinkClientGetResponse struct { + // Tag-operation link details. + TagOperationLinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceTagOperationLinkClientListByProductResponse contains the response from method WorkspaceTagOperationLinkClient.NewListByProductPager. +type WorkspaceTagOperationLinkClientListByProductResponse struct { + // Paged Tag-operation link list representation. + TagOperationLinkCollection +} + +// WorkspaceTagProductLinkClientCreateOrUpdateResponse contains the response from method WorkspaceTagProductLinkClient.CreateOrUpdate. +type WorkspaceTagProductLinkClientCreateOrUpdateResponse struct { + // Tag-product link details. + TagProductLinkContract +} + +// WorkspaceTagProductLinkClientDeleteResponse contains the response from method WorkspaceTagProductLinkClient.Delete. +type WorkspaceTagProductLinkClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspaceTagProductLinkClientGetResponse contains the response from method WorkspaceTagProductLinkClient.Get. +type WorkspaceTagProductLinkClientGetResponse struct { + // Tag-product link details. + TagProductLinkContract + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspaceTagProductLinkClientListByProductResponse contains the response from method WorkspaceTagProductLinkClient.NewListByProductPager. +type WorkspaceTagProductLinkClientListByProductResponse struct { + // Paged Tag-product link list representation. + TagProductLinkCollection +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/service_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/service_client.go index dcafe2dd35e3..c06eb601533b 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/service_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/service_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type ServiceClient struct { } // NewServiceClient creates a new instance of ServiceClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewServiceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServiceClient, error) { @@ -47,7 +44,7 @@ func NewServiceClient(subscriptionID string, credential azcore.TokenCredential, // pick the updated DNS changes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - ServiceClientBeginApplyNetworkConfigurationUpdatesOptions contains the optional parameters for the ServiceClient.BeginApplyNetworkConfigurationUpdates @@ -74,7 +71,7 @@ func (client *ServiceClient) BeginApplyNetworkConfigurationUpdates(ctx context.C // the updated DNS changes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *ServiceClient) applyNetworkConfigurationUpdates(ctx context.Context, resourceGroupName string, serviceName string, options *ServiceClientBeginApplyNetworkConfigurationUpdatesOptions) (*http.Response, error) { var err error const operationName = "ServiceClient.BeginApplyNetworkConfigurationUpdates" @@ -116,7 +113,7 @@ func (client *ServiceClient) applyNetworkConfigurationUpdatesCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { @@ -132,7 +129,7 @@ func (client *ServiceClient) applyNetworkConfigurationUpdatesCreateRequest(ctx c // and could take several minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - parameters - Parameters supplied to the ApiManagementService_Backup operation. @@ -159,7 +156,7 @@ func (client *ServiceClient) BeginBackup(ctx context.Context, resourceGroupName // and could take several minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *ServiceClient) backup(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, options *ServiceClientBeginBackupOptions) (*http.Response, error) { var err error const operationName = "ServiceClient.BeginBackup" @@ -182,7 +179,7 @@ func (client *ServiceClient) backup(ctx context.Context, resourceGroupName strin } // backupCreateRequest creates the Backup request. -func (client *ServiceClient) backupCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, options *ServiceClientBeginBackupOptions) (*policy.Request, error) { +func (client *ServiceClient) backupCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, _ *ServiceClientBeginBackupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -201,7 +198,7 @@ func (client *ServiceClient) backupCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -213,7 +210,7 @@ func (client *ServiceClient) backupCreateRequest(ctx context.Context, resourceGr // CheckNameAvailability - Checks availability and correctness of a name for an API Management service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - parameters - Parameters supplied to the CheckNameAvailability operation. // - options - ServiceClientCheckNameAvailabilityOptions contains the optional parameters for the ServiceClient.CheckNameAvailability // method. @@ -240,7 +237,7 @@ func (client *ServiceClient) CheckNameAvailability(ctx context.Context, paramete } // checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. -func (client *ServiceClient) checkNameAvailabilityCreateRequest(ctx context.Context, parameters ServiceCheckNameAvailabilityParameters, options *ServiceClientCheckNameAvailabilityOptions) (*policy.Request, error) { +func (client *ServiceClient) checkNameAvailabilityCreateRequest(ctx context.Context, parameters ServiceCheckNameAvailabilityParameters, _ *ServiceClientCheckNameAvailabilityOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -251,7 +248,7 @@ func (client *ServiceClient) checkNameAvailabilityCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -273,7 +270,7 @@ func (client *ServiceClient) checkNameAvailabilityHandleResponse(resp *http.Resp // minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - parameters - Parameters supplied to the CreateOrUpdate API Management service operation. @@ -300,7 +297,7 @@ func (client *ServiceClient) BeginCreateOrUpdate(ctx context.Context, resourceGr // to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *ServiceClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceResource, options *ServiceClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "ServiceClient.BeginCreateOrUpdate" @@ -323,7 +320,7 @@ func (client *ServiceClient) createOrUpdate(ctx context.Context, resourceGroupNa } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ServiceClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceResource, options *ServiceClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ServiceClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceResource, _ *ServiceClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -342,7 +339,7 @@ func (client *ServiceClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -354,7 +351,7 @@ func (client *ServiceClient) createOrUpdateCreateRequest(ctx context.Context, re // BeginDelete - Deletes an existing API Management service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - ServiceClientBeginDeleteOptions contains the optional parameters for the ServiceClient.BeginDelete method. @@ -378,7 +375,7 @@ func (client *ServiceClient) BeginDelete(ctx context.Context, resourceGroupName // Delete - Deletes an existing API Management service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *ServiceClient) deleteOperation(ctx context.Context, resourceGroupName string, serviceName string, options *ServiceClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "ServiceClient.BeginDelete" @@ -401,7 +398,7 @@ func (client *ServiceClient) deleteOperation(ctx context.Context, resourceGroupN } // deleteCreateRequest creates the Delete request. -func (client *ServiceClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ServiceClientBeginDeleteOptions) (*policy.Request, error) { +func (client *ServiceClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *ServiceClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -420,7 +417,7 @@ func (client *ServiceClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -429,7 +426,7 @@ func (client *ServiceClient) deleteCreateRequest(ctx context.Context, resourceGr // Get - Gets an API Management service resource description. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - ServiceClientGetOptions contains the optional parameters for the ServiceClient.Get method. @@ -456,7 +453,7 @@ func (client *ServiceClient) Get(ctx context.Context, resourceGroupName string, } // getCreateRequest creates the Get request. -func (client *ServiceClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ServiceClientGetOptions) (*policy.Request, error) { +func (client *ServiceClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *ServiceClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -475,7 +472,7 @@ func (client *ServiceClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -493,7 +490,7 @@ func (client *ServiceClient) getHandleResponse(resp *http.Response) (ServiceClie // GetDomainOwnershipIdentifier - Get the custom domain ownership identifier for an API Management service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - options - ServiceClientGetDomainOwnershipIdentifierOptions contains the optional parameters for the ServiceClient.GetDomainOwnershipIdentifier // method. func (client *ServiceClient) GetDomainOwnershipIdentifier(ctx context.Context, options *ServiceClientGetDomainOwnershipIdentifierOptions) (ServiceClientGetDomainOwnershipIdentifierResponse, error) { @@ -519,7 +516,7 @@ func (client *ServiceClient) GetDomainOwnershipIdentifier(ctx context.Context, o } // getDomainOwnershipIdentifierCreateRequest creates the GetDomainOwnershipIdentifier request. -func (client *ServiceClient) getDomainOwnershipIdentifierCreateRequest(ctx context.Context, options *ServiceClientGetDomainOwnershipIdentifierOptions) (*policy.Request, error) { +func (client *ServiceClient) getDomainOwnershipIdentifierCreateRequest(ctx context.Context, _ *ServiceClientGetDomainOwnershipIdentifierOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -530,7 +527,7 @@ func (client *ServiceClient) getDomainOwnershipIdentifierCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -548,7 +545,7 @@ func (client *ServiceClient) getDomainOwnershipIdentifierHandleResponse(resp *ht // GetSsoToken - Gets the Single-Sign-On token for the API Management Service which is valid for 5 Minutes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - ServiceClientGetSsoTokenOptions contains the optional parameters for the ServiceClient.GetSsoToken method. @@ -575,7 +572,7 @@ func (client *ServiceClient) GetSsoToken(ctx context.Context, resourceGroupName } // getSsoTokenCreateRequest creates the GetSsoToken request. -func (client *ServiceClient) getSsoTokenCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ServiceClientGetSsoTokenOptions) (*policy.Request, error) { +func (client *ServiceClient) getSsoTokenCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *ServiceClientGetSsoTokenOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -594,7 +591,7 @@ func (client *ServiceClient) getSsoTokenCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -611,7 +608,7 @@ func (client *ServiceClient) getSsoTokenHandleResponse(resp *http.Response) (Ser // NewListPager - Lists all API Management services within an Azure subscription. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - options - ServiceClientListOptions contains the optional parameters for the ServiceClient.NewListPager method. func (client *ServiceClient) NewListPager(options *ServiceClientListOptions) *runtime.Pager[ServiceClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServiceClientListResponse]{ @@ -637,7 +634,7 @@ func (client *ServiceClient) NewListPager(options *ServiceClientListOptions) *ru } // listCreateRequest creates the List request. -func (client *ServiceClient) listCreateRequest(ctx context.Context, options *ServiceClientListOptions) (*policy.Request, error) { +func (client *ServiceClient) listCreateRequest(ctx context.Context, _ *ServiceClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -648,7 +645,7 @@ func (client *ServiceClient) listCreateRequest(ctx context.Context, options *Ser return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -665,7 +662,7 @@ func (client *ServiceClient) listHandleResponse(resp *http.Response) (ServiceCli // NewListByResourceGroupPager - List all API Management services within a resource group. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ServiceClientListByResourceGroupOptions contains the optional parameters for the ServiceClient.NewListByResourceGroupPager // method. @@ -693,7 +690,7 @@ func (client *ServiceClient) NewListByResourceGroupPager(resourceGroupName strin } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *ServiceClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ServiceClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *ServiceClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ServiceClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -708,7 +705,7 @@ func (client *ServiceClient) listByResourceGroupCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -728,7 +725,7 @@ func (client *ServiceClient) listByResourceGroupHandleResponse(resp *http.Respon // minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - ServiceClientBeginMigrateToStv2Options contains the optional parameters for the ServiceClient.BeginMigrateToStv2 @@ -756,7 +753,7 @@ func (client *ServiceClient) BeginMigrateToStv2(ctx context.Context, resourceGro // minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *ServiceClient) migrateToStv2(ctx context.Context, resourceGroupName string, serviceName string, options *ServiceClientBeginMigrateToStv2Options) (*http.Response, error) { var err error const operationName = "ServiceClient.BeginMigrateToStv2" @@ -798,9 +795,15 @@ func (client *ServiceClient) migrateToStv2CreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.Parameters != nil { + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil + } return req, nil } @@ -809,7 +812,7 @@ func (client *ServiceClient) migrateToStv2CreateRequest(ctx context.Context, res // complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - parameters - Parameters supplied to the Restore API Management service from backup operation. @@ -837,7 +840,7 @@ func (client *ServiceClient) BeginRestore(ctx context.Context, resourceGroupName // complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *ServiceClient) restore(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, options *ServiceClientBeginRestoreOptions) (*http.Response, error) { var err error const operationName = "ServiceClient.BeginRestore" @@ -860,7 +863,7 @@ func (client *ServiceClient) restore(ctx context.Context, resourceGroupName stri } // restoreCreateRequest creates the Restore request. -func (client *ServiceClient) restoreCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, options *ServiceClientBeginRestoreOptions) (*policy.Request, error) { +func (client *ServiceClient) restoreCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters, _ *ServiceClientBeginRestoreOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -879,7 +882,7 @@ func (client *ServiceClient) restoreCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -891,7 +894,7 @@ func (client *ServiceClient) restoreCreateRequest(ctx context.Context, resourceG // BeginUpdate - Updates an existing API Management service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - parameters - Parameters supplied to the CreateOrUpdate API Management service operation. @@ -916,7 +919,7 @@ func (client *ServiceClient) BeginUpdate(ctx context.Context, resourceGroupName // Update - Updates an existing API Management service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *ServiceClient) update(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceUpdateParameters, options *ServiceClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "ServiceClient.BeginUpdate" @@ -939,7 +942,7 @@ func (client *ServiceClient) update(ctx context.Context, resourceGroupName strin } // updateCreateRequest creates the Update request. -func (client *ServiceClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceUpdateParameters, options *ServiceClientBeginUpdateOptions) (*policy.Request, error) { +func (client *ServiceClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceUpdateParameters, _ *ServiceClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -958,7 +961,7 @@ func (client *ServiceClient) updateCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/service_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/service_client_example_test.go deleted file mode 100644 index 532ab419012a..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/service_client_example_test.go +++ /dev/null @@ -1,3308 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementRestoreWithAccessKey.json -func ExampleServiceClient_BeginRestore() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginRestore(ctx, "rg1", "apimService1", armapimanagement.ServiceBackupRestoreParameters{ - AccessKey: to.Ptr("**************************************************"), - AccessType: to.Ptr(armapimanagement.AccessTypeAccessKey), - BackupName: to.Ptr("apimService1backup_2017_03_19"), - ContainerName: to.Ptr("backupContainer"), - StorageAccount: to.Ptr("teststorageaccount"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // "tag3": to.Ptr("value3"), - // }, - // Etag: to.Ptr("AAAAAAACXok="), - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(true), - // GatewayRegionalURL: to.Ptr("https://apimService1-eastus-01.regional.azure-api.net"), - // Location: to.Ptr("East US"), - // PublicIPAddresses: []*string{ - // to.Ptr("23.101.138.153")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-01-01"), - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-18T06:26:20.334Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-westus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989XXXXXXXXXXXXXXXXB9C2C91F1D174FDB3A2"), - // }, - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("gateway1.msitesting.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeManagement), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989XXXXXXXXXXXXXXXXB9C2C91F1D174FDB3A2"), - // }, - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("mgmt.msitesting.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypePortal), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989XXXXXXXXXXXXXXXXB9C2C91F1D174FDB3A2"), - // }, - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("portal1.msitesting.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.91.32.113")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementBackupWithAccessKey.json -func ExampleServiceClient_BeginBackup_apiManagementBackupWithAccessKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginBackup(ctx, "rg1", "apimService1", armapimanagement.ServiceBackupRestoreParameters{ - AccessKey: to.Ptr("**************************************************"), - AccessType: to.Ptr(armapimanagement.AccessTypeAccessKey), - BackupName: to.Ptr("apimService1backup_2017_03_19"), - ContainerName: to.Ptr("backupContainer"), - StorageAccount: to.Ptr("teststorageaccount"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // "tag3": to.Ptr("value3"), - // }, - // Etag: to.Ptr("AAAAAAACXok="), - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(true), - // GatewayRegionalURL: to.Ptr("https://apimService1-eastus-01.regional.azure-api.net"), - // Location: to.Ptr("East US"), - // PublicIPAddresses: []*string{ - // to.Ptr("23.101.138.153")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-01-01"), - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-18T06:26:20.334Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-westus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989XXXXXXXXXXXXXXXXB9C2C91F1D174FDB3A2"), - // }, - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("gateway1.msitesting.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeManagement), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989XXXXXXXXXXXXXXXXB9C2C91F1D174FDB3A2"), - // }, - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("mgmt.msitesting.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypePortal), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989XXXXXXXXXXXXXXXXB9C2C91F1D174FDB3A2"), - // }, - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("portal1.msitesting.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.91.32.113")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementBackupWithSystemManagedIdentity.json -func ExampleServiceClient_BeginBackup_apiManagementBackupWithSystemManagedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginBackup(ctx, "rg1", "apimService1", armapimanagement.ServiceBackupRestoreParameters{ - AccessType: to.Ptr(armapimanagement.AccessTypeSystemAssignedManagedIdentity), - BackupName: to.Ptr("backup5"), - ContainerName: to.Ptr("apim-backups"), - StorageAccount: to.Ptr("contosorpstorage"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "Owner": to.Ptr("apimService1"), - // }, - // Etag: to.Ptr("AAAAAAAQM8o="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("00000000-5fb4-4916-95d4-64b306f9d924"), - // TenantID: to.Ptr("00000000-86f1-0000-91ab-2d7cd011db47"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/rg1UserIdentity": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("00000000-a154-4830-0000-46a12da1a1e2"), - // PrincipalID: to.Ptr("00000000-a100-4478-0000-d65d98118ba0"), - // }, - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/vpnpremium": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("00000000-6328-4db2-0000-ab0e3e7806cf"), - // PrincipalID: to.Ptr("00000000-9208-4128-af2d-a10d2af9b5a3"), - // }, - // }, - // }, - // Location: to.Ptr("Central US EUAP"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-23T16:26:47.863Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-centraluseuap-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv1), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("52.XXXX.160.66")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apimService1@corp.microsoft.com"), - // PublisherName: to.Ptr("MS"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // SystemData: &armapimanagement.SystemData{ - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-30T06:24:57.000Z"); return t}()), - // LastModifiedBy: to.Ptr("contoso@microsoft.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementBackupWithUserAssignedManagedIdentity.json -func ExampleServiceClient_BeginBackup_apiManagementBackupWithUserAssignedManagedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginBackup(ctx, "rg1", "apimService1", armapimanagement.ServiceBackupRestoreParameters{ - AccessType: to.Ptr(armapimanagement.AccessTypeUserAssignedManagedIdentity), - BackupName: to.Ptr("backup5"), - ClientID: to.Ptr("XXXXX-a154-4830-XXXX-46a12da1a1e2"), - ContainerName: to.Ptr("apim-backups"), - StorageAccount: to.Ptr("contosorpstorage"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "Owner": to.Ptr("apimService1"), - // }, - // Etag: to.Ptr("AAAAAAAQM8o="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("00000000-5fb4-4916-95d4-64b306f9d924"), - // TenantID: to.Ptr("00000000-86f1-0000-91ab-2d7cd011db47"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/rg1UserIdentity": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("00000000-a154-4830-0000-46a12da1a1e2"), - // PrincipalID: to.Ptr("00000000-a100-4478-0000-d65d98118ba0"), - // }, - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/vpnpremium": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("00000000-6328-4db2-0000-ab0e3e7806cf"), - // PrincipalID: to.Ptr("00000000-9208-4128-af2d-a10d2af9b5a3"), - // }, - // }, - // }, - // Location: to.Ptr("Central US EUAP"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-23T16:26:47.863Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-centraluseuap-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv1), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("52.XXXX.160.66")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apimService1@corp.microsoft.com"), - // PublisherName: to.Ptr("MS"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // SystemData: &armapimanagement.SystemData{ - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-30T06:24:57.000Z"); return t}()), - // LastModifiedBy: to.Ptr("contoso@microsoft.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateMultiRegionServiceWithCustomHostname.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementCreateMultiRegionServiceWithCustomHostname() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - "tag3": to.Ptr("value3"), - }, - Location: to.Ptr("West US"), - Properties: &armapimanagement.ServiceProperties{ - AdditionalLocations: []*armapimanagement.AdditionalLocation{ - { - DisableGateway: to.Ptr(true), - Location: to.Ptr("East US"), - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypePremium), - Capacity: to.Ptr[int32](1), - }, - }}, - APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - MinAPIVersion: to.Ptr("2019-01-01"), - }, - HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - { - Type: to.Ptr(armapimanagement.HostnameTypeProxy), - CertificatePassword: to.Ptr("Password"), - DefaultSSLBinding: to.Ptr(true), - EncodedCertificate: to.Ptr("****** Base 64 Encoded Certificate ************"), - HostName: to.Ptr("gateway1.msitesting.net"), - }, - { - Type: to.Ptr(armapimanagement.HostnameTypeManagement), - CertificatePassword: to.Ptr("Password"), - EncodedCertificate: to.Ptr("****** Base 64 Encoded Certificate ************"), - HostName: to.Ptr("mgmt.msitesting.net"), - }, - { - Type: to.Ptr(armapimanagement.HostnameTypePortal), - CertificatePassword: to.Ptr("Password"), - EncodedCertificate: to.Ptr("****** Base 64 Encoded Certificate ************"), - HostName: to.Ptr("portal1.msitesting.net"), - }}, - VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - PublisherEmail: to.Ptr("apim@autorestsdk.com"), - PublisherName: to.Ptr("autorestsdk"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypePremium), - Capacity: to.Ptr[int32](1), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // "tag3": to.Ptr("value3"), - // }, - // Etag: to.Ptr("AAAAAAACXok="), - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(true), - // GatewayRegionalURL: to.Ptr("https://apimService1-eastus-01.regional.azure-api.net"), - // Location: to.Ptr("East US"), - // PublicIPAddresses: []*string{ - // to.Ptr("23.101.138.153")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-01-01"), - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-18T06:26:20.334Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-westus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989XXXXXXXXXXXXXXXXF1D174FDB3A2"), - // }, - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("gateway1.msitesting.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeManagement), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989XXXXXXXXXXXXXXXXF1D174FDB3A2"), - // }, - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("mgmt.msitesting.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypePortal), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989XXXXXXXXXXXXXXXXF1D174FDB3A2"), - // }, - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("portal1.msitesting.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.91.32.113")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateService.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementCreateService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Tags: map[string]*string{ - "Name": to.Ptr("Contoso"), - "Test": to.Ptr("User"), - }, - Location: to.Ptr("South Central US"), - Properties: &armapimanagement.ServiceProperties{ - PublisherEmail: to.Ptr("foo@contoso.com"), - PublisherName: to.Ptr("foo"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypeDeveloper), - Capacity: to.Ptr[int32](1), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "api-version": to.Ptr("2022-08-01"), - // }, - // Etag: to.Ptr("AAAAAAAmREI="), - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-11T18:41:01.250Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-eastus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv1), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.90.229.33")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("samir@microsoft.com"), - // PublisherName: to.Ptr("foo"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeStandard), - // Capacity: to.Ptr[int32](1), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-11T18:41:00.939Z"); return t}()), - // CreatedBy: to.Ptr("user@contoso.com"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-11T18:41:00.939Z"); return t}()), - // LastModifiedBy: to.Ptr("user@contoso.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceHavingMsi.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementCreateServiceHavingMsi() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - "tag3": to.Ptr("value3"), - }, - Identity: &armapimanagement.ServiceIdentity{ - Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssigned), - }, - Location: to.Ptr("West US"), - Properties: &armapimanagement.ServiceProperties{ - PublisherEmail: to.Ptr("apim@autorestsdk.com"), - PublisherName: to.Ptr("autorestsdk"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypeConsumption), - Capacity: to.Ptr[int32](0), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // "tag3": to.Ptr("value3"), - // }, - // Etag: to.Ptr("AAAAAAAAWiU="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("dfb9a757-df69-4966-a8d0-711a9cd8ffb4"), - // TenantID: to.Ptr("00000000-86f1-41af-91ab-2d7cd011db47"), - // }, - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-11T16:29:29.971Z"); return t}()), - // EnableClientCertificate: to.Ptr(false), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionMtv1), - // ProvisioningState: to.Ptr("Succeeded"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeConsumption), - // Capacity: to.Ptr[int32](0), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceInVnetWithPublicIP.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementCreateServiceInVnetWithPublicIp() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - "tag3": to.Ptr("value3"), - }, - Location: to.Ptr("East US 2 EUAP"), - Properties: &armapimanagement.ServiceProperties{ - PublicIPAddressID: to.Ptr("/subscriptions/subid/resourceGroups/rgName/providers/Microsoft.Network/publicIPAddresses/apimazvnet"), - VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rgName/providers/Microsoft.Network/virtualNetworks/apimcus/subnets/tenant"), - }, - VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeExternal), - PublisherEmail: to.Ptr("apim@autorestsdk.com"), - PublisherName: to.Ptr("autorestsdk"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypePremium), - Capacity: to.Ptr[int32](2), - }, - Zones: []*string{ - to.Ptr("1"), - to.Ptr("2")}, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rgName/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // "tag3": to.Ptr("value3"), - // }, - // Etag: to.Ptr("AAAAAAAGTAs="), - // Location: to.Ptr("East US 2 EUAP"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-02-22T06:53:46.640Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-eastus2euap-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv2), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("20.47.137.XXX")}, - // PublicIPAddressID: to.Ptr("/subscriptions/subid/resourceGroups/rgName/providers/Microsoft.Network/publicIPAddresses/apimazvnet"), - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - // SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rgName/providers/Microsoft.Network/virtualNetworks/apimcus/subnets/tenant"), - // }, - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeExternal), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](2), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // }, - // Zones: []*string{ - // to.Ptr("1"), - // to.Ptr("2")}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceInZones.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementCreateServiceInZones() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - "tag3": to.Ptr("value3"), - }, - Location: to.Ptr("North europe"), - Properties: &armapimanagement.ServiceProperties{ - PublisherEmail: to.Ptr("apim@autorestsdk.com"), - PublisherName: to.Ptr("autorestsdk"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypePremium), - Capacity: to.Ptr[int32](2), - }, - Zones: []*string{ - to.Ptr("1"), - to.Ptr("2")}, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // "tag3": to.Ptr("value3"), - // }, - // Etag: to.Ptr("AAAAAAAiXvE="), - // Location: to.Ptr("North Europe"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-28T23:18:14.656Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-northeurope-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv2), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("20.54.34.66")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](2), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // }, - // Zones: []*string{ - // to.Ptr("1"), - // to.Ptr("2")}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceWithCustomHostnameKeyVault.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementCreateServiceWithCustomHostnameKeyVault() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - "tag3": to.Ptr("value3"), - }, - Identity: &armapimanagement.ServiceIdentity{ - Type: to.Ptr(armapimanagement.ApimIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, - }, - }, - Location: to.Ptr("North Europe"), - Properties: &armapimanagement.ServiceProperties{ - APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - MinAPIVersion: to.Ptr("2019-01-01"), - }, - HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - { - Type: to.Ptr(armapimanagement.HostnameTypeProxy), - DefaultSSLBinding: to.Ptr(true), - HostName: to.Ptr("gateway1.msitesting.net"), - IdentityClientID: to.Ptr("329419bc-adec-4dce-9568-25a6d486e468"), - KeyVaultID: to.Ptr("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), - }, - { - Type: to.Ptr(armapimanagement.HostnameTypeManagement), - HostName: to.Ptr("mgmt.msitesting.net"), - IdentityClientID: to.Ptr("329419bc-adec-4dce-9568-25a6d486e468"), - KeyVaultID: to.Ptr("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), - }, - { - Type: to.Ptr(armapimanagement.HostnameTypePortal), - HostName: to.Ptr("portal1.msitesting.net"), - IdentityClientID: to.Ptr("329419bc-adec-4dce-9568-25a6d486e468"), - KeyVaultID: to.Ptr("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), - }}, - VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - PublisherEmail: to.Ptr("apim@autorestsdk.com"), - PublisherName: to.Ptr("autorestsdk"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypePremium), - Capacity: to.Ptr[int32](1), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // "tag3": to.Ptr("value3"), - // }, - // Etag: to.Ptr("AAAAAAAigjU="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeUserAssigned), - // TenantID: to.Ptr("f686d426-8d16-0000-0000-ab578e110ccd"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("329419bc-adec-4dce-9568-25a6d486e468"), - // PrincipalID: to.Ptr("15e769b2-0000-0000-0000-3fd9a923ac3a"), - // }, - // }, - // }, - // Location: to.Ptr("North Europe"), - // Properties: &armapimanagement.ServiceProperties{ - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-01-01"), - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-13T22:30:20.775Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-northeurope-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2037-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("EA276907917CB5XXXXXXXXXXX690"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceKeyVault), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("gateway1.msitesting.net"), - // IdentityClientID: to.Ptr("329419bc-adec-4dce-9568-25a6d486e468"), - // KeyVaultID: to.Ptr("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeManagement), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2037-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("EA276907917CB5XXXXXXXXXXX690"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceKeyVault), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("mgmt.msitesting.net"), - // IdentityClientID: to.Ptr("329419bc-adec-4dce-9568-25a6d486e468"), - // KeyVaultID: to.Ptr("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypePortal), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2037-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("EA276907917CB5XXXXXXXXXXX690"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceKeyVault), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("portal1.msitesting.net"), - // IdentityClientID: to.Ptr("329419bc-adec-4dce-9568-25a6d486e468"), - // KeyVaultID: to.Ptr("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv2), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("40.112.74.192")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceWithNatGatewayEnabled.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementCreateServiceWithNatGatewayEnabled() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - "tag3": to.Ptr("value3"), - }, - Location: to.Ptr("East US"), - Properties: &armapimanagement.ServiceProperties{ - NatGatewayState: to.Ptr(armapimanagement.NatGatewayStateEnabled), - PublisherEmail: to.Ptr("apim@autorestsdk.com"), - PublisherName: to.Ptr("autorestsdk"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypePremium), - Capacity: to.Ptr[int32](1), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "api-version": to.Ptr("2022-08-01"), - // }, - // Etag: to.Ptr("AAAAAAAmREI="), - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-26T18:41:01.250Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("false"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-eastus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NatGatewayState: to.Ptr(armapimanagement.NatGatewayStateEnabled), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // OutboundPublicIPAddresses: []*string{ - // to.Ptr("60.0.0.0/31")}, - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv2), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.90.229.33")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-11T18:41:00.939Z"); return t}()), - // CreatedBy: to.Ptr("user@contoso.com"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-11T18:41:00.939Z"); return t}()), - // LastModifiedBy: to.Ptr("user@contoso.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceWithSystemCertificates.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementCreateServiceWithSystemCertificates() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - "tag3": to.Ptr("value3"), - }, - Location: to.Ptr("Central US"), - Properties: &armapimanagement.ServiceProperties{ - Certificates: []*armapimanagement.CertificateConfiguration{ - { - CertificatePassword: to.Ptr("Password"), - EncodedCertificate: to.Ptr("*******Base64 encoded Certificate******************"), - StoreName: to.Ptr(armapimanagement.CertificateConfigurationStoreNameCertificateAuthority), - }}, - PublisherEmail: to.Ptr("apim@autorestsdk.com"), - PublisherName: to.Ptr("autorestsdk"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypeBasic), - Capacity: to.Ptr[int32](1), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // "tag3": to.Ptr("value3"), - // }, - // Etag: to.Ptr("AAAAAAAp3UM="), - // Location: to.Ptr("Central US"), - // Properties: &armapimanagement.ServiceProperties{ - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // }, - // Certificates: []*armapimanagement.CertificateConfiguration{ - // { - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2036-01-01T07:00:00.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("8E989652CABCF585ACBFCB9C2C91F1D174FDB3A2"), - // }, - // StoreName: to.Ptr(armapimanagement.CertificateConfigurationStoreNameCertificateAuthority), - // }}, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-18T06:33:28.090Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-centralus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv2), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("40.113.223.117")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeBasic), - // Capacity: to.Ptr[int32](1), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateServiceWithUserAssignedIdentity.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementCreateServiceWithUserAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - "tag3": to.Ptr("value3"), - }, - Identity: &armapimanagement.ServiceIdentity{ - Type: to.Ptr(armapimanagement.ApimIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/apimService1": {}, - }, - }, - Location: to.Ptr("West US"), - Properties: &armapimanagement.ServiceProperties{ - PublisherEmail: to.Ptr("apim@autorestsdk.com"), - PublisherName: to.Ptr("autorestsdk"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypeConsumption), - Capacity: to.Ptr[int32](0), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // "tag3": to.Ptr("value3"), - // }, - // Etag: to.Ptr("AAAAAAAFzyk="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeUserAssigned), - // TenantID: to.Ptr("00000000-86f1-41af-0000-2d7cd011db47"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/apimService1": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("5a2c6b8e-0905-0000-a772-993c9418137f"), - // PrincipalID: to.Ptr("00000000-6e62-4649-9f54-a119fc1ba85e"), - // }, - // }, - // }, - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-12T01:05:33.457Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DisableGateway: to.Ptr(false), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionMtv1), - // ProvisioningState: to.Ptr("Succeeded"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("apim@autorestsdk.com"), - // PublisherName: to.Ptr("autorestsdk"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeConsumption), - // Capacity: to.Ptr[int32](0), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeApplication), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUndelete.json -func ExampleServiceClient_BeginCreateOrUpdate_apiManagementUndelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginCreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceResource{ - Location: to.Ptr("South Central US"), - Properties: &armapimanagement.ServiceProperties{ - Restore: to.Ptr(true), - PublisherEmail: to.Ptr("foo@contoso.com"), - PublisherName: to.Ptr("foo"), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypeDeveloper), - Capacity: to.Ptr[int32](1), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Etag: to.Ptr("AAAAAAAp3T4="), - // Location: to.Ptr("South Central US"), - // Properties: &armapimanagement.ServiceProperties{ - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-18T06:10:56.032Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-southcentralus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("23.102.171.124")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("foo@contoso.com"), - // PublisherName: to.Ptr("foo"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeDeveloper), - // Capacity: to.Ptr[int32](1), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateServiceDisableTls10.json -func ExampleServiceClient_BeginUpdate_apiManagementUpdateServiceDisableTls10() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceUpdateParameters{ - Properties: &armapimanagement.ServiceUpdateProperties{ - CustomProperties: map[string]*string{ - "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("false"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "Owner": to.Ptr("sasolank"), - // "Pool": to.Ptr("Manual"), - // "Reserved": to.Ptr(""), - // "TestExpiration": to.Ptr("Thu, 29 Jun 2017 18:50:40 GMT"), - // "TestSuiteExpiration": to.Ptr("Thu, 29 Jun 2017 18:51:46 GMT"), - // "UID": to.Ptr("4f5025fe-0669-4e2e-8320-5199466e5eb3"), - // }, - // Etag: to.Ptr("AAAAAAAYRPs="), - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-29T17:50:42.319Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // }, - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // }, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("40.86.176.232")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("admin@live.com"), - // PublisherName: to.Ptr("Contoso"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeStandard), - // Capacity: to.Ptr[int32](1), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateServicePublisherDetails.json -func ExampleServiceClient_BeginUpdate_apiManagementUpdateServicePublisherDetails() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceUpdateParameters{ - Properties: &armapimanagement.ServiceUpdateProperties{ - PublisherEmail: to.Ptr("foobar@live.com"), - PublisherName: to.Ptr("Contoso Vnext"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "Owner": to.Ptr("sasolank"), - // "Pool": to.Ptr("Manual"), - // "Reserved": to.Ptr(""), - // "TestExpiration": to.Ptr("Thu, 29 Jun 2017 18:50:40 GMT"), - // "TestSuiteExpiration": to.Ptr("Thu, 29 Jun 2017 18:51:46 GMT"), - // "UID": to.Ptr("4f5025fe-0669-4e2e-8320-5199466e5eb3"), - // }, - // Etag: to.Ptr("AAAAAAAYRPs="), - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-29T17:50:42.319Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // }, - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // }, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("40.86.176.232")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("foobar@live.com"), - // PublisherName: to.Ptr("Contoso Vnext"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeStandard), - // Capacity: to.Ptr[int32](1), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateServiceToNewVnetAndAZs.json -func ExampleServiceClient_BeginUpdate_apiManagementUpdateServiceToNewVnetAndAvailabilityZones() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginUpdate(ctx, "rg1", "apimService1", armapimanagement.ServiceUpdateParameters{ - Properties: &armapimanagement.ServiceUpdateProperties{ - AdditionalLocations: []*armapimanagement.AdditionalLocation{ - { - Location: to.Ptr("Australia East"), - PublicIPAddressID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/apim-australia-east-publicip"), - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypePremium), - Capacity: to.Ptr[int32](3), - }, - VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/apimaeavnet/subnets/default"), - }, - Zones: []*string{ - to.Ptr("1"), - to.Ptr("2"), - to.Ptr("3")}, - }}, - PublicIPAddressID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/publicip-apim-japan-east"), - VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-apim-japaneast/subnets/apim2"), - }, - VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeExternal), - }, - SKU: &armapimanagement.ServiceSKUProperties{ - Name: to.Ptr(armapimanagement.SKUTypePremium), - Capacity: to.Ptr[int32](3), - }, - Zones: []*string{ - to.Ptr("1"), - to.Ptr("2"), - to.Ptr("3")}, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Etag: to.Ptr("AAAAAAAWBIU="), - // Location: to.Ptr("Japan East"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-australiaeast-01.regional.azure-api.net"), - // Location: to.Ptr("Australia East"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv2), - // PublicIPAddresses: []*string{ - // to.Ptr("20.213.1.35")}, - // PublicIPAddressID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/apim-australia-east-publicip"), - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](3), - // }, - // VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - // SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/apimaeavnet/subnets/default"), - // }, - // Zones: []*string{ - // to.Ptr("1"), - // to.Ptr("2"), - // to.Ptr("3")}, - // }}, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-08T23:41:35.644Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_GCM_SHA256": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_256_CBC_SHA": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_256_CBC_SHA256": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("false"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-japaneast-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-09T23:59:59.000Z"); return t}()), - // Subject: to.Ptr("CN=mycustomdomain.int-azure-api.net"), - // Thumbprint: to.Ptr("2994B5FFB8F76B3C687D324A8DEE0432C1ED18CD"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceManaged), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("mycustomdomain.int-azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv2), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("20.78.248.217")}, - // PublicIPAddressID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/publicip-apim-japan-east"), - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - // SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-apim-japaneast/subnets/apim2"), - // }, - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeInternal), - // PublisherEmail: to.Ptr("contoso@microsoft.com"), - // PublisherName: to.Ptr("apimPublisher"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](3), - // }, - // SystemData: &armapimanagement.SystemData{ - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-21T20:04:21.610Z"); return t}()), - // LastModifiedBy: to.Ptr("contoso@microsoft.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // Zones: []*string{ - // to.Ptr("1"), - // to.Ptr("2"), - // to.Ptr("3")}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetMultiRegionInternalVnet.json -func ExampleServiceClient_Get_apiManagementServiceGetMultiRegionInternalVnet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewServiceClient().Get(ctx, "rg1", "apimService1", 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.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimservice1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimservice1"), - // Tags: map[string]*string{ - // }, - // Etag: to.Ptr("AAAAAADqC0c="), - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimservice1-westus2-01.regional.azure-api.net"), - // Location: to.Ptr("West US 2"), - // PrivateIPAddresses: []*string{ - // to.Ptr("10.0.X.6")}, - // PublicIPAddresses: []*string{ - // to.Ptr("40.XXX.79.187")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - // SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/APIMVNet/subnets/apim-internal-sub"), - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-02T01:42:09.126Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("True"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimservice1-westus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimservice1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-16T16:51:34.000Z"); return t}()), - // Subject: to.Ptr("CN=*.preview.net"), - // Thumbprint: to.Ptr("B4330123DBAXXXXXXXXX1F35E84493476"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimgatewaytest.preview.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimservice1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://apimservice1.portal.azure-api.net"), - // PrivateIPAddresses: []*string{ - // to.Ptr("172.XX.0.5")}, - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("137.XXX.11.74")}, - // ScmURL: to.Ptr("https://apimservice1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - // SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/apim-appGateway-vnet/subnets/apim-subnet"), - // }, - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeInternal), - // PublisherEmail: to.Ptr("abcs@contoso.com"), - // PublisherName: to.Ptr("contoso publisher"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetService.json -func ExampleServiceClient_Get_apiManagementServiceGetService() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewServiceClient().Get(ctx, "rg1", "apimService1", 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.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("OGF-Z3-06162021-Premium"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/OGF-Z3-06162021-Premium"), - // Tags: map[string]*string{ - // "ReleaseName": to.Ptr("Z3"), - // "owner": to.Ptr("v-aswmoh"), - // }, - // Etag: to.Ptr("AAAAAAAWN/4="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("306205e7-b21a-41bf-92e2-3e28af30041e"), - // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ogf-identity": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("8d9791f2-0cdf-41f4-9e66-cdc39b496789"), - // PrincipalID: to.Ptr("713784d2-ee37-412a-95f0-3768f397f82d"), - // }, - // }, - // }, - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-z3-06162021-premium-eastus2-01.regional.azure-api.net"), - // Location: to.Ptr("East US 2"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv2), - // PublicIPAddresses: []*string{ - // to.Ptr("40.70.24.106")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // Zones: []*string{ - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-12-01"), - // }, - // Certificates: []*armapimanagement.CertificateConfiguration{ - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:40:00.945Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("false"), - // }, - // DeveloperPortalURL: to.Ptr("https://ogf-z3-06162021-premium.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-z3-06162021-premium-eastus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://ogf-z3-06162021-premium.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("ogf-z3-06162021-premium.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T22:32:32.000Z"); return t}()), - // Subject: to.Ptr("CN=*.current.int-azure-api.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US"), - // Thumbprint: to.Ptr("BA0C286XXXXXXXX58A4A507E3DBD51"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("gateway.current.int-azure-api.net"), - // KeyVaultID: to.Ptr("https://ogf-testing.vault.azure.net/secrets/current-ssl"), - // NegotiateClientCertificate: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeDeveloperPortal), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T22:32:32.000Z"); return t}()), - // Subject: to.Ptr("CN=*.current.int-azure-api.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US"), - // Thumbprint: to.Ptr("BA0C286XXXXXXXX58A4A507E3DBD51"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("developer.current.int-azure-api.net"), - // KeyVaultID: to.Ptr("https://ogf-testing.vault.azure.net/secrets/current-ssl"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeManagement), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T22:32:32.000Z"); return t}()), - // Subject: to.Ptr("CN=*.current.int-azure-api.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US"), - // Thumbprint: to.Ptr("BA0C286XXXXXXXX58A4A507E3DBD51"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("mgmt.current.int-azure-api.net"), - // KeyVaultID: to.Ptr("https://ogf-testing.vault.azure.net/secrets/current-ssl"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://ogf-z3-06162021-premium.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv2), - // PortalURL: to.Ptr("https://ogf-z3-06162021-premium.portal.azure-api.net"), - // PrivateEndpointConnections: []*armapimanagement.RemotePrivateEndpointConnectionWrapper{ - // { - // Name: to.Ptr("privateEndpointProxyName"), - // Type: to.Ptr("Microsoft.ApiManagement/service/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/privateEndpointProxyName"), - // Properties: &armapimanagement.PrivateEndpointConnectionWrapperProperties{ - // GroupIDs: []*string{ - // to.Ptr("Gateway")}, - // PrivateEndpoint: &armapimanagement.ArmIDWrapper{ - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), - // }, - // PrivateLinkServiceConnectionState: &armapimanagement.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Please approve my request, thanks"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armapimanagement.PrivateEndpointServiceConnectionStatusPending), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // }}, - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.92.130.49")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://ogf-z3-06162021-premium.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("string"), - // PublisherName: to.Ptr("Test Premium"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:40:00.710Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-20T06:33:09.615Z"); return t}()), - // LastModifiedBy: to.Ptr("foo@contoso.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetServiceHavingMsi.json -func ExampleServiceClient_Get_apiManagementServiceGetServiceHavingMsi() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewServiceClient().Get(ctx, "rg1", "apimService1", 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.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // }, - // Etag: to.Ptr("AAAAAAAENfI="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("ca1d33f7-0000-42ec-0000-d526a1ee953a"), - // TenantID: to.Ptr("72f988bf-0000-41af-0000-2d7cd011db47"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/apimService1": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("aaff9c7d-0000-4db2-0000-ab0e3e7806cf"), - // PrincipalID: to.Ptr("95194df2-9208-0000-0000-a10d2af9b5a3"), - // }, - // }, - // }, - // Location: to.Ptr("West Europe"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-04-12T00:20:15.601Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("True"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimService1-westeurope-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-18T11:11:47.000Z"); return t}()), - // Subject: to.Ptr("CN=*.msitesting.net"), - // Thumbprint: to.Ptr("9833D531D7A45XXXXXA85908BD3692E0BD3F"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceKeyVault), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("proxy.msitesting.net"), - // KeyVaultID: to.Ptr("https://samir-msi-keyvault.vault.azure.net/secrets/msicertificate"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.94.xxx.188")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - // SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/dfVirtualNetwork/subnets/backendSubnet"), - // }, - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeExternal), - // PublisherEmail: to.Ptr("foo@contoso.com"), - // PublisherName: to.Ptr("Contoso"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceDeleteService.json -func ExampleServiceClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginDelete(ctx, "rg1", "apimService1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceMigrateToStv2.json -func ExampleServiceClient_BeginMigrateToStv2() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginMigrateToStv2(ctx, "rg1", "apimService1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimservice1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimservice1"), - // Tags: map[string]*string{ - // }, - // Etag: to.Ptr("AAAAAADqC0c="), - // Location: to.Ptr("West US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimservice1-westus2-01.regional.azure-api.net"), - // Location: to.Ptr("West US 2"), - // PrivateIPAddresses: []*string{ - // to.Ptr("10.0.X.6")}, - // PublicIPAddresses: []*string{ - // to.Ptr("40.XXX.79.187")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - // SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/APIMVNet/subnets/apim-internal-sub"), - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-02T01:42:09.126Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("True"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("True"), - // }, - // DeveloperPortalURL: to.Ptr("https://apimService1.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://apimservice1-westus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://apimservice1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("apimService1.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-16T16:51:34.000Z"); return t}()), - // Subject: to.Ptr("CN=*.preview.net"), - // Thumbprint: to.Ptr("B4330123DBAXXXXXXXXX1F35E84493476"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("apimgatewaytest.preview.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://apimservice1.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PlatformVersion: to.Ptr(armapimanagement.PlatformVersionStv1), - // PortalURL: to.Ptr("https://apimservice1.portal.azure-api.net"), - // PrivateIPAddresses: []*string{ - // to.Ptr("172.XX.0.5")}, - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("137.XXX.11.74")}, - // ScmURL: to.Ptr("https://apimservice1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - // SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/apim-appGateway-vnet/subnets/apim-subnet"), - // }, - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeInternal), - // PublisherEmail: to.Ptr("abcs@contoso.com"), - // PublisherName: to.Ptr("contoso publisher"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListServiceBySubscriptionAndResourceGroup.json -func ExampleServiceClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewServiceClient().NewListByResourceGroupPager("rg1", 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.ServiceListResult = armapimanagement.ServiceListResult{ - // Value: []*armapimanagement.ServiceResource{ - // { - // Name: to.Ptr("OGF-Z3-06162021-Premium"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/OGF-Z3-06162021-Premium"), - // Tags: map[string]*string{ - // "ReleaseName": to.Ptr("Z3"), - // "owner": to.Ptr("v-aswmoh"), - // }, - // Etag: to.Ptr("AAAAAAAWN/4="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("306205e7-b21a-41bf-92e2-3e28af30041e"), - // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ogf-identity": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("8d9791f2-0cdf-41f4-9e66-cdc39b496789"), - // PrincipalID: to.Ptr("713784d2-ee37-412a-95f0-3768f397f82d"), - // }, - // }, - // }, - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-z3-06162021-premium-eastus2-01.regional.azure-api.net"), - // Location: to.Ptr("East US 2"), - // PublicIPAddresses: []*string{ - // to.Ptr("40.70.24.106")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // Zones: []*string{ - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-12-01"), - // }, - // Certificates: []*armapimanagement.CertificateConfiguration{ - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:40:00.945Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("false"), - // }, - // DeveloperPortalURL: to.Ptr("https://ogf-z3-06162021-premium.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-z3-06162021-premium-eastus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://ogf-z3-06162021-premium.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("ogf-z3-06162021-premium.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T22:32:32.000Z"); return t}()), - // Subject: to.Ptr("CN=*.current.int-azure-api.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US"), - // Thumbprint: to.Ptr("BA0C286F71AF3B6A01BDB240C58A4A507E3DBD51"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("gateway.current.int-azure-api.net"), - // KeyVaultID: to.Ptr("https://ogf-testing.vault-int.azure-int.net/secrets/current-ssl"), - // NegotiateClientCertificate: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeDeveloperPortal), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T22:32:32.000Z"); return t}()), - // Subject: to.Ptr("CN=*.current.int-azure-api.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US"), - // Thumbprint: to.Ptr("BA0C286F71AF3B6A01BDB240C58A4A507E3DBD51"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("developer.current.int-azure-api.net"), - // KeyVaultID: to.Ptr("https://ogf-testing.vault-int.azure-int.net/secrets/current-ssl"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeManagement), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T22:32:32.000Z"); return t}()), - // Subject: to.Ptr("CN=*.current.int-azure-api.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US"), - // Thumbprint: to.Ptr("BA0C286F71AF3B6A01BDB240C58A4A507E3DBD51"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("mgmt.current.int-azure-api.net"), - // KeyVaultID: to.Ptr("https://ogf-testing.vault-int.azure-int.net/secrets/current-ssl"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://ogf-z3-06162021-premium.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://ogf-z3-06162021-premium.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.92.130.49")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://ogf-z3-06162021-premium.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("bar@contoso.com"), - // PublisherName: to.Ptr("Test Premium"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:40:00.710Z"); return t}()), - // CreatedBy: to.Ptr("bar@contoso.com"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-20T06:33:09.615Z"); return t}()), - // LastModifiedBy: to.Ptr("foo@contoso.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("vvktestcons"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/vvktestcons"), - // Tags: map[string]*string{ - // "Owner": to.Ptr("vitaliik"), - // }, - // Etag: to.Ptr("AAAAAAAWKwo="), - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-10T18:07:23.456Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DisableGateway: to.Ptr(false), - // EnableClientCertificate: to.Ptr(false), - // GatewayURL: to.Ptr("https://vvktestcons.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("vvktestcons.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("bar@contoso.com"), - // PublisherName: to.Ptr("vvktestcons"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeConsumption), - // Capacity: to.Ptr[int32](0), - // }, - // }, - // { - // Name: to.Ptr("OGF-Z3-06162021-Standard"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/OGF-Z3-06162021-Standard"), - // Tags: map[string]*string{ - // }, - // Etag: to.Ptr("AAAAAAAWF7M="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("347a5800-ca99-475a-9202-fe38ca79ee41"), - // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ogf-identity": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("8d9791f2-0cdf-41f4-9e66-cdc39b496789"), - // PrincipalID: to.Ptr("713784d2-ee37-412a-95f0-3768f397f82d"), - // }, - // }, - // }, - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-12-01"), - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:39:58.655Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA": to.Ptr("true"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://ogf-z3-06162021-standard.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-z3-06162021-standard-eastus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://ogf-z3-06162021-standard.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("ogf-z3-06162021-standard.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://ogf-z3-06162021-standard.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://ogf-z3-06162021-standard.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.82.208.32")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://ogf-z3-06162021-standard.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("bar@contoso.com"), - // PublisherName: to.Ptr("Test Standard"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeStandard), - // Capacity: to.Ptr[int32](2), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:39:58.459Z"); return t}()), - // CreatedBy: to.Ptr("bar@contoso.com"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T15:05:13.549Z"); return t}()), - // LastModifiedBy: to.Ptr("bar@contoso.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("ogf-dev-060921"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/ogf-dev-060921"), - // Tags: map[string]*string{ - // }, - // Etag: to.Ptr("AAAAAAAWEFg="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("c9bd4c05-205e-4431-b232-112cf2e9e0aa"), - // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), - // }, - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-dev-060921-southcentralus-01.regional.azure-api.net"), - // Location: to.Ptr("South Central US"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.84.208.29")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](9), - // }, - // Zones: []*string{ - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-12-01"), - // }, - // Certificates: []*armapimanagement.CertificateConfiguration{ - // { - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T22:51:47.000Z"); return t}()), - // Subject: to.Ptr("CN=*.apim.net"), - // Thumbprint: to.Ptr("4E8234312EC69245D1AE296C4882D46FB84076A3"), - // }, - // StoreName: to.Ptr(armapimanagement.CertificateConfigurationStoreNameRoot), - // }}, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-09T10:06:22.213Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("false"), - // }, - // DeveloperPortalURL: to.Ptr("https://ogf-dev-060921.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-dev-060921-eastus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://ogf-dev-060921.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("ogf-dev-060921.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://ogf-dev-060921.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://ogf-dev-060921.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("168.62.39.172")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://ogf-dev-060921.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("v-ssaiprasan@microsoft.com"), - // PublisherName: to.Ptr("TechM"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](3), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-09T10:06:21.733Z"); return t}()), - // CreatedBy: to.Ptr("v-ssaiprasan@microsoft.com"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T14:27:05.546Z"); return t}()), - // LastModifiedBy: to.Ptr("v-ssaiprasan@microsoft.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListServiceBySubscription.json -func ExampleServiceClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewServiceClient().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.ServiceListResult = armapimanagement.ServiceListResult{ - // Value: []*armapimanagement.ServiceResource{ - // { - // Name: to.Ptr("OGF-Z3-06162021-Premium"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/OGF-Z3-06162021-Premium"), - // Tags: map[string]*string{ - // "ReleaseName": to.Ptr("Z3"), - // "owner": to.Ptr("v-aswmoh"), - // }, - // Etag: to.Ptr("AAAAAAAWN/4="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("306205e7-b21a-41bf-92e2-3e28af30041e"), - // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ogf-identity": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("8d9791f2-0cdf-41f4-9e66-cdc39b496789"), - // PrincipalID: to.Ptr("713784d2-ee37-412a-95f0-3768f397f82d"), - // }, - // }, - // }, - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-z3-06162021-premium-eastus2-01.regional.azure-api.net"), - // Location: to.Ptr("East US 2"), - // PublicIPAddresses: []*string{ - // to.Ptr("40.70.24.106")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // Zones: []*string{ - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-12-01"), - // }, - // Certificates: []*armapimanagement.CertificateConfiguration{ - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:40:00.945Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("false"), - // }, - // DeveloperPortalURL: to.Ptr("https://ogf-z3-06162021-premium.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-z3-06162021-premium-eastus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://ogf-z3-06162021-premium.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("ogf-z3-06162021-premium.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T22:32:32.000Z"); return t}()), - // Subject: to.Ptr("CN=*.current.int-azure-api.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US"), - // Thumbprint: to.Ptr("BA0C286F71AF3B6A01BDB240C58A4A507E3DBD51"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("gateway.current.int-azure-api.net"), - // KeyVaultID: to.Ptr("https://ogf-testing.vault-int.azure-int.net/secrets/current-ssl"), - // NegotiateClientCertificate: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeDeveloperPortal), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T22:32:32.000Z"); return t}()), - // Subject: to.Ptr("CN=*.current.int-azure-api.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US"), - // Thumbprint: to.Ptr("BA0C286F71AF3B6A01BDB240C58A4A507E3DBD51"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("developer.current.int-azure-api.net"), - // KeyVaultID: to.Ptr("https://ogf-testing.vault-int.azure-int.net/secrets/current-ssl"), - // NegotiateClientCertificate: to.Ptr(false), - // }, - // { - // Type: to.Ptr(armapimanagement.HostnameTypeManagement), - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-08T22:32:32.000Z"); return t}()), - // Subject: to.Ptr("CN=*.current.int-azure-api.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US"), - // Thumbprint: to.Ptr("BA0C286F71AF3B6A01BDB240C58A4A507E3DBD51"), - // }, - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceCustom), - // DefaultSSLBinding: to.Ptr(false), - // HostName: to.Ptr("mgmt.current.int-azure-api.net"), - // KeyVaultID: to.Ptr("https://ogf-testing.vault-int.azure-int.net/secrets/current-ssl"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://ogf-z3-06162021-premium.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://ogf-z3-06162021-premium.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.92.130.49")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://ogf-z3-06162021-premium.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("bar@contoso.com"), - // PublisherName: to.Ptr("Test Premium"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:40:00.710Z"); return t}()), - // CreatedBy: to.Ptr("bar@contoso.com"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-20T06:33:09.615Z"); return t}()), - // LastModifiedBy: to.Ptr("foo@contoso.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("vvktestcons"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/vvktestcons"), - // Tags: map[string]*string{ - // "Owner": to.Ptr("vitaliik"), - // }, - // Etag: to.Ptr("AAAAAAAWKwo="), - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-10T18:07:23.456Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DisableGateway: to.Ptr(false), - // EnableClientCertificate: to.Ptr(false), - // GatewayURL: to.Ptr("https://vvktestcons.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("vvktestcons.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("bar@contoso.com"), - // PublisherName: to.Ptr("vvktestcons"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeConsumption), - // Capacity: to.Ptr[int32](0), - // }, - // }, - // { - // Name: to.Ptr("OGF-Z3-06162021-Standard"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/OGF-Z3-06162021-Standard"), - // Tags: map[string]*string{ - // }, - // Etag: to.Ptr("AAAAAAAWF7M="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("347a5800-ca99-475a-9202-fe38ca79ee41"), - // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), - // UserAssignedIdentities: map[string]*armapimanagement.UserIdentityProperties{ - // "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ogf-identity": &armapimanagement.UserIdentityProperties{ - // ClientID: to.Ptr("8d9791f2-0cdf-41f4-9e66-cdc39b496789"), - // PrincipalID: to.Ptr("713784d2-ee37-412a-95f0-3768f397f82d"), - // }, - // }, - // }, - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-12-01"), - // }, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:39:58.655Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA": to.Ptr("true"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("False"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("False"), - // }, - // DeveloperPortalURL: to.Ptr("https://ogf-z3-06162021-standard.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-z3-06162021-standard-eastus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://ogf-z3-06162021-standard.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("ogf-z3-06162021-standard.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://ogf-z3-06162021-standard.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://ogf-z3-06162021-standard.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.82.208.32")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://ogf-z3-06162021-standard.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("bar@contoso.com"), - // PublisherName: to.Ptr("Test Standard"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypeStandard), - // Capacity: to.Ptr[int32](2), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-16T09:39:58.459Z"); return t}()), - // CreatedBy: to.Ptr("bar@contoso.com"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-17T15:05:13.549Z"); return t}()), - // LastModifiedBy: to.Ptr("bar@contoso.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("ogf-dev-060921"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/ogf-dev-060921"), - // Tags: map[string]*string{ - // }, - // Etag: to.Ptr("AAAAAAAWEFg="), - // Identity: &armapimanagement.ServiceIdentity{ - // Type: to.Ptr(armapimanagement.ApimIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("c9bd4c05-205e-4431-b232-112cf2e9e0aa"), - // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), - // }, - // Location: to.Ptr("East US"), - // Properties: &armapimanagement.ServiceProperties{ - // AdditionalLocations: []*armapimanagement.AdditionalLocation{ - // { - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-dev-060921-southcentralus-01.regional.azure-api.net"), - // Location: to.Ptr("South Central US"), - // PublicIPAddresses: []*string{ - // to.Ptr("13.84.208.29")}, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](9), - // }, - // Zones: []*string{ - // }, - // }}, - // APIVersionConstraint: &armapimanagement.APIVersionConstraint{ - // MinAPIVersion: to.Ptr("2019-12-01"), - // }, - // Certificates: []*armapimanagement.CertificateConfiguration{ - // { - // Certificate: &armapimanagement.CertificateInformation{ - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-25T22:51:47.000Z"); return t}()), - // Subject: to.Ptr("CN=*.apim.net"), - // Thumbprint: to.Ptr("4E8234312EC69245D1AE296C4882D46FB84076A3"), - // }, - // StoreName: to.Ptr(armapimanagement.CertificateConfigurationStoreNameRoot), - // }}, - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-09T10:06:22.213Z"); return t}()), - // CustomProperties: map[string]*string{ - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": to.Ptr("false"), - // "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": to.Ptr("false"), - // }, - // DeveloperPortalURL: to.Ptr("https://ogf-dev-060921.developer.azure-api.net"), - // DisableGateway: to.Ptr(false), - // GatewayRegionalURL: to.Ptr("https://ogf-dev-060921-eastus-01.regional.azure-api.net"), - // GatewayURL: to.Ptr("https://ogf-dev-060921.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // { - // Type: to.Ptr(armapimanagement.HostnameTypeProxy), - // CertificateSource: to.Ptr(armapimanagement.CertificateSourceBuiltIn), - // DefaultSSLBinding: to.Ptr(true), - // HostName: to.Ptr("ogf-dev-060921.azure-api.net"), - // NegotiateClientCertificate: to.Ptr(false), - // }}, - // ManagementAPIURL: to.Ptr("https://ogf-dev-060921.management.azure-api.net"), - // NotificationSenderEmail: to.Ptr("apimgmt-noreply@mail.windowsazure.com"), - // PortalURL: to.Ptr("https://ogf-dev-060921.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("168.62.39.172")}, - // PublicNetworkAccess: to.Ptr(armapimanagement.PublicNetworkAccessEnabled), - // ScmURL: to.Ptr("https://ogf-dev-060921.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeNone), - // PublisherEmail: to.Ptr("v-ssaiprasan@microsoft.com"), - // PublisherName: to.Ptr("TechM"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](3), - // }, - // SystemData: &armapimanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-09T10:06:21.733Z"); return t}()), - // CreatedBy: to.Ptr("v-ssaiprasan@microsoft.com"), - // CreatedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-10T14:27:05.546Z"); return t}()), - // LastModifiedBy: to.Ptr("v-ssaiprasan@microsoft.com"), - // LastModifiedByType: to.Ptr(armapimanagement.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetSsoToken.json -func ExampleServiceClient_GetSsoToken() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewServiceClient().GetSsoToken(ctx, "rg1", "apimService1", 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.ServiceGetSsoTokenResult = armapimanagement.ServiceGetSsoTokenResult{ - // RedirectURI: to.Ptr("https://apimService1.portal.azure-api.net:443/signin-sso?token=1%26201705301929%26eIkr3%2fnfaLs1GVJ0OVbzkJjAcwPFkEZAPM8VUXvXPf7cJ6lWsB9oUwsk2zln9x0KLkn21txCPJWWheSPq7SNeA%3d%3d"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceCheckNameAvailability.json -func ExampleServiceClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewServiceClient().CheckNameAvailability(ctx, armapimanagement.ServiceCheckNameAvailabilityParameters{ - Name: to.Ptr("apimService1"), - }, 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.ServiceNameAvailabilityResult = armapimanagement.ServiceNameAvailabilityResult{ - // Message: to.Ptr(""), - // NameAvailable: to.Ptr(true), - // Reason: to.Ptr(armapimanagement.NameAvailabilityReasonValid), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementServiceGetDomainOwnershipIdentifier.json -func ExampleServiceClient_GetDomainOwnershipIdentifier() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewServiceClient().GetDomainOwnershipIdentifier(ctx, 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.ServiceGetDomainOwnershipIdentifierResult = armapimanagement.ServiceGetDomainOwnershipIdentifierResult{ - // DomainOwnershipIdentifier: to.Ptr("KLE1vdMblVeHECAi4nCe3oNaXXXXvNlLrXt2ev84KM="), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementApplyNetworkConfigurationUpdates.json -func ExampleServiceClient_BeginApplyNetworkConfigurationUpdates() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewServiceClient().BeginApplyNetworkConfigurationUpdates(ctx, "rg1", "apimService1", &armapimanagement.ServiceClientBeginApplyNetworkConfigurationUpdatesOptions{Parameters: &armapimanagement.ServiceApplyNetworkConfigurationParameters{ - Location: to.Ptr("west us"), - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResource = armapimanagement.ServiceResource{ - // Name: to.Ptr("apimService1"), - // Type: to.Ptr("Microsoft.ApiManagement/service"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1"), - // Tags: map[string]*string{ - // "UID": to.Ptr("52ed5986-717b-45b4-b17c-3df8db372cff"), - // }, - // Etag: to.Ptr("AAAAAAAXX6Y="), - // Location: to.Ptr("East Asia"), - // Properties: &armapimanagement.ServiceProperties{ - // CreatedAtUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2015-09-22T01:50:34.792Z"); return t}()), - // GatewayURL: to.Ptr("https://apimService1.azure-api.net"), - // HostnameConfigurations: []*armapimanagement.HostnameConfiguration{ - // }, - // ManagementAPIURL: to.Ptr("https://apimService1.management.azure-api.net"), - // PortalURL: to.Ptr("https://apimService1.portal.azure-api.net"), - // ProvisioningState: to.Ptr("Succeeded"), - // PublicIPAddresses: []*string{ - // to.Ptr("207.46.155.24")}, - // ScmURL: to.Ptr("https://apimService1.scm.azure-api.net"), - // TargetProvisioningState: to.Ptr(""), - // VirtualNetworkConfiguration: &armapimanagement.VirtualNetworkConfiguration{ - // SubnetResourceID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/eastUsVirtualNetwork/subnets/apimSubnet"), - // }, - // VirtualNetworkType: to.Ptr(armapimanagement.VirtualNetworkTypeExternal), - // PublisherEmail: to.Ptr("admin@live.com"), - // PublisherName: to.Ptr("Contoso"), - // }, - // SKU: &armapimanagement.ServiceSKUProperties{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // Capacity: to.Ptr[int32](1), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/serviceskus_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/serviceskus_client.go index 35dd5ec5f523..a9508557d1e0 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/serviceskus_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/serviceskus_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type ServiceSKUsClient struct { } // NewServiceSKUsClient creates a new instance of ServiceSKUsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewServiceSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServiceSKUsClient, error) { @@ -45,7 +42,7 @@ func NewServiceSKUsClient(subscriptionID string, credential azcore.TokenCredenti // NewListAvailableServiceSKUsPager - Gets all available SKU for a given API Management service // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - ServiceSKUsClientListAvailableServiceSKUsOptions contains the optional parameters for the ServiceSKUsClient.NewListAvailableServiceSKUsPager @@ -74,7 +71,7 @@ func (client *ServiceSKUsClient) NewListAvailableServiceSKUsPager(resourceGroupN } // listAvailableServiceSKUsCreateRequest creates the ListAvailableServiceSKUs request. -func (client *ServiceSKUsClient) listAvailableServiceSKUsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ServiceSKUsClientListAvailableServiceSKUsOptions) (*policy.Request, error) { +func (client *ServiceSKUsClient) listAvailableServiceSKUsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *ServiceSKUsClientListAvailableServiceSKUsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -93,7 +90,7 @@ func (client *ServiceSKUsClient) listAvailableServiceSKUsCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/serviceskus_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/serviceskus_client_example_test.go deleted file mode 100644 index 8959741ec5e7..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/serviceskus_client_example_test.go +++ /dev/null @@ -1,140 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSKUs-Consumption.json -func ExampleServiceSKUsClient_NewListAvailableServiceSKUsPager_apiManagementListSkUsConsumption() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewServiceSKUsClient().NewListAvailableServiceSKUsPager("rg1", "apimService1", 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.ResourceSKUResults = armapimanagement.ResourceSKUResults{ - // Value: []*armapimanagement.ResourceSKUResult{ - // { - // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), - // SKU: &armapimanagement.ResourceSKU{ - // Name: to.Ptr(armapimanagement.SKUTypeConsumption), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSKUs-Dedicated.json -func ExampleServiceSKUsClient_NewListAvailableServiceSKUsPager_apiManagementListSkUsDedicated() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewServiceSKUsClient().NewListAvailableServiceSKUsPager("rg1", "apimService1", 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.ResourceSKUResults = armapimanagement.ResourceSKUResults{ - // Value: []*armapimanagement.ResourceSKUResult{ - // { - // Capacity: &armapimanagement.ResourceSKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](1), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.ResourceSKUCapacityScaleTypeNone), - // }, - // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), - // SKU: &armapimanagement.ResourceSKU{ - // Name: to.Ptr(armapimanagement.SKUTypeDeveloper), - // }, - // }, - // { - // Capacity: &armapimanagement.ResourceSKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](2), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.ResourceSKUCapacityScaleTypeManual), - // }, - // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), - // SKU: &armapimanagement.ResourceSKU{ - // Name: to.Ptr(armapimanagement.SKUTypeBasic), - // }, - // }, - // { - // Capacity: &armapimanagement.ResourceSKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](4), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.ResourceSKUCapacityScaleTypeAutomatic), - // }, - // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), - // SKU: &armapimanagement.ResourceSKU{ - // Name: to.Ptr(armapimanagement.SKUTypeStandard), - // }, - // }, - // { - // Capacity: &armapimanagement.ResourceSKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](10), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.ResourceSKUCapacityScaleTypeAutomatic), - // }, - // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), - // SKU: &armapimanagement.ResourceSKU{ - // Name: to.Ptr(armapimanagement.SKUTypePremium), - // }, - // }, - // { - // Capacity: &armapimanagement.ResourceSKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](1), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.ResourceSKUCapacityScaleTypeAutomatic), - // }, - // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), - // SKU: &armapimanagement.ResourceSKU{ - // Name: to.Ptr(armapimanagement.SKUTypeIsolated), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/signinsettings_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/signinsettings_client.go index 65d57140a55b..f15bca91f814 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/signinsettings_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/signinsettings_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type SignInSettingsClient struct { } // NewSignInSettingsClient creates a new instance of SignInSettingsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewSignInSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SignInSettingsClient, error) { @@ -46,7 +43,7 @@ func NewSignInSettingsClient(subscriptionID string, credential azcore.TokenCrede // CreateOrUpdate - Create or Update Sign-In settings. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - parameters - Create or update parameters. @@ -94,12 +91,12 @@ func (client *SignInSettingsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -118,7 +115,7 @@ func (client *SignInSettingsClient) createOrUpdateHandleResponse(resp *http.Resp // Get - Get Sign In Settings for the Portal // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - SignInSettingsClientGetOptions contains the optional parameters for the SignInSettingsClient.Get method. @@ -145,7 +142,7 @@ func (client *SignInSettingsClient) Get(ctx context.Context, resourceGroupName s } // getCreateRequest creates the Get request. -func (client *SignInSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *SignInSettingsClientGetOptions) (*policy.Request, error) { +func (client *SignInSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *SignInSettingsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -164,7 +161,7 @@ func (client *SignInSettingsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -184,7 +181,7 @@ func (client *SignInSettingsClient) getHandleResponse(resp *http.Response) (Sign // GetEntityTag - Gets the entity state (Etag) version of the SignInSettings. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - SignInSettingsClientGetEntityTagOptions contains the optional parameters for the SignInSettingsClient.GetEntityTag @@ -212,7 +209,7 @@ func (client *SignInSettingsClient) GetEntityTag(ctx context.Context, resourceGr } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *SignInSettingsClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *SignInSettingsClientGetEntityTagOptions) (*policy.Request, error) { +func (client *SignInSettingsClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *SignInSettingsClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -231,7 +228,7 @@ func (client *SignInSettingsClient) getEntityTagCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -249,7 +246,7 @@ func (client *SignInSettingsClient) getEntityTagHandleResponse(resp *http.Respon // Update - Update Sign-In settings. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or @@ -278,7 +275,7 @@ func (client *SignInSettingsClient) Update(ctx context.Context, resourceGroupNam } // updateCreateRequest creates the Update request. -func (client *SignInSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalSigninSettings, options *SignInSettingsClientUpdateOptions) (*policy.Request, error) { +func (client *SignInSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalSigninSettings, _ *SignInSettingsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -297,10 +294,10 @@ func (client *SignInSettingsClient) updateCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/signinsettings_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/signinsettings_client_example_test.go deleted file mode 100644 index 8d0062bab6f7..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/signinsettings_client_example_test.go +++ /dev/null @@ -1,117 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadSignInSettings.json -func ExampleSignInSettingsClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSignInSettingsClient().GetEntityTag(ctx, "rg1", "apimService1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsGetSignIn.json -func ExampleSignInSettingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSignInSettingsClient().Get(ctx, "rg1", "apimService1", 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.PortalSigninSettings = armapimanagement.PortalSigninSettings{ - // Name: to.Ptr("signin"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalsettings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalsettings/signin"), - // Properties: &armapimanagement.PortalSigninSettingProperties{ - // Enabled: to.Ptr(true), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsUpdateSignIn.json -func ExampleSignInSettingsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSignInSettingsClient().Update(ctx, "rg1", "apimService1", "*", armapimanagement.PortalSigninSettings{ - Properties: &armapimanagement.PortalSigninSettingProperties{ - Enabled: to.Ptr(true), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsPutSignIn.json -func ExampleSignInSettingsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSignInSettingsClient().CreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.PortalSigninSettings{ - Properties: &armapimanagement.PortalSigninSettingProperties{ - Enabled: to.Ptr(true), - }, - }, &armapimanagement.SignInSettingsClientCreateOrUpdateOptions{IfMatch: to.Ptr("*")}) - 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.PortalSigninSettings = armapimanagement.PortalSigninSettings{ - // Name: to.Ptr("signin"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalsettings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalsettings/signin"), - // Properties: &armapimanagement.PortalSigninSettingProperties{ - // Enabled: to.Ptr(true), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/signupsettings_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/signupsettings_client.go index c46d692629a5..92bc58c86661 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/signupsettings_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/signupsettings_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type SignUpSettingsClient struct { } // NewSignUpSettingsClient creates a new instance of SignUpSettingsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewSignUpSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SignUpSettingsClient, error) { @@ -46,7 +43,7 @@ func NewSignUpSettingsClient(subscriptionID string, credential azcore.TokenCrede // CreateOrUpdate - Create or Update Sign-Up settings. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - parameters - Create or update parameters. @@ -94,12 +91,12 @@ func (client *SignUpSettingsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -118,7 +115,7 @@ func (client *SignUpSettingsClient) createOrUpdateHandleResponse(resp *http.Resp // Get - Get Sign Up Settings for the Portal // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - SignUpSettingsClientGetOptions contains the optional parameters for the SignUpSettingsClient.Get method. @@ -145,7 +142,7 @@ func (client *SignUpSettingsClient) Get(ctx context.Context, resourceGroupName s } // getCreateRequest creates the Get request. -func (client *SignUpSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *SignUpSettingsClientGetOptions) (*policy.Request, error) { +func (client *SignUpSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *SignUpSettingsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -164,7 +161,7 @@ func (client *SignUpSettingsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -184,7 +181,7 @@ func (client *SignUpSettingsClient) getHandleResponse(resp *http.Response) (Sign // GetEntityTag - Gets the entity state (Etag) version of the SignUpSettings. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - SignUpSettingsClientGetEntityTagOptions contains the optional parameters for the SignUpSettingsClient.GetEntityTag @@ -212,7 +209,7 @@ func (client *SignUpSettingsClient) GetEntityTag(ctx context.Context, resourceGr } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *SignUpSettingsClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *SignUpSettingsClientGetEntityTagOptions) (*policy.Request, error) { +func (client *SignUpSettingsClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *SignUpSettingsClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -231,7 +228,7 @@ func (client *SignUpSettingsClient) getEntityTagCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -249,7 +246,7 @@ func (client *SignUpSettingsClient) getEntityTagHandleResponse(resp *http.Respon // Update - Update Sign-Up settings. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or @@ -278,7 +275,7 @@ func (client *SignUpSettingsClient) Update(ctx context.Context, resourceGroupNam } // updateCreateRequest creates the Update request. -func (client *SignUpSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalSignupSettings, options *SignUpSettingsClientUpdateOptions) (*policy.Request, error) { +func (client *SignUpSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalSignupSettings, _ *SignUpSettingsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -297,10 +294,10 @@ func (client *SignUpSettingsClient) updateCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/signupsettings_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/signupsettings_client_example_test.go deleted file mode 100644 index a3897bf8f0cb..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/signupsettings_client_example_test.go +++ /dev/null @@ -1,137 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadSignUpSettings.json -func ExampleSignUpSettingsClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSignUpSettingsClient().GetEntityTag(ctx, "rg1", "apimService1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsGetSignUp.json -func ExampleSignUpSettingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSignUpSettingsClient().Get(ctx, "rg1", "apimService1", 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.PortalSignupSettings = armapimanagement.PortalSignupSettings{ - // Name: to.Ptr("signup"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalsettings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalsettings/signup"), - // Properties: &armapimanagement.PortalSignupSettingsProperties{ - // Enabled: to.Ptr(true), - // TermsOfService: &armapimanagement.TermsOfServiceProperties{ - // ConsentRequired: to.Ptr(true), - // Enabled: to.Ptr(true), - // Text: to.Ptr("Terms of service text."), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsUpdateSignUp.json -func ExampleSignUpSettingsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSignUpSettingsClient().Update(ctx, "rg1", "apimService1", "*", armapimanagement.PortalSignupSettings{ - Properties: &armapimanagement.PortalSignupSettingsProperties{ - Enabled: to.Ptr(true), - TermsOfService: &armapimanagement.TermsOfServiceProperties{ - ConsentRequired: to.Ptr(true), - Enabled: to.Ptr(true), - Text: to.Ptr("Terms of service text."), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementPortalSettingsPutSignUp.json -func ExampleSignUpSettingsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSignUpSettingsClient().CreateOrUpdate(ctx, "rg1", "apimService1", armapimanagement.PortalSignupSettings{ - Properties: &armapimanagement.PortalSignupSettingsProperties{ - Enabled: to.Ptr(true), - TermsOfService: &armapimanagement.TermsOfServiceProperties{ - ConsentRequired: to.Ptr(true), - Enabled: to.Ptr(true), - Text: to.Ptr("Terms of service text."), - }, - }, - }, &armapimanagement.SignUpSettingsClientCreateOrUpdateOptions{IfMatch: to.Ptr("*")}) - 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.PortalSignupSettings = armapimanagement.PortalSignupSettings{ - // Name: to.Ptr("signup"), - // Type: to.Ptr("Microsoft.ApiManagement/service/portalsettings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/portalsettings/signup"), - // Properties: &armapimanagement.PortalSignupSettingsProperties{ - // Enabled: to.Ptr(true), - // TermsOfService: &armapimanagement.TermsOfServiceProperties{ - // ConsentRequired: to.Ptr(true), - // Enabled: to.Ptr(true), - // Text: to.Ptr("Terms of service text."), - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/skus_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/skus_client.go index 6142afe098f4..c7671b4aeb06 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/skus_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/skus_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type SKUsClient struct { } // NewSKUsClient creates a new instance of SKUsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, error) { @@ -45,7 +42,7 @@ func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, opt // NewListPager - Gets the list of Microsoft.ApiManagement SKUs available for your Subscription. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - options - SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime.Pager[SKUsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SKUsClientListResponse]{ @@ -71,7 +68,7 @@ func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime. } // listCreateRequest creates the List request. -func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsClientListOptions) (*policy.Request, error) { +func (client *SKUsClient) listCreateRequest(ctx context.Context, _ *SKUsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -82,7 +79,7 @@ func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsCl return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/skus_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/skus_client_example_test.go deleted file mode 100644 index 3e3de48abc9f..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/skus_client_example_test.go +++ /dev/null @@ -1,266 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSku.json -func ExampleSKUsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSKUsClient().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.SKUsResult = armapimanagement.SKUsResult{ - // Value: []*armapimanagement.SKU{ - // { - // Name: to.Ptr("Developer"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](1), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeNone), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("centralindia"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("centralindia")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }, - // { - // Name: to.Ptr("Standard"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](4), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeAutomatic), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("centralindia"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("centralindia")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }, - // { - // Name: to.Ptr("Premium"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](10), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeAutomatic), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("centralindia"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("centralindia")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }, - // { - // Name: to.Ptr("Basic"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](2), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeManual), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("centralindia"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("centralindia")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }, - // { - // Name: to.Ptr("Consumption"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](0), - // Maximum: to.Ptr[int32](0), - // Minimum: to.Ptr[int32](0), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeNone), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("centralindia"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("centralindia")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }, - // { - // Name: to.Ptr("Developer"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](1), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeNone), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("uaenorth"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("uaenorth")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }, - // { - // Name: to.Ptr("Standard"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](4), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeAutomatic), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("uaenorth"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("uaenorth")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }, - // { - // Name: to.Ptr("Premium"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](10), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeAutomatic), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("uaenorth"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("uaenorth")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }, - // { - // Name: to.Ptr("Basic"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](2), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeManual), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("uaenorth"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("uaenorth")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }, - // { - // Name: to.Ptr("Developer"), - // Capacity: &armapimanagement.SKUCapacity{ - // Default: to.Ptr[int32](1), - // Maximum: to.Ptr[int32](1), - // Minimum: to.Ptr[int32](1), - // ScaleType: to.Ptr(armapimanagement.APIManagementSKUCapacityScaleTypeNone), - // }, - // LocationInfo: []*armapimanagement.SKULocationInfo{ - // { - // Location: to.Ptr("australiacentral"), - // ZoneDetails: []*armapimanagement.SKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("australiacentral")}, - // ResourceType: to.Ptr("service"), - // Restrictions: []*armapimanagement.SKURestrictions{ - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/subscription_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/subscription_client.go index 49da9b9552b9..f2a998294f0f 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/subscription_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/subscription_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type SubscriptionClient struct { } // NewSubscriptionClient creates a new instance of SubscriptionClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewSubscriptionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SubscriptionClient, error) { @@ -47,7 +44,7 @@ func NewSubscriptionClient(subscriptionID string, credential azcore.TokenCredent // CreateOrUpdate - Creates or updates the subscription of specified user to the specified product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. @@ -100,18 +97,18 @@ func (client *SubscriptionClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.Notify != nil { - reqQP.Set("notify", strconv.FormatBool(*options.Notify)) - } - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") if options != nil && options.AppType != nil { reqQP.Set("appType", string(*options.AppType)) } + if options != nil && options.Notify != nil { + reqQP.Set("notify", strconv.FormatBool(*options.Notify)) + } req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -133,7 +130,7 @@ func (client *SubscriptionClient) createOrUpdateHandleResponse(resp *http.Respon // Delete - Deletes the specified subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. @@ -162,7 +159,7 @@ func (client *SubscriptionClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *SubscriptionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string, options *SubscriptionClientDeleteOptions) (*policy.Request, error) { +func (client *SubscriptionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string, _ *SubscriptionClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -185,17 +182,17 @@ func (client *SubscriptionClient) deleteCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // Get - Gets the specified Subscription entity. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. @@ -223,7 +220,7 @@ func (client *SubscriptionClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *SubscriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionClientGetOptions) (*policy.Request, error) { +func (client *SubscriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, _ *SubscriptionClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -246,7 +243,7 @@ func (client *SubscriptionClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -266,7 +263,7 @@ func (client *SubscriptionClient) getHandleResponse(resp *http.Response) (Subscr // GetEntityTag - Gets the entity state (Etag) version of the apimanagement subscription specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. @@ -295,7 +292,7 @@ func (client *SubscriptionClient) GetEntityTag(ctx context.Context, resourceGrou } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *SubscriptionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionClientGetEntityTagOptions) (*policy.Request, error) { +func (client *SubscriptionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, _ *SubscriptionClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -318,7 +315,7 @@ func (client *SubscriptionClient) getEntityTagCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -335,7 +332,7 @@ func (client *SubscriptionClient) getEntityTagHandleResponse(resp *http.Response // NewListPager - Lists all subscriptions of the API Management service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - SubscriptionClientListOptions contains the optional parameters for the SubscriptionClient.NewListPager method. @@ -385,13 +382,13 @@ func (client *SubscriptionClient) listCreateRequest(ctx context.Context, resourc if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -409,7 +406,7 @@ func (client *SubscriptionClient) listHandleResponse(resp *http.Response) (Subsc // ListSecrets - Gets the specified Subscription keys. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. @@ -438,7 +435,7 @@ func (client *SubscriptionClient) ListSecrets(ctx context.Context, resourceGroup } // listSecretsCreateRequest creates the ListSecrets request. -func (client *SubscriptionClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionClientListSecretsOptions) (*policy.Request, error) { +func (client *SubscriptionClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, _ *SubscriptionClientListSecretsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -461,7 +458,7 @@ func (client *SubscriptionClient) listSecretsCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -482,7 +479,7 @@ func (client *SubscriptionClient) listSecretsHandleResponse(resp *http.Response) // RegeneratePrimaryKey - Regenerates primary key of existing subscription of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. @@ -510,7 +507,7 @@ func (client *SubscriptionClient) RegeneratePrimaryKey(ctx context.Context, reso } // regeneratePrimaryKeyCreateRequest creates the RegeneratePrimaryKey request. -func (client *SubscriptionClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionClientRegeneratePrimaryKeyOptions) (*policy.Request, error) { +func (client *SubscriptionClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, _ *SubscriptionClientRegeneratePrimaryKeyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -533,7 +530,7 @@ func (client *SubscriptionClient) regeneratePrimaryKeyCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -542,7 +539,7 @@ func (client *SubscriptionClient) regeneratePrimaryKeyCreateRequest(ctx context. // RegenerateSecondaryKey - Regenerates secondary key of existing subscription of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. @@ -570,7 +567,7 @@ func (client *SubscriptionClient) RegenerateSecondaryKey(ctx context.Context, re } // regenerateSecondaryKeyCreateRequest creates the RegenerateSecondaryKey request. -func (client *SubscriptionClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionClientRegenerateSecondaryKeyOptions) (*policy.Request, error) { +func (client *SubscriptionClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, _ *SubscriptionClientRegenerateSecondaryKeyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -593,7 +590,7 @@ func (client *SubscriptionClient) regenerateSecondaryKeyCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -602,7 +599,7 @@ func (client *SubscriptionClient) regenerateSecondaryKeyCreateRequest(ctx contex // Update - Updates the details of a subscription specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. @@ -656,16 +653,16 @@ func (client *SubscriptionClient) updateCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.Notify != nil { - reqQP.Set("notify", strconv.FormatBool(*options.Notify)) - } - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") if options != nil && options.AppType != nil { reqQP.Set("appType", string(*options.AppType)) } + if options != nil && options.Notify != nil { + reqQP.Set("notify", strconv.FormatBool(*options.Notify)) + } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/subscription_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/subscription_client_example_test.go deleted file mode 100644 index 2697f6bc1fde..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/subscription_client_example_test.go +++ /dev/null @@ -1,292 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSubscriptions.json -func ExampleSubscriptionClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSubscriptionClient().NewListPager("rg1", "apimService1", &armapimanagement.SubscriptionClientListOptions{Filter: nil, - Top: nil, - Skip: 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.SubscriptionCollection = armapimanagement.SubscriptionCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.SubscriptionContract{ - // { - // Name: to.Ptr("5600b59475ff190048070001"), - // Type: to.Ptr("Microsoft.ApiManagement/service/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/subscriptions/5600b59475ff190048070001"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2015-09-22T01:57:40.300Z"); return t}()), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060001"), - // State: to.Ptr(armapimanagement.SubscriptionStateActive), - // }, - // }, - // { - // Name: to.Ptr("56eaed3dbaf08b06e46d27fe"), - // Type: to.Ptr("Microsoft.ApiManagement/service/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/subscriptions/56eaed3dbaf08b06e46d27fe"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-17T17:45:33.837Z"); return t}()), - // DisplayName: to.Ptr("Starter"), - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-04-01T00:00:00.000Z"); return t}()), - // NotificationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-20T00:00:00.000Z"); return t}()), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/56eaec62baf08b06e46d27fd"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060001"), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-17T00:00:00.000Z"); return t}()), - // State: to.Ptr(armapimanagement.SubscriptionStateActive), - // }, - // }, - // { - // Name: to.Ptr("5931a769d8d14f0ad8ce13b8"), - // Type: to.Ptr("Microsoft.ApiManagement/service/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/subscriptions/5931a769d8d14f0ad8ce13b8"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-02T17:59:06.223Z"); return t}()), - // DisplayName: to.Ptr("Unlimited"), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512a88c680b"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002"), - // State: to.Ptr(armapimanagement.SubscriptionStateSubmitted), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadSubscription.json -func ExampleSubscriptionClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSubscriptionClient().GetEntityTag(ctx, "rg1", "apimService1", "5931a769d8d14f0ad8ce13b8", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetSubscription.json -func ExampleSubscriptionClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionClient().Get(ctx, "rg1", "apimService1", "5931a769d8d14f0ad8ce13b8", 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.SubscriptionContract = armapimanagement.SubscriptionContract{ - // Name: to.Ptr("5931a769d8d14f0ad8ce13b8"), - // Type: to.Ptr("Microsoft.ApiManagement/service/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/subscriptions/5931a769d8d14f0ad8ce13b8"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-02T17:59:06.223Z"); return t}()), - // DisplayName: to.Ptr("Unlimited"), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512a88c680b"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002"), - // State: to.Ptr(armapimanagement.SubscriptionStateSubmitted), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateSubscription.json -func ExampleSubscriptionClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionClient().CreateOrUpdate(ctx, "rg1", "apimService1", "testsub", armapimanagement.SubscriptionCreateParameters{ - Properties: &armapimanagement.SubscriptionCreateParameterProperties{ - DisplayName: to.Ptr("testsub"), - OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7"), - Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002"), - }, - }, &armapimanagement.SubscriptionClientCreateOrUpdateOptions{Notify: nil, - IfMatch: nil, - AppType: 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.SubscriptionContract = armapimanagement.SubscriptionContract{ - // Name: to.Ptr("testsub"), - // Type: to.Ptr("Microsoft.ApiManagement/service/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/subscriptions/testsub"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-02T23:34:03.105Z"); return t}()), - // DisplayName: to.Ptr("testsub"), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002"), - // State: to.Ptr(armapimanagement.SubscriptionStateSubmitted), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateSubscription.json -func ExampleSubscriptionClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionClient().Update(ctx, "rg1", "apimService1", "testsub", "*", armapimanagement.SubscriptionUpdateParameters{ - Properties: &armapimanagement.SubscriptionUpdateParameterProperties{ - DisplayName: to.Ptr("testsub"), - }, - }, &armapimanagement.SubscriptionClientUpdateOptions{Notify: nil, - AppType: 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.SubscriptionContract = armapimanagement.SubscriptionContract{ - // Name: to.Ptr("testsub"), - // Type: to.Ptr("Microsoft.ApiManagement/service/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/subscriptions/testsub"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-02T17:59:06.223Z"); return t}()), - // DisplayName: to.Ptr("testsub"), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512a88c680b"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002"), - // State: to.Ptr(armapimanagement.SubscriptionStateSubmitted), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteSubscription.json -func ExampleSubscriptionClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSubscriptionClient().Delete(ctx, "rg1", "apimService1", "testsub", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementSubscriptionRegeneratePrimaryKey.json -func ExampleSubscriptionClient_RegeneratePrimaryKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSubscriptionClient().RegeneratePrimaryKey(ctx, "rg1", "apimService1", "testsub", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementSubscriptionRegenerateSecondaryKey.json -func ExampleSubscriptionClient_RegenerateSecondaryKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSubscriptionClient().RegenerateSecondaryKey(ctx, "rg1", "apimService1", "testsub", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementSubscriptionListSecrets.json -func ExampleSubscriptionClient_ListSecrets() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionClient().ListSecrets(ctx, "rg1", "apimService1", "5931a769d8d14f0ad8ce13b8", 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.SubscriptionKeysContract = armapimanagement.SubscriptionKeysContract{ - // PrimaryKey: to.Ptr(""), - // SecondaryKey: to.Ptr(""), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tag_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/tag_client.go index 8f0a9f6b3478..8e676c91190b 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tag_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/tag_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type TagClient struct { } // NewTagClient creates a new instance of TagClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewTagClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagClient, error) { @@ -47,7 +44,7 @@ func NewTagClient(subscriptionID string, credential azcore.TokenCredential, opti // AssignToAPI - Assign tag to the Api. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -77,7 +74,7 @@ func (client *TagClient) AssignToAPI(ctx context.Context, resourceGroupName stri } // assignToAPICreateRequest creates the AssignToAPI request. -func (client *TagClient) assignToAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagClientAssignToAPIOptions) (*policy.Request, error) { +func (client *TagClient) assignToAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, _ *TagClientAssignToAPIOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -104,7 +101,7 @@ func (client *TagClient) assignToAPICreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -125,7 +122,7 @@ func (client *TagClient) assignToAPIHandleResponse(resp *http.Response) (TagClie // AssignToOperation - Assign tag to the Operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -156,7 +153,7 @@ func (client *TagClient) AssignToOperation(ctx context.Context, resourceGroupNam } // assignToOperationCreateRequest creates the AssignToOperation request. -func (client *TagClient) assignToOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagClientAssignToOperationOptions) (*policy.Request, error) { +func (client *TagClient) assignToOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, _ *TagClientAssignToOperationOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -187,7 +184,7 @@ func (client *TagClient) assignToOperationCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -205,7 +202,7 @@ func (client *TagClient) assignToOperationHandleResponse(resp *http.Response) (T // AssignToProduct - Assign tag to the Product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -234,7 +231,7 @@ func (client *TagClient) AssignToProduct(ctx context.Context, resourceGroupName } // assignToProductCreateRequest creates the AssignToProduct request. -func (client *TagClient) assignToProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagClientAssignToProductOptions) (*policy.Request, error) { +func (client *TagClient) assignToProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, _ *TagClientAssignToProductOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -261,7 +258,7 @@ func (client *TagClient) assignToProductCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -279,7 +276,7 @@ func (client *TagClient) assignToProductHandleResponse(resp *http.Response) (Tag // CreateOrUpdate - Creates a tag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - tagID - Tag identifier. Must be unique in the current API Management service instance. @@ -331,12 +328,12 @@ func (client *TagClient) createOrUpdateCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -358,7 +355,7 @@ func (client *TagClient) createOrUpdateHandleResponse(resp *http.Response) (TagC // Delete - Deletes specific tag of the API Management service instance. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - tagID - Tag identifier. Must be unique in the current API Management service instance. @@ -387,7 +384,7 @@ func (client *TagClient) Delete(ctx context.Context, resourceGroupName string, s } // deleteCreateRequest creates the Delete request. -func (client *TagClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string, options *TagClientDeleteOptions) (*policy.Request, error) { +func (client *TagClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string, _ *TagClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -410,17 +407,17 @@ func (client *TagClient) deleteCreateRequest(ctx context.Context, resourceGroupN return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // DetachFromAPI - Detach the tag from the Api. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -449,7 +446,7 @@ func (client *TagClient) DetachFromAPI(ctx context.Context, resourceGroupName st } // detachFromAPICreateRequest creates the DetachFromAPI request. -func (client *TagClient) detachFromAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagClientDetachFromAPIOptions) (*policy.Request, error) { +func (client *TagClient) detachFromAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, _ *TagClientDetachFromAPIOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -476,7 +473,7 @@ func (client *TagClient) detachFromAPICreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -485,7 +482,7 @@ func (client *TagClient) detachFromAPICreateRequest(ctx context.Context, resourc // DetachFromOperation - Detach the tag from the Operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -515,7 +512,7 @@ func (client *TagClient) DetachFromOperation(ctx context.Context, resourceGroupN } // detachFromOperationCreateRequest creates the DetachFromOperation request. -func (client *TagClient) detachFromOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagClientDetachFromOperationOptions) (*policy.Request, error) { +func (client *TagClient) detachFromOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, _ *TagClientDetachFromOperationOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -546,7 +543,7 @@ func (client *TagClient) detachFromOperationCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -555,7 +552,7 @@ func (client *TagClient) detachFromOperationCreateRequest(ctx context.Context, r // DetachFromProduct - Detach the tag from the Product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -583,7 +580,7 @@ func (client *TagClient) DetachFromProduct(ctx context.Context, resourceGroupNam } // detachFromProductCreateRequest creates the DetachFromProduct request. -func (client *TagClient) detachFromProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagClientDetachFromProductOptions) (*policy.Request, error) { +func (client *TagClient) detachFromProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, _ *TagClientDetachFromProductOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -610,7 +607,7 @@ func (client *TagClient) detachFromProductCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -619,7 +616,7 @@ func (client *TagClient) detachFromProductCreateRequest(ctx context.Context, res // Get - Gets the details of the tag specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - tagID - Tag identifier. Must be unique in the current API Management service instance. @@ -647,7 +644,7 @@ func (client *TagClient) Get(ctx context.Context, resourceGroupName string, serv } // getCreateRequest creates the Get request. -func (client *TagClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, options *TagClientGetOptions) (*policy.Request, error) { +func (client *TagClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, _ *TagClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -670,7 +667,7 @@ func (client *TagClient) getCreateRequest(ctx context.Context, resourceGroupName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -691,7 +688,7 @@ func (client *TagClient) getHandleResponse(resp *http.Response) (TagClientGetRes // GetByAPI - Get tag associated with the API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -721,7 +718,7 @@ func (client *TagClient) GetByAPI(ctx context.Context, resourceGroupName string, } // getByAPICreateRequest creates the GetByAPI request. -func (client *TagClient) getByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagClientGetByAPIOptions) (*policy.Request, error) { +func (client *TagClient) getByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, _ *TagClientGetByAPIOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -748,7 +745,7 @@ func (client *TagClient) getByAPICreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -769,7 +766,7 @@ func (client *TagClient) getByAPIHandleResponse(resp *http.Response) (TagClientG // GetByOperation - Get tag associated with the Operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -800,7 +797,7 @@ func (client *TagClient) GetByOperation(ctx context.Context, resourceGroupName s } // getByOperationCreateRequest creates the GetByOperation request. -func (client *TagClient) getByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagClientGetByOperationOptions) (*policy.Request, error) { +func (client *TagClient) getByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, _ *TagClientGetByOperationOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -831,7 +828,7 @@ func (client *TagClient) getByOperationCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -852,7 +849,7 @@ func (client *TagClient) getByOperationHandleResponse(resp *http.Response) (TagC // GetByProduct - Get tag associated with the Product. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -881,7 +878,7 @@ func (client *TagClient) GetByProduct(ctx context.Context, resourceGroupName str } // getByProductCreateRequest creates the GetByProduct request. -func (client *TagClient) getByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagClientGetByProductOptions) (*policy.Request, error) { +func (client *TagClient) getByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, _ *TagClientGetByProductOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -908,7 +905,7 @@ func (client *TagClient) getByProductCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -928,7 +925,7 @@ func (client *TagClient) getByProductHandleResponse(resp *http.Response) (TagCli // GetEntityState - Gets the entity state version of the tag specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - tagID - Tag identifier. Must be unique in the current API Management service instance. @@ -956,7 +953,7 @@ func (client *TagClient) GetEntityState(ctx context.Context, resourceGroupName s } // getEntityStateCreateRequest creates the GetEntityState request. -func (client *TagClient) getEntityStateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, options *TagClientGetEntityStateOptions) (*policy.Request, error) { +func (client *TagClient) getEntityStateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, _ *TagClientGetEntityStateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -979,7 +976,7 @@ func (client *TagClient) getEntityStateCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -996,7 +993,7 @@ func (client *TagClient) getEntityStateHandleResponse(resp *http.Response) (TagC // GetEntityStateByAPI - Gets the entity state version of the tag specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -1026,7 +1023,7 @@ func (client *TagClient) GetEntityStateByAPI(ctx context.Context, resourceGroupN } // getEntityStateByAPICreateRequest creates the GetEntityStateByAPI request. -func (client *TagClient) getEntityStateByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagClientGetEntityStateByAPIOptions) (*policy.Request, error) { +func (client *TagClient) getEntityStateByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, _ *TagClientGetEntityStateByAPIOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -1053,7 +1050,7 @@ func (client *TagClient) getEntityStateByAPICreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1070,7 +1067,7 @@ func (client *TagClient) getEntityStateByAPIHandleResponse(resp *http.Response) // GetEntityStateByOperation - Gets the entity state version of the tag specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -1102,7 +1099,7 @@ func (client *TagClient) GetEntityStateByOperation(ctx context.Context, resource } // getEntityStateByOperationCreateRequest creates the GetEntityStateByOperation request. -func (client *TagClient) getEntityStateByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagClientGetEntityStateByOperationOptions) (*policy.Request, error) { +func (client *TagClient) getEntityStateByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, _ *TagClientGetEntityStateByOperationOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -1133,7 +1130,7 @@ func (client *TagClient) getEntityStateByOperationCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1150,7 +1147,7 @@ func (client *TagClient) getEntityStateByOperationHandleResponse(resp *http.Resp // GetEntityStateByProduct - Gets the entity state version of the tag specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -1180,7 +1177,7 @@ func (client *TagClient) GetEntityStateByProduct(ctx context.Context, resourceGr } // getEntityStateByProductCreateRequest creates the GetEntityStateByProduct request. -func (client *TagClient) getEntityStateByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagClientGetEntityStateByProductOptions) (*policy.Request, error) { +func (client *TagClient) getEntityStateByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, _ *TagClientGetEntityStateByProductOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -1207,7 +1204,7 @@ func (client *TagClient) getEntityStateByProductCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1224,7 +1221,7 @@ func (client *TagClient) getEntityStateByProductHandleResponse(resp *http.Respon // NewListByAPIPager - Lists all Tags associated with the API. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -1280,13 +1277,13 @@ func (client *TagClient) listByAPICreateRequest(ctx context.Context, resourceGro if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1303,7 +1300,7 @@ func (client *TagClient) listByAPIHandleResponse(resp *http.Response) (TagClient // NewListByOperationPager - Lists all Tags associated with the Operation. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has @@ -1364,13 +1361,13 @@ func (client *TagClient) listByOperationCreateRequest(ctx context.Context, resou if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1387,7 +1384,7 @@ func (client *TagClient) listByOperationHandleResponse(resp *http.Response) (Tag // NewListByProductPager - Lists all Tags associated with the Product. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - productID - Product identifier. Must be unique in the current API Management service instance. @@ -1442,13 +1439,13 @@ func (client *TagClient) listByProductCreateRequest(ctx context.Context, resourc if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1465,7 +1462,7 @@ func (client *TagClient) listByProductHandleResponse(resp *http.Response) (TagCl // NewListByServicePager - Lists a collection of tags defined within a service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - TagClientListByServiceOptions contains the optional parameters for the TagClient.NewListByServicePager method. @@ -1515,16 +1512,16 @@ func (client *TagClient) listByServiceCreateRequest(ctx context.Context, resourc if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Scope != nil { reqQP.Set("scope", *options.Scope) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1542,7 +1539,7 @@ func (client *TagClient) listByServiceHandleResponse(resp *http.Response) (TagCl // Update - Updates the details of the tag specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - tagID - Tag identifier. Must be unique in the current API Management service instance. @@ -1573,7 +1570,7 @@ func (client *TagClient) Update(ctx context.Context, resourceGroupName string, s } // updateCreateRequest creates the Update request. -func (client *TagClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string, parameters TagCreateUpdateParameters, options *TagClientUpdateOptions) (*policy.Request, error) { +func (client *TagClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string, parameters TagCreateUpdateParameters, _ *TagClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -1596,10 +1593,10 @@ func (client *TagClient) updateCreateRequest(ctx context.Context, resourceGroupN return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tag_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/tag_client_example_test.go deleted file mode 100644 index 5fc2354e6a57..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tag_client_example_test.go +++ /dev/null @@ -1,584 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiOperationTags.json -func ExampleTagClient_NewListByOperationPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTagClient().NewListByOperationPager("rg1", "apimService1", "57d2ef278aa04f0888cba3f3", "57d2ef278aa04f0888cba3f6", &armapimanagement.TagClientListByOperationOptions{Filter: nil, - Top: nil, - Skip: 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.TagCollection = armapimanagement.TagCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.TagContract{ - // { - // Name: to.Ptr("5600b539c53f5b0062060002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/5600b539c53f5b0062060002"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiOperationTag.json -func ExampleTagClient_GetEntityStateByOperation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTagClient().GetEntityStateByOperation(ctx, "rg1", "apimService1", "59d6bb8f1f7fab13dc67ec9b", "59d6bb8f1f7fab13dc67ec9a", "59306a29e4bbd510dc24e5f9", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiOperationTag.json -func ExampleTagClient_GetByOperation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagClient().GetByOperation(ctx, "rg1", "apimService1", "59d6bb8f1f7fab13dc67ec9b", "59d6bb8f1f7fab13dc67ec9a", "59306a29e4bbd510dc24e5f9", 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.TagContract = armapimanagement.TagContract{ - // Name: to.Ptr("59306a29e4bbd510dc24e5f9"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/59306a29e4bbd510dc24e5f9"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiOperationTag.json -func ExampleTagClient_AssignToOperation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagClient().AssignToOperation(ctx, "rg1", "apimService1", "5931a75ae4bbd512a88c680b", "5931a75ae4bbd512a88c680a", "tagId1", 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.TagContract = armapimanagement.TagContract{ - // Name: to.Ptr("tagId1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/tagId1"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiOperationTag.json -func ExampleTagClient_DetachFromOperation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTagClient().DetachFromOperation(ctx, "rg1", "apimService1", "59d5b28d1f7fab116c282650", "59d5b28d1f7fab116c282651", "59d5b28e1f7fab116402044e", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListApiTags.json -func ExampleTagClient_NewListByAPIPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTagClient().NewListByAPIPager("rg1", "apimService1", "57d2ef278aa04f0888cba3f3", &armapimanagement.TagClientListByAPIOptions{Filter: nil, - Top: nil, - Skip: 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.TagCollection = armapimanagement.TagCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.TagContract{ - // { - // Name: to.Ptr("5600b539c53f5b0062060002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/5600b539c53f5b0062060002"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadApiTag.json -func ExampleTagClient_GetEntityStateByAPI() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTagClient().GetEntityStateByAPI(ctx, "rg1", "apimService1", "59d6bb8f1f7fab13dc67ec9b", "59306a29e4bbd510dc24e5f9", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetApiTag.json -func ExampleTagClient_GetByAPI() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagClient().GetByAPI(ctx, "rg1", "apimService1", "59d6bb8f1f7fab13dc67ec9b", "59306a29e4bbd510dc24e5f9", 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.TagContract = armapimanagement.TagContract{ - // Name: to.Ptr("59306a29e4bbd510dc24e5f9"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/59306a29e4bbd510dc24e5f9"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateApiTag.json -func ExampleTagClient_AssignToAPI() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagClient().AssignToAPI(ctx, "rg1", "apimService1", "5931a75ae4bbd512a88c680b", "tagId1", 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.TagContract = armapimanagement.TagContract{ - // Name: to.Ptr("tagId1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/tagId1"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteApiTag.json -func ExampleTagClient_DetachFromAPI() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTagClient().DetachFromAPI(ctx, "rg1", "apimService1", "59d5b28d1f7fab116c282650", "59d5b28e1f7fab116402044e", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListProductTags.json -func ExampleTagClient_NewListByProductPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTagClient().NewListByProductPager("rg1", "apimService1", "57d2ef278aa04f0888cba3f1", &armapimanagement.TagClientListByProductOptions{Filter: nil, - Top: nil, - Skip: 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.TagCollection = armapimanagement.TagCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.TagContract{ - // { - // Name: to.Ptr("5600b539c53f5b0062060002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/5600b539c53f5b0062060002"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadProductTag.json -func ExampleTagClient_GetEntityStateByProduct() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTagClient().GetEntityStateByProduct(ctx, "rg1", "apimService1", "59306a29e4bbd510dc24e5f8", "59306a29e4bbd510dc24e5f9", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetProductTag.json -func ExampleTagClient_GetByProduct() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagClient().GetByProduct(ctx, "rg1", "apimService1", "59d6bb8f1f7fab13dc67ec9b", "59306a29e4bbd510dc24e5f9", 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.TagContract = armapimanagement.TagContract{ - // Name: to.Ptr("59306a29e4bbd510dc24e5f9"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/59306a29e4bbd510dc24e5f9"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateProductTag.json -func ExampleTagClient_AssignToProduct() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagClient().AssignToProduct(ctx, "rg1", "apimService1", "5931a75ae4bbd512a88c680b", "tagId1", 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.TagContract = armapimanagement.TagContract{ - // Name: to.Ptr("tagId1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/tagId1"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteProductTag.json -func ExampleTagClient_DetachFromProduct() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTagClient().DetachFromProduct(ctx, "rg1", "apimService1", "59d5b28d1f7fab116c282650", "59d5b28e1f7fab116402044e", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTags.json -func ExampleTagClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTagClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.TagClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: nil, - Scope: 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.TagCollection = armapimanagement.TagCollection{ - // Count: to.Ptr[int64](2), - // Value: []*armapimanagement.TagContract{ - // { - // Name: to.Ptr("5600b59375ff190048020001"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/5600b59375ff190048020001"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // }, - // { - // Name: to.Ptr("5600b59375ff190048020002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/5600b59375ff190048020002"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag2"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadTag.json -func ExampleTagClient_GetEntityState() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTagClient().GetEntityState(ctx, "rg1", "apimService1", "59306a29e4bbd510dc24e5f9", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTag.json -func ExampleTagClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagClient().Get(ctx, "rg1", "apimService1", "59306a29e4bbd510dc24e5f9", 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.TagContract = armapimanagement.TagContract{ - // Name: to.Ptr("59306a29e4bbd510dc24e5f9"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/59306a29e4bbd510dc24e5f9"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateTag.json -func ExampleTagClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagClient().CreateOrUpdate(ctx, "rg1", "apimService1", "tagId1", armapimanagement.TagCreateUpdateParameters{ - Properties: &armapimanagement.TagContractProperties{ - DisplayName: to.Ptr("tag1"), - }, - }, &armapimanagement.TagClientCreateOrUpdateOptions{IfMatch: 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.TagContract = armapimanagement.TagContract{ - // Name: to.Ptr("tagId1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/tagId1"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateTag.json -func ExampleTagClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagClient().Update(ctx, "rg1", "apimService1", "temptag", "*", armapimanagement.TagCreateUpdateParameters{ - Properties: &armapimanagement.TagContractProperties{ - DisplayName: to.Ptr("temp tag"), - }, - }, 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.TagContract = armapimanagement.TagContract{ - // Name: to.Ptr("temptag"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tags"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tags/temptag"), - // Properties: &armapimanagement.TagContractProperties{ - // DisplayName: to.Ptr("tag1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteTag.json -func ExampleTagClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTagClient().Delete(ctx, "rg1", "apimService1", "tagId1", "*", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tagapilink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/tagapilink_client.go new file mode 100644 index 000000000000..c5419161e60c --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/tagapilink_client.go @@ -0,0 +1,341 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// TagAPILinkClient contains the methods for the TagAPILink group. +// Don't use this type directly, use NewTagAPILinkClient() instead. +type TagAPILinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewTagAPILinkClient creates a new instance of TagAPILinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewTagAPILinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagAPILinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TagAPILinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds an API to the specified tag via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Tag-API link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - TagAPILinkClientCreateOrUpdateOptions contains the optional parameters for the TagAPILinkClient.CreateOrUpdate +// method. +func (client *TagAPILinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, tagID string, apiLinkID string, parameters TagAPILinkContract, options *TagAPILinkClientCreateOrUpdateOptions) (TagAPILinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "TagAPILinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, tagID, apiLinkID, parameters, options) + if err != nil { + return TagAPILinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TagAPILinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return TagAPILinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TagAPILinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, apiLinkID string, parameters TagAPILinkContract, _ *TagAPILinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks/{apiLinkId}" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *TagAPILinkClient) createOrUpdateHandleResponse(resp *http.Response) (TagAPILinkClientCreateOrUpdateResponse, error) { + result := TagAPILinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagAPILinkContract); err != nil { + return TagAPILinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified API from the specified tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Tag-API link identifier. Must be unique in the current API Management service instance. +// - options - TagAPILinkClientDeleteOptions contains the optional parameters for the TagAPILinkClient.Delete method. +func (client *TagAPILinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, tagID string, apiLinkID string, options *TagAPILinkClientDeleteOptions) (TagAPILinkClientDeleteResponse, error) { + var err error + const operationName = "TagAPILinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, tagID, apiLinkID, options) + if err != nil { + return TagAPILinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TagAPILinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TagAPILinkClientDeleteResponse{}, err + } + return TagAPILinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TagAPILinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, apiLinkID string, _ *TagAPILinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks/{apiLinkId}" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the API link for the tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Tag-API link identifier. Must be unique in the current API Management service instance. +// - options - TagAPILinkClientGetOptions contains the optional parameters for the TagAPILinkClient.Get method. +func (client *TagAPILinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, tagID string, apiLinkID string, options *TagAPILinkClientGetOptions) (TagAPILinkClientGetResponse, error) { + var err error + const operationName = "TagAPILinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, tagID, apiLinkID, options) + if err != nil { + return TagAPILinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TagAPILinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TagAPILinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *TagAPILinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, apiLinkID string, _ *TagAPILinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks/{apiLinkId}" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TagAPILinkClient) getHandleResponse(resp *http.Response) (TagAPILinkClientGetResponse, error) { + result := TagAPILinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.TagAPILinkContract); err != nil { + return TagAPILinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the API links associated with a tag. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - options - TagAPILinkClientListByProductOptions contains the optional parameters for the TagAPILinkClient.NewListByProductPager +// method. +func (client *TagAPILinkClient) NewListByProductPager(resourceGroupName string, serviceName string, tagID string, options *TagAPILinkClientListByProductOptions) *runtime.Pager[TagAPILinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[TagAPILinkClientListByProductResponse]{ + More: func(page TagAPILinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TagAPILinkClientListByProductResponse) (TagAPILinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TagAPILinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, tagID, options) + }, nil) + if err != nil { + return TagAPILinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *TagAPILinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, options *TagAPILinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *TagAPILinkClient) listByProductHandleResponse(resp *http.Response) (TagAPILinkClientListByProductResponse, error) { + result := TagAPILinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagAPILinkCollection); err != nil { + return TagAPILinkClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tagoperationlink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/tagoperationlink_client.go new file mode 100644 index 000000000000..9462be481f4a --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/tagoperationlink_client.go @@ -0,0 +1,341 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// TagOperationLinkClient contains the methods for the TagOperationLink group. +// Don't use this type directly, use NewTagOperationLinkClient() instead. +type TagOperationLinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewTagOperationLinkClient creates a new instance of TagOperationLinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewTagOperationLinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagOperationLinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TagOperationLinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds an operation to the specified tag via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - operationLinkID - Tag-operation link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - TagOperationLinkClientCreateOrUpdateOptions contains the optional parameters for the TagOperationLinkClient.CreateOrUpdate +// method. +func (client *TagOperationLinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, tagID string, operationLinkID string, parameters TagOperationLinkContract, options *TagOperationLinkClientCreateOrUpdateOptions) (TagOperationLinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "TagOperationLinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, tagID, operationLinkID, parameters, options) + if err != nil { + return TagOperationLinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TagOperationLinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return TagOperationLinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TagOperationLinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, operationLinkID string, parameters TagOperationLinkContract, _ *TagOperationLinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks/{operationLinkId}" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if operationLinkID == "" { + return nil, errors.New("parameter operationLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationLinkId}", url.PathEscape(operationLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *TagOperationLinkClient) createOrUpdateHandleResponse(resp *http.Response) (TagOperationLinkClientCreateOrUpdateResponse, error) { + result := TagOperationLinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagOperationLinkContract); err != nil { + return TagOperationLinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified operation from the specified tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - operationLinkID - Tag-operation link identifier. Must be unique in the current API Management service instance. +// - options - TagOperationLinkClientDeleteOptions contains the optional parameters for the TagOperationLinkClient.Delete method. +func (client *TagOperationLinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, tagID string, operationLinkID string, options *TagOperationLinkClientDeleteOptions) (TagOperationLinkClientDeleteResponse, error) { + var err error + const operationName = "TagOperationLinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, tagID, operationLinkID, options) + if err != nil { + return TagOperationLinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TagOperationLinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TagOperationLinkClientDeleteResponse{}, err + } + return TagOperationLinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TagOperationLinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, operationLinkID string, _ *TagOperationLinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks/{operationLinkId}" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if operationLinkID == "" { + return nil, errors.New("parameter operationLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationLinkId}", url.PathEscape(operationLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the operation link for the tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - operationLinkID - Tag-operation link identifier. Must be unique in the current API Management service instance. +// - options - TagOperationLinkClientGetOptions contains the optional parameters for the TagOperationLinkClient.Get method. +func (client *TagOperationLinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, tagID string, operationLinkID string, options *TagOperationLinkClientGetOptions) (TagOperationLinkClientGetResponse, error) { + var err error + const operationName = "TagOperationLinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, tagID, operationLinkID, options) + if err != nil { + return TagOperationLinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TagOperationLinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TagOperationLinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *TagOperationLinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, operationLinkID string, _ *TagOperationLinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks/{operationLinkId}" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if operationLinkID == "" { + return nil, errors.New("parameter operationLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationLinkId}", url.PathEscape(operationLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TagOperationLinkClient) getHandleResponse(resp *http.Response) (TagOperationLinkClientGetResponse, error) { + result := TagOperationLinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.TagOperationLinkContract); err != nil { + return TagOperationLinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the operation links associated with a tag. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - options - TagOperationLinkClientListByProductOptions contains the optional parameters for the TagOperationLinkClient.NewListByProductPager +// method. +func (client *TagOperationLinkClient) NewListByProductPager(resourceGroupName string, serviceName string, tagID string, options *TagOperationLinkClientListByProductOptions) *runtime.Pager[TagOperationLinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[TagOperationLinkClientListByProductResponse]{ + More: func(page TagOperationLinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TagOperationLinkClientListByProductResponse) (TagOperationLinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TagOperationLinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, tagID, options) + }, nil) + if err != nil { + return TagOperationLinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *TagOperationLinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, options *TagOperationLinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *TagOperationLinkClient) listByProductHandleResponse(resp *http.Response) (TagOperationLinkClientListByProductResponse, error) { + result := TagOperationLinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagOperationLinkCollection); err != nil { + return TagOperationLinkClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tagproductlink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/tagproductlink_client.go new file mode 100644 index 000000000000..460d18120265 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/tagproductlink_client.go @@ -0,0 +1,341 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// TagProductLinkClient contains the methods for the TagProductLink group. +// Don't use this type directly, use NewTagProductLinkClient() instead. +type TagProductLinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewTagProductLinkClient creates a new instance of TagProductLinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewTagProductLinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagProductLinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TagProductLinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds a product to the specified tag via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - productLinkID - Tag-product link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - TagProductLinkClientCreateOrUpdateOptions contains the optional parameters for the TagProductLinkClient.CreateOrUpdate +// method. +func (client *TagProductLinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, tagID string, productLinkID string, parameters TagProductLinkContract, options *TagProductLinkClientCreateOrUpdateOptions) (TagProductLinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "TagProductLinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, tagID, productLinkID, parameters, options) + if err != nil { + return TagProductLinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TagProductLinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return TagProductLinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TagProductLinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, productLinkID string, parameters TagProductLinkContract, _ *TagProductLinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks/{productLinkId}" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if productLinkID == "" { + return nil, errors.New("parameter productLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productLinkId}", url.PathEscape(productLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *TagProductLinkClient) createOrUpdateHandleResponse(resp *http.Response) (TagProductLinkClientCreateOrUpdateResponse, error) { + result := TagProductLinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagProductLinkContract); err != nil { + return TagProductLinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified product from the specified tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - productLinkID - Tag-product link identifier. Must be unique in the current API Management service instance. +// - options - TagProductLinkClientDeleteOptions contains the optional parameters for the TagProductLinkClient.Delete method. +func (client *TagProductLinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, tagID string, productLinkID string, options *TagProductLinkClientDeleteOptions) (TagProductLinkClientDeleteResponse, error) { + var err error + const operationName = "TagProductLinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, tagID, productLinkID, options) + if err != nil { + return TagProductLinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TagProductLinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TagProductLinkClientDeleteResponse{}, err + } + return TagProductLinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TagProductLinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, productLinkID string, _ *TagProductLinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks/{productLinkId}" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if productLinkID == "" { + return nil, errors.New("parameter productLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productLinkId}", url.PathEscape(productLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the product link for the tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - productLinkID - Tag-product link identifier. Must be unique in the current API Management service instance. +// - options - TagProductLinkClientGetOptions contains the optional parameters for the TagProductLinkClient.Get method. +func (client *TagProductLinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, tagID string, productLinkID string, options *TagProductLinkClientGetOptions) (TagProductLinkClientGetResponse, error) { + var err error + const operationName = "TagProductLinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, tagID, productLinkID, options) + if err != nil { + return TagProductLinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TagProductLinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TagProductLinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *TagProductLinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, productLinkID string, _ *TagProductLinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks/{productLinkId}" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if productLinkID == "" { + return nil, errors.New("parameter productLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productLinkId}", url.PathEscape(productLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TagProductLinkClient) getHandleResponse(resp *http.Response) (TagProductLinkClientGetResponse, error) { + result := TagProductLinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.TagProductLinkContract); err != nil { + return TagProductLinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the product links associated with a tag. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - options - TagProductLinkClientListByProductOptions contains the optional parameters for the TagProductLinkClient.NewListByProductPager +// method. +func (client *TagProductLinkClient) NewListByProductPager(resourceGroupName string, serviceName string, tagID string, options *TagProductLinkClientListByProductOptions) *runtime.Pager[TagProductLinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[TagProductLinkClientListByProductResponse]{ + More: func(page TagProductLinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TagProductLinkClientListByProductResponse) (TagProductLinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TagProductLinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, tagID, options) + }, nil) + if err != nil { + return TagProductLinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *TagProductLinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, options *TagProductLinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks" + 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 tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *TagProductLinkClient) listByProductHandleResponse(resp *http.Response) (TagProductLinkClientListByProductResponse, error) { + result := TagProductLinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagProductLinkCollection); err != nil { + return TagProductLinkClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tagresource_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/tagresource_client.go index f58424ff22a4..4a909fb8cb12 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tagresource_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/tagresource_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type TagResourceClient struct { } // NewTagResourceClient creates a new instance of TagResourceClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewTagResourceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagResourceClient, error) { @@ -46,7 +43,7 @@ func NewTagResourceClient(subscriptionID string, credential azcore.TokenCredenti // NewListByServicePager - Lists a collection of resources associated with tags. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - TagResourceClientListByServiceOptions contains the optional parameters for the TagResourceClient.NewListByServicePager @@ -97,13 +94,13 @@ func (client *TagResourceClient) listByServiceCreateRequest(ctx context.Context, if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tagresource_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/tagresource_client_example_test.go deleted file mode 100644 index 55f1760528ce..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tagresource_client_example_test.go +++ /dev/null @@ -1,94 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTagResources.json -func ExampleTagResourceClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTagResourceClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.TagResourceClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: 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.TagResourceCollection = armapimanagement.TagResourceCollection{ - // Value: []*armapimanagement.TagResourceContract{ - // { - // Operation: &armapimanagement.OperationTagResourceContractProperties{ - // Name: to.Ptr("Create resource"), - // Method: to.Ptr("POST"), - // Description: to.Ptr("A demonstration of a POST call based on the echo backend above. The request body is expected to contain JSON-formatted data (see example below). A policy is used to automatically transform any request sent in JSON directly to XML. In a real-world scenario this could be used to enable modern clients to speak to a legacy backend."), - // APIName: to.Ptr("Echo API"), - // APIRevision: to.Ptr("1"), - // ID: to.Ptr("/apis/echo-api/operations/create-resource"), - // URLTemplate: to.Ptr("/resource"), - // }, - // Tag: &armapimanagement.TagResourceContractProperties{ - // Name: to.Ptr("awesomeTag"), - // ID: to.Ptr("/tags/apitag123"), - // }, - // }, - // { - // API: &armapimanagement.APITagResourceContractProperties{ - // APIRevision: to.Ptr("1"), - // IsCurrent: to.Ptr(true), - // Name: to.Ptr("Echo API"), - // Path: to.Ptr("echo"), - // ID: to.Ptr("/apis/echo-api"), - // ServiceURL: to.Ptr("http://echoapi.cloudapp.net/api"), - // }, - // Tag: &armapimanagement.TagResourceContractProperties{ - // Name: to.Ptr("awesomeTag"), - // ID: to.Ptr("/tags/apitag123"), - // }, - // }, - // { - // Product: &armapimanagement.ProductTagResourceContractProperties{ - // Description: to.Ptr("Subscribers will be able to run 5 calls/minute up to a maximum of 100 calls/week."), - // ApprovalRequired: to.Ptr(false), - // State: to.Ptr(armapimanagement.ProductStatePublished), - // SubscriptionRequired: to.Ptr(true), - // SubscriptionsLimit: to.Ptr[int32](1), - // Terms: to.Ptr(""), - // Name: to.Ptr("Starter"), - // ID: to.Ptr("/products/starter"), - // }, - // Tag: &armapimanagement.TagResourceContractProperties{ - // Name: to.Ptr("awesomeTag"), - // ID: to.Ptr("/tags/apitag123"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccess_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccess_client.go index 24d34713b086..b90b9210a78d 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccess_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccess_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type TenantAccessClient struct { } // NewTenantAccessClient creates a new instance of TenantAccessClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewTenantAccessClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TenantAccessClient, error) { @@ -46,7 +43,7 @@ func NewTenantAccessClient(subscriptionID string, credential azcore.TokenCredent // Create - Update tenant access information details. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - accessName - The identifier of the Access configuration. @@ -77,7 +74,7 @@ func (client *TenantAccessClient) Create(ctx context.Context, resourceGroupName } // createCreateRequest creates the Create request. -func (client *TenantAccessClient) createCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, ifMatch string, parameters AccessInformationCreateParameters, options *TenantAccessClientCreateOptions) (*policy.Request, error) { +func (client *TenantAccessClient) createCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, ifMatch string, parameters AccessInformationCreateParameters, _ *TenantAccessClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -100,10 +97,10 @@ func (client *TenantAccessClient) createCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -125,7 +122,7 @@ func (client *TenantAccessClient) createHandleResponse(resp *http.Response) (Ten // Get - Get tenant access information details without secrets. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - accessName - The identifier of the Access configuration. @@ -153,7 +150,7 @@ func (client *TenantAccessClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *TenantAccessClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessClientGetOptions) (*policy.Request, error) { +func (client *TenantAccessClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, _ *TenantAccessClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -176,7 +173,7 @@ func (client *TenantAccessClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -196,7 +193,7 @@ func (client *TenantAccessClient) getHandleResponse(resp *http.Response) (Tenant // GetEntityTag - Tenant access metadata // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - accessName - The identifier of the Access configuration. @@ -225,7 +222,7 @@ func (client *TenantAccessClient) GetEntityTag(ctx context.Context, resourceGrou } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *TenantAccessClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessClientGetEntityTagOptions) (*policy.Request, error) { +func (client *TenantAccessClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, _ *TenantAccessClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -248,7 +245,7 @@ func (client *TenantAccessClient) getEntityTagCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -265,7 +262,7 @@ func (client *TenantAccessClient) getEntityTagHandleResponse(resp *http.Response // NewListByServicePager - Returns list of access infos - for Git and Management endpoints. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - TenantAccessClientListByServiceOptions contains the optional parameters for the TenantAccessClient.NewListByServicePager @@ -316,7 +313,7 @@ func (client *TenantAccessClient) listByServiceCreateRequest(ctx context.Context if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -334,7 +331,7 @@ func (client *TenantAccessClient) listByServiceHandleResponse(resp *http.Respons // ListSecrets - Get tenant access information details. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - accessName - The identifier of the Access configuration. @@ -363,7 +360,7 @@ func (client *TenantAccessClient) ListSecrets(ctx context.Context, resourceGroup } // listSecretsCreateRequest creates the ListSecrets request. -func (client *TenantAccessClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessClientListSecretsOptions) (*policy.Request, error) { +func (client *TenantAccessClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, _ *TenantAccessClientListSecretsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -386,7 +383,7 @@ func (client *TenantAccessClient) listSecretsCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -407,7 +404,7 @@ func (client *TenantAccessClient) listSecretsHandleResponse(resp *http.Response) // RegeneratePrimaryKey - Regenerate primary access key // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - accessName - The identifier of the Access configuration. @@ -435,7 +432,7 @@ func (client *TenantAccessClient) RegeneratePrimaryKey(ctx context.Context, reso } // regeneratePrimaryKeyCreateRequest creates the RegeneratePrimaryKey request. -func (client *TenantAccessClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessClientRegeneratePrimaryKeyOptions) (*policy.Request, error) { +func (client *TenantAccessClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, _ *TenantAccessClientRegeneratePrimaryKeyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -458,7 +455,7 @@ func (client *TenantAccessClient) regeneratePrimaryKeyCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -467,7 +464,7 @@ func (client *TenantAccessClient) regeneratePrimaryKeyCreateRequest(ctx context. // RegenerateSecondaryKey - Regenerate secondary access key // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - accessName - The identifier of the Access configuration. @@ -495,7 +492,7 @@ func (client *TenantAccessClient) RegenerateSecondaryKey(ctx context.Context, re } // regenerateSecondaryKeyCreateRequest creates the RegenerateSecondaryKey request. -func (client *TenantAccessClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessClientRegenerateSecondaryKeyOptions) (*policy.Request, error) { +func (client *TenantAccessClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, _ *TenantAccessClientRegenerateSecondaryKeyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -518,7 +515,7 @@ func (client *TenantAccessClient) regenerateSecondaryKeyCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -527,7 +524,7 @@ func (client *TenantAccessClient) regenerateSecondaryKeyCreateRequest(ctx contex // Update - Update tenant access information details. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - accessName - The identifier of the Access configuration. @@ -558,7 +555,7 @@ func (client *TenantAccessClient) Update(ctx context.Context, resourceGroupName } // updateCreateRequest creates the Update request. -func (client *TenantAccessClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, ifMatch string, parameters AccessInformationUpdateParameters, options *TenantAccessClientUpdateOptions) (*policy.Request, error) { +func (client *TenantAccessClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, ifMatch string, parameters AccessInformationUpdateParameters, _ *TenantAccessClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -581,10 +578,10 @@ func (client *TenantAccessClient) updateCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccess_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccess_client_example_test.go deleted file mode 100644 index 77fd0901db31..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccess_client_example_test.go +++ /dev/null @@ -1,237 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTenantAccess.json -func ExampleTenantAccessClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTenantAccessClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.TenantAccessClientListByServiceOptions{Filter: 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.AccessInformationCollection = armapimanagement.AccessInformationCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.AccessInformationContract{ - // { - // Name: to.Ptr("access"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tenant"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tenant/access"), - // Properties: &armapimanagement.AccessInformationContractProperties{ - // Enabled: to.Ptr(true), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadTenantAccess.json -func ExampleTenantAccessClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTenantAccessClient().GetEntityTag(ctx, "rg1", "apimService1", armapimanagement.AccessIDNameAccess, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTenantAccess.json -func ExampleTenantAccessClient_Get_apiManagementGetTenantAccess() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTenantAccessClient().Get(ctx, "rg1", "apimService1", armapimanagement.AccessIDNameAccess, 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.AccessInformationContract = armapimanagement.AccessInformationContract{ - // Name: to.Ptr("access"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tenant"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tenant/access"), - // Properties: &armapimanagement.AccessInformationContractProperties{ - // Enabled: to.Ptr(true), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTenantGitAccess.json -func ExampleTenantAccessClient_Get_apiManagementGetTenantGitAccess() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTenantAccessClient().Get(ctx, "rg1", "apimService1", armapimanagement.AccessIDNameGitAccess, 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.AccessInformationContract = armapimanagement.AccessInformationContract{ - // Name: to.Ptr("gitAccess"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tenant"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tenant/gitAccess"), - // Properties: &armapimanagement.AccessInformationContractProperties{ - // Enabled: to.Ptr(true), - // PrincipalID: to.Ptr("git"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateTenantAccess.json -func ExampleTenantAccessClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTenantAccessClient().Create(ctx, "rg1", "apimService1", armapimanagement.AccessIDNameAccess, "*", armapimanagement.AccessInformationCreateParameters{ - Properties: &armapimanagement.AccessInformationCreateParameterProperties{ - Enabled: to.Ptr(true), - }, - }, 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.AccessInformationContract = armapimanagement.AccessInformationContract{ - // Name: to.Ptr("access"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tenant"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tenant/access"), - // Properties: &armapimanagement.AccessInformationContractProperties{ - // Enabled: to.Ptr(true), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateTenantAccess.json -func ExampleTenantAccessClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTenantAccessClient().Update(ctx, "rg1", "apimService1", armapimanagement.AccessIDNameAccess, "*", armapimanagement.AccessInformationUpdateParameters{ - Properties: &armapimanagement.AccessInformationUpdateParameterProperties{ - Enabled: to.Ptr(true), - }, - }, 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.AccessInformationContract = armapimanagement.AccessInformationContract{ - // Name: to.Ptr("access"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tenant"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tenant/access"), - // Properties: &armapimanagement.AccessInformationContractProperties{ - // Enabled: to.Ptr(true), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantAccessRegenerateKey.json -func ExampleTenantAccessClient_RegeneratePrimaryKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTenantAccessClient().RegeneratePrimaryKey(ctx, "rg1", "apimService1", armapimanagement.AccessIDNameAccess, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListSecretsTenantAccess.json -func ExampleTenantAccessClient_ListSecrets() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTenantAccessClient().ListSecrets(ctx, "rg1", "apimService1", armapimanagement.AccessIDNameAccess, 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.AccessInformationSecretsContract = armapimanagement.AccessInformationSecretsContract{ - // Enabled: to.Ptr(true), - // ID: to.Ptr("5600b59375ff190048030003"), - // PrimaryKey: to.Ptr(""), - // SecondaryKey: to.Ptr(""), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccessgit_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccessgit_client.go index 5af3beb72aa9..6398699d72ae 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccessgit_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccessgit_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type TenantAccessGitClient struct { } // NewTenantAccessGitClient creates a new instance of TenantAccessGitClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewTenantAccessGitClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TenantAccessGitClient, error) { @@ -46,7 +43,7 @@ func NewTenantAccessGitClient(subscriptionID string, credential azcore.TokenCred // RegeneratePrimaryKey - Regenerate primary access key for GIT. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - accessName - The identifier of the Access configuration. @@ -74,7 +71,7 @@ func (client *TenantAccessGitClient) RegeneratePrimaryKey(ctx context.Context, r } // regeneratePrimaryKeyCreateRequest creates the RegeneratePrimaryKey request. -func (client *TenantAccessGitClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGitClientRegeneratePrimaryKeyOptions) (*policy.Request, error) { +func (client *TenantAccessGitClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, _ *TenantAccessGitClientRegeneratePrimaryKeyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -97,7 +94,7 @@ func (client *TenantAccessGitClient) regeneratePrimaryKeyCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -106,7 +103,7 @@ func (client *TenantAccessGitClient) regeneratePrimaryKeyCreateRequest(ctx conte // RegenerateSecondaryKey - Regenerate secondary access key for GIT. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - accessName - The identifier of the Access configuration. @@ -134,7 +131,7 @@ func (client *TenantAccessGitClient) RegenerateSecondaryKey(ctx context.Context, } // regenerateSecondaryKeyCreateRequest creates the RegenerateSecondaryKey request. -func (client *TenantAccessGitClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGitClientRegenerateSecondaryKeyOptions) (*policy.Request, error) { +func (client *TenantAccessGitClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, _ *TenantAccessGitClientRegenerateSecondaryKeyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -157,7 +154,7 @@ func (client *TenantAccessGitClient) regenerateSecondaryKeyCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccessgit_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccessgit_client_example_test.go deleted file mode 100644 index 81d267d5b112..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tenantaccessgit_client_example_test.go +++ /dev/null @@ -1,35 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantAccessRegenerateKey.json -func ExampleTenantAccessGitClient_RegeneratePrimaryKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTenantAccessGitClient().RegeneratePrimaryKey(ctx, "rg1", "apimService1", armapimanagement.AccessIDNameAccess, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tenantconfiguration_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/tenantconfiguration_client.go index 87fd47425ac4..ba99ec60e26e 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tenantconfiguration_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/tenantconfiguration_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type TenantConfigurationClient struct { } // NewTenantConfigurationClient creates a new instance of TenantConfigurationClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewTenantConfigurationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TenantConfigurationClient, error) { @@ -47,7 +44,7 @@ func NewTenantConfigurationClient(subscriptionID string, credential azcore.Token // running operation and could take several minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - configurationName - The identifier of the Git Configuration Operation. @@ -76,7 +73,7 @@ func (client *TenantConfigurationClient) BeginDeploy(ctx context.Context, resour // operation and could take several minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *TenantConfigurationClient) deploy(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationClientBeginDeployOptions) (*http.Response, error) { var err error const operationName = "TenantConfigurationClient.BeginDeploy" @@ -99,7 +96,7 @@ func (client *TenantConfigurationClient) deploy(ctx context.Context, resourceGro } // deployCreateRequest creates the Deploy request. -func (client *TenantConfigurationClient) deployCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationClientBeginDeployOptions) (*policy.Request, error) { +func (client *TenantConfigurationClient) deployCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, _ *TenantConfigurationClientBeginDeployOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -122,7 +119,7 @@ func (client *TenantConfigurationClient) deployCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -134,7 +131,7 @@ func (client *TenantConfigurationClient) deployCreateRequest(ctx context.Context // GetSyncState - Gets the status of the most recent synchronization between the configuration database and the Git repository. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - configurationName - The identifier of the Git Configuration Operation. @@ -163,7 +160,7 @@ func (client *TenantConfigurationClient) GetSyncState(ctx context.Context, resou } // getSyncStateCreateRequest creates the GetSyncState request. -func (client *TenantConfigurationClient) getSyncStateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, options *TenantConfigurationClientGetSyncStateOptions) (*policy.Request, error) { +func (client *TenantConfigurationClient) getSyncStateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, _ *TenantConfigurationClientGetSyncStateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -186,7 +183,7 @@ func (client *TenantConfigurationClient) getSyncStateCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -205,7 +202,7 @@ func (client *TenantConfigurationClient) getSyncStateHandleResponse(resp *http.R // This is a long running operation and could take several minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - configurationName - The identifier of the Git Configuration Operation. @@ -234,7 +231,7 @@ func (client *TenantConfigurationClient) BeginSave(ctx context.Context, resource // This is a long running operation and could take several minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *TenantConfigurationClient) save(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters SaveConfigurationParameter, options *TenantConfigurationClientBeginSaveOptions) (*http.Response, error) { var err error const operationName = "TenantConfigurationClient.BeginSave" @@ -257,7 +254,7 @@ func (client *TenantConfigurationClient) save(ctx context.Context, resourceGroup } // saveCreateRequest creates the Save request. -func (client *TenantConfigurationClient) saveCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters SaveConfigurationParameter, options *TenantConfigurationClientBeginSaveOptions) (*policy.Request, error) { +func (client *TenantConfigurationClient) saveCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters SaveConfigurationParameter, _ *TenantConfigurationClientBeginSaveOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -280,7 +277,7 @@ func (client *TenantConfigurationClient) saveCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -293,7 +290,7 @@ func (client *TenantConfigurationClient) saveCreateRequest(ctx context.Context, // could take several minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - configurationName - The identifier of the Git Configuration Operation. @@ -322,7 +319,7 @@ func (client *TenantConfigurationClient) BeginValidate(ctx context.Context, reso // take several minutes to complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 func (client *TenantConfigurationClient) validate(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationClientBeginValidateOptions) (*http.Response, error) { var err error const operationName = "TenantConfigurationClient.BeginValidate" @@ -345,7 +342,7 @@ func (client *TenantConfigurationClient) validate(ctx context.Context, resourceG } // validateCreateRequest creates the Validate request. -func (client *TenantConfigurationClient) validateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationClientBeginValidateOptions) (*policy.Request, error) { +func (client *TenantConfigurationClient) validateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, _ *TenantConfigurationClientBeginValidateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -368,7 +365,7 @@ func (client *TenantConfigurationClient) validateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tenantconfiguration_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/tenantconfiguration_client_example_test.go deleted file mode 100644 index 0dfe90d543e5..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tenantconfiguration_client_example_test.go +++ /dev/null @@ -1,178 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantConfigurationDeploy.json -func ExampleTenantConfigurationClient_BeginDeploy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTenantConfigurationClient().BeginDeploy(ctx, "rg1", "apimService1", armapimanagement.ConfigurationIDNameConfiguration, armapimanagement.DeployConfigurationParameters{ - Properties: &armapimanagement.DeployConfigurationParameterProperties{ - Branch: to.Ptr("master"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationResultContract = armapimanagement.OperationResultContract{ - // Name: to.Ptr("6074e652093a9d0dac3d733c"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tenant/operationResults"), - // ID: to.Ptr("6074e652093a9d0dac3d733c"), - // Properties: &armapimanagement.OperationResultContractProperties{ - // Error: &armapimanagement.ErrorResponseBody{ - // Code: to.Ptr("ValidationError"), - // Message: to.Ptr("File not found: 'api-management/configuration.json'"), - // }, - // Started: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-26T17:06:54.303Z"); return t}()), - // Status: to.Ptr(armapimanagement.AsyncOperationStatusFailed), - // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-26T17:07:21.777Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantConfigurationSave.json -func ExampleTenantConfigurationClient_BeginSave() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTenantConfigurationClient().BeginSave(ctx, "rg1", "apimService1", armapimanagement.ConfigurationIDNameConfiguration, armapimanagement.SaveConfigurationParameter{ - Properties: &armapimanagement.SaveConfigurationParameterProperties{ - Branch: to.Ptr("master"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationResultContract = armapimanagement.OperationResultContract{ - // Name: to.Ptr("6074e652093a9d0dac3d733c"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tenant/operationResults"), - // ID: to.Ptr("6074e652093a9d0dac3d733c"), - // Properties: &armapimanagement.OperationResultContractProperties{ - // ActionLog: []*armapimanagement.OperationResultLogItemContract{ - // }, - // ResultInfo: to.Ptr("The configuration was successfully saved to master as commit c0ae274f6046912107bad734834cbf65918668b6."), - // Started: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-13T00:31:14.940Z"); return t}()), - // Status: to.Ptr(armapimanagement.AsyncOperationStatusSucceeded), - // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-13T00:31:27.590Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantConfigurationValidate.json -func ExampleTenantConfigurationClient_BeginValidate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTenantConfigurationClient().BeginValidate(ctx, "rg1", "apimService1", armapimanagement.ConfigurationIDNameConfiguration, armapimanagement.DeployConfigurationParameters{ - Properties: &armapimanagement.DeployConfigurationParameterProperties{ - Branch: to.Ptr("master"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationResultContract = armapimanagement.OperationResultContract{ - // Name: to.Ptr("6074ec02093a9d0dac3d7345"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tenant/operationResults"), - // ID: to.Ptr("6074ec02093a9d0dac3d7345"), - // Properties: &armapimanagement.OperationResultContractProperties{ - // ActionLog: []*armapimanagement.OperationResultLogItemContract{ - // }, - // ResultInfo: to.Ptr("Validation is successfull"), - // Started: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-13T00:55:30.620Z"); return t}()), - // Status: to.Ptr(armapimanagement.AsyncOperationStatusSucceeded), - // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-13T00:55:39.857Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementTenantAccessSyncState.json -func ExampleTenantConfigurationClient_GetSyncState() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTenantConfigurationClient().GetSyncState(ctx, "rg1", "apimService1", armapimanagement.ConfigurationIDNameConfiguration, 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.TenantConfigurationSyncStateContract = armapimanagement.TenantConfigurationSyncStateContract{ - // Name: to.Ptr("syncState"), - // Type: to.Ptr("Microsoft.ApiManagement/service/tenant/syncState"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tenant/configuration/syncState"), - // Properties: &armapimanagement.TenantConfigurationSyncStateContractProperties{ - // Branch: to.Ptr("master"), - // CommitID: to.Ptr("de891c2342c7058dde45e5e624eae7e558c94683"), - // ConfigurationChangeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-13T00:11:43.862Z"); return t}()), - // IsExport: to.Ptr(true), - // IsGitEnabled: to.Ptr(true), - // IsSynced: to.Ptr(true), - // LastOperationID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/tenant/configuration/operationResults/6074f0bd093a9d0dac3d7347"), - // SyncDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-13T01:15:53.982Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tenantsettings_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/tenantsettings_client.go index ffb74e3c86de..ea3858d89460 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tenantsettings_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/tenantsettings_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type TenantSettingsClient struct { } // NewTenantSettingsClient creates a new instance of TenantSettingsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewTenantSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TenantSettingsClient, error) { @@ -46,7 +43,7 @@ func NewTenantSettingsClient(subscriptionID string, credential azcore.TokenCrede // Get - Get tenant settings. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - settingsType - The identifier of the settings. @@ -74,7 +71,7 @@ func (client *TenantSettingsClient) Get(ctx context.Context, resourceGroupName s } // getCreateRequest creates the Get request. -func (client *TenantSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, settingsType SettingsTypeName, options *TenantSettingsClientGetOptions) (*policy.Request, error) { +func (client *TenantSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, settingsType SettingsTypeName, _ *TenantSettingsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -97,7 +94,7 @@ func (client *TenantSettingsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -117,7 +114,7 @@ func (client *TenantSettingsClient) getHandleResponse(resp *http.Response) (Tena // NewListByServicePager - Public settings. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - TenantSettingsClientListByServiceOptions contains the optional parameters for the TenantSettingsClient.NewListByServicePager @@ -168,7 +165,7 @@ func (client *TenantSettingsClient) listByServiceCreateRequest(ctx context.Conte if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/tenantsettings_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/tenantsettings_client_example_test.go deleted file mode 100644 index 3235565201ea..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/tenantsettings_client_example_test.go +++ /dev/null @@ -1,96 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListTenantSettings.json -func ExampleTenantSettingsClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTenantSettingsClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.TenantSettingsClientListByServiceOptions{Filter: 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.TenantSettingsCollection = armapimanagement.TenantSettingsCollection{ - // Value: []*armapimanagement.TenantSettingsContract{ - // { - // Name: to.Ptr("public"), - // Type: to.Ptr("Microsoft.ApiManagement/service/settings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/settings/public"), - // Properties: &armapimanagement.TenantSettingsContractProperties{ - // Settings: map[string]*string{ - // "CustomPortalSettings.DelegatedSubscriptionEnabled": to.Ptr("False"), - // "CustomPortalSettings.DelegationEnabled": to.Ptr("False"), - // "CustomPortalSettings.DelegationUrl": to.Ptr(""), - // "CustomPortalSettings.UserRegistrationTerms": nil, - // "CustomPortalSettings.UserRegistrationTermsConsentRequired": to.Ptr("False"), - // "CustomPortalSettings.UserRegistrationTermsEnabled": to.Ptr("False"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetTenantSettings.json -func ExampleTenantSettingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTenantSettingsClient().Get(ctx, "rg1", "apimService1", armapimanagement.SettingsTypeNamePublic, 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.TenantSettingsContract = armapimanagement.TenantSettingsContract{ - // Name: to.Ptr("public"), - // Type: to.Ptr("Microsoft.ApiManagement/service/settings"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/settings/public"), - // Properties: &armapimanagement.TenantSettingsContractProperties{ - // Settings: map[string]*string{ - // "CustomPortalSettings.DelegatedSubscriptionEnabled": to.Ptr("False"), - // "CustomPortalSettings.DelegationEnabled": to.Ptr("False"), - // "CustomPortalSettings.DelegationUrl": to.Ptr(""), - // "CustomPortalSettings.UserRegistrationTerms": nil, - // "CustomPortalSettings.UserRegistrationTermsConsentRequired": to.Ptr("False"), - // "CustomPortalSettings.UserRegistrationTermsEnabled": to.Ptr("False"), - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/time_rfc3339.go b/sdk/resourcemanager/apimanagement/armapimanagement/time_rfc3339.go index 0ced6a7279f3..6752fdcbb221 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/time_rfc3339.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/time_rfc3339.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -19,12 +16,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +41,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/user_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/user_client.go index 3ff62db604e5..6cb5c1367b69 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/user_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/user_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type UserClient struct { } // NewUserClient creates a new instance of UserClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewUserClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UserClient, error) { @@ -47,7 +44,7 @@ func NewUserClient(subscriptionID string, credential azcore.TokenCredential, opt // CreateOrUpdate - Creates or Updates a user. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -99,15 +96,15 @@ func (client *UserClient) createOrUpdateCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") if options != nil && options.Notify != nil { reqQP.Set("notify", strconv.FormatBool(*options.Notify)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -126,39 +123,61 @@ func (client *UserClient) createOrUpdateHandleResponse(resp *http.Response) (Use return result, nil } -// Delete - Deletes specific user. +// BeginDelete - Deletes specific user. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. // - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or // it should be * for unconditional update. -// - options - UserClientDeleteOptions contains the optional parameters for the UserClient.Delete method. -func (client *UserClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, options *UserClientDeleteOptions) (UserClientDeleteResponse, error) { +// - options - UserClientBeginDeleteOptions contains the optional parameters for the UserClient.BeginDelete method. +func (client *UserClient) BeginDelete(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, options *UserClientBeginDeleteOptions) (*runtime.Poller[UserClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, serviceName, userID, ifMatch, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UserClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[UserClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes specific user. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *UserClient) deleteOperation(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, options *UserClientBeginDeleteOptions) (*http.Response, error) { var err error - const operationName = "UserClient.Delete" + const operationName = "UserClient.BeginDelete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, userID, ifMatch, options) if err != nil { - return UserClientDeleteResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return UserClientDeleteResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return UserClientDeleteResponse{}, err + return nil, err } - return UserClientDeleteResponse{}, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *UserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, options *UserClientDeleteOptions) (*policy.Request, error) { +func (client *UserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, options *UserClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -181,19 +200,19 @@ func (client *UserClient) deleteCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.AppType != nil { + reqQP.Set("appType", string(*options.AppType)) + } if options != nil && options.DeleteSubscriptions != nil { reqQP.Set("deleteSubscriptions", strconv.FormatBool(*options.DeleteSubscriptions)) } if options != nil && options.Notify != nil { reqQP.Set("notify", strconv.FormatBool(*options.Notify)) } - reqQP.Set("api-version", "2022-08-01") - if options != nil && options.AppType != nil { - reqQP.Set("appType", string(*options.AppType)) - } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } @@ -201,7 +220,7 @@ func (client *UserClient) deleteCreateRequest(ctx context.Context, resourceGroup // portal. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -229,7 +248,7 @@ func (client *UserClient) GenerateSsoURL(ctx context.Context, resourceGroupName } // generateSsoURLCreateRequest creates the GenerateSsoURL request. -func (client *UserClient) generateSsoURLCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserClientGenerateSsoURLOptions) (*policy.Request, error) { +func (client *UserClient) generateSsoURLCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, _ *UserClientGenerateSsoURLOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -252,7 +271,7 @@ func (client *UserClient) generateSsoURLCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -270,7 +289,7 @@ func (client *UserClient) generateSsoURLHandleResponse(resp *http.Response) (Use // Get - Gets the details of the user specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -298,7 +317,7 @@ func (client *UserClient) Get(ctx context.Context, resourceGroupName string, ser } // getCreateRequest creates the Get request. -func (client *UserClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserClientGetOptions) (*policy.Request, error) { +func (client *UserClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, _ *UserClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -321,7 +340,7 @@ func (client *UserClient) getCreateRequest(ctx context.Context, resourceGroupNam return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -341,7 +360,7 @@ func (client *UserClient) getHandleResponse(resp *http.Response) (UserClientGetR // GetEntityTag - Gets the entity state (Etag) version of the user specified by its identifier. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -369,7 +388,7 @@ func (client *UserClient) GetEntityTag(ctx context.Context, resourceGroupName st } // getEntityTagCreateRequest creates the GetEntityTag request. -func (client *UserClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserClientGetEntityTagOptions) (*policy.Request, error) { +func (client *UserClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, _ *UserClientGetEntityTagOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -392,7 +411,7 @@ func (client *UserClient) getEntityTagCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -410,7 +429,7 @@ func (client *UserClient) getEntityTagHandleResponse(resp *http.Response) (UserC // GetSharedAccessToken - Gets the Shared Access Authorization Token for the User. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -440,7 +459,7 @@ func (client *UserClient) GetSharedAccessToken(ctx context.Context, resourceGrou } // getSharedAccessTokenCreateRequest creates the GetSharedAccessToken request. -func (client *UserClient) getSharedAccessTokenCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserTokenParameters, options *UserClientGetSharedAccessTokenOptions) (*policy.Request, error) { +func (client *UserClient) getSharedAccessTokenCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserTokenParameters, _ *UserClientGetSharedAccessTokenOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -463,7 +482,7 @@ func (client *UserClient) getSharedAccessTokenCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -483,7 +502,7 @@ func (client *UserClient) getSharedAccessTokenHandleResponse(resp *http.Response // NewListByServicePager - Lists a collection of registered users in the specified service instance. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - options - UserClientListByServiceOptions contains the optional parameters for the UserClient.NewListByServicePager method. @@ -533,16 +552,16 @@ func (client *UserClient) listByServiceCreateRequest(ctx context.Context, resour if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") if options != nil && options.ExpandGroups != nil { reqQP.Set("expandGroups", strconv.FormatBool(*options.ExpandGroups)) } - reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -560,7 +579,7 @@ func (client *UserClient) listByServiceHandleResponse(resp *http.Response) (User // Update - Updates the details of the user specified by its identifier. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -591,7 +610,7 @@ func (client *UserClient) Update(ctx context.Context, resourceGroupName string, } // updateCreateRequest creates the Update request. -func (client *UserClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, parameters UserUpdateParameters, options *UserClientUpdateOptions) (*policy.Request, error) { +func (client *UserClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, parameters UserUpdateParameters, _ *UserClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -614,10 +633,10 @@ func (client *UserClient) updateCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/user_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/user_client_example_test.go deleted file mode 100644 index f861158f55cc..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/user_client_example_test.go +++ /dev/null @@ -1,321 +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 armapimanagement_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListUsers.json -func ExampleUserClient_NewListByServicePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUserClient().NewListByServicePager("rg1", "apimService1", &armapimanagement.UserClientListByServiceOptions{Filter: nil, - Top: nil, - Skip: nil, - ExpandGroups: 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.UserCollection = armapimanagement.UserCollection{ - // Count: to.Ptr[int64](3), - // Value: []*armapimanagement.UserContract{ - // { - // Name: to.Ptr("1"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // Properties: &armapimanagement.UserContractProperties{ - // Identities: []*armapimanagement.UserIdentityContract{ - // { - // ID: to.Ptr("admin@live.com"), - // Provider: to.Ptr("Azure"), - // }}, - // State: to.Ptr(armapimanagement.UserStateActive), - // Email: to.Ptr("admin@live.com"), - // FirstName: to.Ptr("Administrator"), - // LastName: to.Ptr(""), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2015-09-22T01:57:39.677Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("56eaec62baf08b06e46d27fd"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/56eaec62baf08b06e46d27fd"), - // Properties: &armapimanagement.UserContractProperties{ - // Identities: []*armapimanagement.UserIdentityContract{ - // { - // ID: to.Ptr("foo.bar.83@gmail.com"), - // Provider: to.Ptr("Basic"), - // }}, - // State: to.Ptr(armapimanagement.UserStateActive), - // Email: to.Ptr("foo.bar.83@gmail.com"), - // FirstName: to.Ptr("foo"), - // LastName: to.Ptr("bar"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-17T17:41:56.327Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("5931a75ae4bbd512a88c680b"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512a88c680b"), - // Properties: &armapimanagement.UserContractProperties{ - // Identities: []*armapimanagement.UserIdentityContract{ - // { - // ID: to.Ptr("*************"), - // Provider: to.Ptr("Microsoft"), - // }}, - // State: to.Ptr(armapimanagement.UserStateActive), - // Email: to.Ptr("foobar@outlook.com"), - // FirstName: to.Ptr("foo"), - // LastName: to.Ptr("bar"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-02T17:58:50.357Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementHeadUser.json -func ExampleUserClient_GetEntityTag() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewUserClient().GetEntityTag(ctx, "rg1", "apimService1", "5931a75ae4bbd512a88c680b", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetUser.json -func ExampleUserClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewUserClient().Get(ctx, "rg1", "apimService1", "5931a75ae4bbd512a88c680b", 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.UserContract = armapimanagement.UserContract{ - // Name: to.Ptr("5931a75ae4bbd512a88c680b"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512a88c680b"), - // Properties: &armapimanagement.UserContractProperties{ - // Identities: []*armapimanagement.UserIdentityContract{ - // { - // ID: to.Ptr("*************"), - // Provider: to.Ptr("Microsoft"), - // }}, - // State: to.Ptr(armapimanagement.UserStateActive), - // Email: to.Ptr("foobar@outlook.com"), - // FirstName: to.Ptr("foo"), - // LastName: to.Ptr("bar"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-02T17:58:50.357Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateUser.json -func ExampleUserClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewUserClient().CreateOrUpdate(ctx, "rg1", "apimService1", "5931a75ae4bbd512288c680b", armapimanagement.UserCreateParameters{ - Properties: &armapimanagement.UserCreateParameterProperties{ - Confirmation: to.Ptr(armapimanagement.ConfirmationSignup), - Email: to.Ptr("foobar@outlook.com"), - FirstName: to.Ptr("foo"), - LastName: to.Ptr("bar"), - }, - }, &armapimanagement.UserClientCreateOrUpdateOptions{Notify: nil, - IfMatch: 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.UserContract = armapimanagement.UserContract{ - // Name: to.Ptr("5931a75ae4bbd512288c680b"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512288c680b"), - // Properties: &armapimanagement.UserContractProperties{ - // Identities: []*armapimanagement.UserIdentityContract{ - // { - // ID: to.Ptr("foobar@outlook.com"), - // Provider: to.Ptr("Basic"), - // }}, - // State: to.Ptr(armapimanagement.UserStateActive), - // Email: to.Ptr("foobar@outlook.com"), - // FirstName: to.Ptr("foo"), - // Groups: []*armapimanagement.GroupContractProperties{ - // }, - // LastName: to.Ptr("bar"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-07T21:21:29.160Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUpdateUser.json -func ExampleUserClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewUserClient().Update(ctx, "rg1", "apimService1", "5931a75ae4bbd512a88c680b", "*", armapimanagement.UserUpdateParameters{ - Properties: &armapimanagement.UserUpdateParametersProperties{ - Email: to.Ptr("foobar@outlook.com"), - FirstName: to.Ptr("foo"), - LastName: to.Ptr("bar"), - }, - }, 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.UserContract = armapimanagement.UserContract{ - // Name: to.Ptr("5931a75ae4bbd512a88c680b"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512a88c680b"), - // Properties: &armapimanagement.UserContractProperties{ - // Identities: []*armapimanagement.UserIdentityContract{ - // { - // ID: to.Ptr("*************"), - // Provider: to.Ptr("Microsoft"), - // }}, - // State: to.Ptr(armapimanagement.UserStateActive), - // Email: to.Ptr("foobar@outlook.com"), - // FirstName: to.Ptr("foo"), - // LastName: to.Ptr("bar"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-06-02T17:58:50.357Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementDeleteUser.json -func ExampleUserClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewUserClient().Delete(ctx, "rg1", "apimService1", "5931a75ae4bbd512288c680b", "*", &armapimanagement.UserClientDeleteOptions{DeleteSubscriptions: nil, - Notify: nil, - AppType: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUserGenerateSsoUrl.json -func ExampleUserClient_GenerateSsoURL() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewUserClient().GenerateSsoURL(ctx, "rg1", "apimService1", "57127d485157a511ace86ae7", 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.GenerateSsoURLResult = armapimanagement.GenerateSsoURLResult{ - // Value: to.Ptr("https://apimService1.portal.azure-api.net/signin-sso?token=57127d485157a511ace86ae7%26201706051624%267VY18MlwAom***********2bYr2bDQHg21OzQsNakExQ%3d%3d"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUserToken.json -func ExampleUserClient_GetSharedAccessToken() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewUserClient().GetSharedAccessToken(ctx, "rg1", "apimService1", "userId1718", armapimanagement.UserTokenParameters{ - Properties: &armapimanagement.UserTokenParameterProperties{ - Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T00:44:24.284Z"); return t }()), - KeyType: to.Ptr(armapimanagement.KeyTypePrimary), - }, - }, 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.UserTokenResult = armapimanagement.UserTokenResult{ - // Value: to.Ptr("userId1718&201904210044&9A1GR1f5WIhFvFmzQG+xxxxxxxxxxx/kBeu87DWad3tkasUXuvPL+MgzlwUHyg=="), - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/userconfirmationpassword_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/userconfirmationpassword_client.go index 822482cb0119..db758a2720cc 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/userconfirmationpassword_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/userconfirmationpassword_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type UserConfirmationPasswordClient struct { } // NewUserConfirmationPasswordClient creates a new instance of UserConfirmationPasswordClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewUserConfirmationPasswordClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UserConfirmationPasswordClient, error) { @@ -46,7 +43,7 @@ func NewUserConfirmationPasswordClient(subscriptionID string, credential azcore. // Send - Sends confirmation // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -97,7 +94,7 @@ func (client *UserConfirmationPasswordClient) sendCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") if options != nil && options.AppType != nil { reqQP.Set("appType", string(*options.AppType)) } diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/userconfirmationpassword_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/userconfirmationpassword_client_example_test.go deleted file mode 100644 index 62f66cf6e6e2..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/userconfirmationpassword_client_example_test.go +++ /dev/null @@ -1,35 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementUserConfirmationPasswordSend.json -func ExampleUserConfirmationPasswordClient_Send() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewUserConfirmationPasswordClient().Send(ctx, "rg1", "apimService1", "57127d485157a511ace86ae7", &armapimanagement.UserConfirmationPasswordClientSendOptions{AppType: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/usergroup_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/usergroup_client.go index 109806a74a33..81bf20148067 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/usergroup_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/usergroup_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type UserGroupClient struct { } // NewUserGroupClient creates a new instance of UserGroupClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewUserGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UserGroupClient, error) { @@ -46,7 +43,7 @@ func NewUserGroupClient(subscriptionID string, credential azcore.TokenCredential // NewListPager - Lists all user groups. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -101,13 +98,13 @@ func (client *UserGroupClient) listCreateRequest(ctx context.Context, resourceGr if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/usergroup_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/usergroup_client_example_test.go deleted file mode 100644 index 0bf66c09cb3c..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/usergroup_client_example_test.go +++ /dev/null @@ -1,61 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListUserGroups.json -func ExampleUserGroupClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUserGroupClient().NewListPager("rg1", "apimService1", "57681833a40f7eb6c49f6acf", &armapimanagement.UserGroupClientListOptions{Filter: nil, - Top: nil, - Skip: 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.GroupCollection = armapimanagement.GroupCollection{ - // Count: to.Ptr[int64](1), - // Value: []*armapimanagement.GroupContract{ - // { - // Name: to.Ptr("5600b57e7e8880006a020002"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users/groups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57681833a40f7eb6c49f6acf/groups/5600b57e7e8880006a020002"), - // Properties: &armapimanagement.GroupContractProperties{ - // Type: to.Ptr(armapimanagement.GroupTypeSystem), - // Description: to.Ptr("Developers is a built-in group. Its membership is managed by the system. Signed-in users fall into this group."), - // BuiltIn: to.Ptr(true), - // DisplayName: to.Ptr("Developers"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/useridentities_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/useridentities_client.go index 278fd4e1f2ac..69637fc1ea81 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/useridentities_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/useridentities_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -28,7 +25,7 @@ type UserIdentitiesClient struct { } // NewUserIdentitiesClient creates a new instance of UserIdentitiesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewUserIdentitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UserIdentitiesClient, error) { @@ -45,7 +42,7 @@ func NewUserIdentitiesClient(subscriptionID string, credential azcore.TokenCrede // NewListPager - List of all user identities. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -74,7 +71,7 @@ func (client *UserIdentitiesClient) NewListPager(resourceGroupName string, servi } // listCreateRequest creates the List request. -func (client *UserIdentitiesClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserIdentitiesClientListOptions) (*policy.Request, error) { +func (client *UserIdentitiesClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, _ *UserIdentitiesClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -97,7 +94,7 @@ func (client *UserIdentitiesClient) listCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/useridentities_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/useridentities_client_example_test.go deleted file mode 100644 index 8b55af502ca4..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/useridentities_client_example_test.go +++ /dev/null @@ -1,50 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListUserIdentities.json -func ExampleUserIdentitiesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUserIdentitiesClient().NewListPager("rg1", "apimService1", "57f2af53bb17172280f44057", 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.UserIdentityCollection = armapimanagement.UserIdentityCollection{ - // Value: []*armapimanagement.UserIdentityContract{ - // { - // ID: to.Ptr("086cf9********55ab"), - // Provider: to.Ptr("Microsoft"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/usersubscription_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/usersubscription_client.go index 4d4d038f0171..4d8de10d8669 100644 --- a/sdk/resourcemanager/apimanagement/armapimanagement/usersubscription_client.go +++ b/sdk/resourcemanager/apimanagement/armapimanagement/usersubscription_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -29,7 +26,7 @@ type UserSubscriptionClient struct { } // NewUserSubscriptionClient creates a new instance of UserSubscriptionClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - 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 NewUserSubscriptionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UserSubscriptionClient, error) { @@ -47,7 +44,7 @@ func NewUserSubscriptionClient(subscriptionID string, credential azcore.TokenCre // Get - Gets the specified Subscription entity associated with a particular user. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -76,7 +73,7 @@ func (client *UserSubscriptionClient) Get(ctx context.Context, resourceGroupName } // getCreateRequest creates the Get request. -func (client *UserSubscriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, sid string, options *UserSubscriptionClientGetOptions) (*policy.Request, error) { +func (client *UserSubscriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, sid string, _ *UserSubscriptionClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -103,7 +100,7 @@ func (client *UserSubscriptionClient) getCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01") + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -123,7 +120,7 @@ func (client *UserSubscriptionClient) getHandleResponse(resp *http.Response) (Us // NewListPager - Lists the collection of subscriptions of the specified user. // -// Generated from API version 2022-08-01 +// Generated from API version 2024-05-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serviceName - The name of the API Management service. // - userID - User identifier. Must be unique in the current API Management service instance. @@ -179,13 +176,13 @@ func (client *UserSubscriptionClient) listCreateRequest(ctx context.Context, res if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skip != nil { reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - reqQP.Set("api-version", "2022-08-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/usersubscription_client_example_test.go b/sdk/resourcemanager/apimanagement/armapimanagement/usersubscription_client_example_test.go deleted file mode 100644 index c3d4377013fa..000000000000 --- a/sdk/resourcemanager/apimanagement/armapimanagement/usersubscription_client_example_test.go +++ /dev/null @@ -1,107 +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 armapimanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementListUserSubscriptions.json -func ExampleUserSubscriptionClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUserSubscriptionClient().NewListPager("rg1", "apimService1", "57681833a40f7eb6c49f6acf", &armapimanagement.UserSubscriptionClientListOptions{Filter: nil, - Top: nil, - Skip: 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.SubscriptionCollection = armapimanagement.SubscriptionCollection{ - // Value: []*armapimanagement.SubscriptionContract{ - // { - // Name: to.Ptr("57681850a40f7eb6c49f6ae3"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57681833a40f7eb6c49f6acf/subscriptions/57681850a40f7eb6c49f6ae3"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-06-20T16:22:39.547Z"); return t}()), - // DisplayName: to.Ptr("57681850a40f7eb6c49f6ae5"), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57681833a40f7eb6c49f6acf"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5768181ea40f7eb6c49f6ac7"), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-06-20T00:00:00.000Z"); return t}()), - // State: to.Ptr(armapimanagement.SubscriptionStateActive), - // }, - // }, - // { - // Name: to.Ptr("57681850a40f7eb6c49f6b2b"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57681833a40f7eb6c49f6acf/subscriptions/57681850a40f7eb6c49f6b2b"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-06-20T16:22:41.103Z"); return t}()), - // DisplayName: to.Ptr("57681850a40f7eb6c49f6b2d"), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57681833a40f7eb6c49f6acf"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5768181ea40f7eb6c49f6ac7"), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-06-20T00:00:00.000Z"); return t}()), - // State: to.Ptr(armapimanagement.SubscriptionStateActive), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementGetUserSubscription.json -func ExampleUserSubscriptionClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapimanagement.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewUserSubscriptionClient().Get(ctx, "rg1", "apimService1", "1", "5fa9b096f3df14003c070001", 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.SubscriptionContract = armapimanagement.SubscriptionContract{ - // Name: to.Ptr("5fa9b096f3df14003c070001"), - // Type: to.Ptr("Microsoft.ApiManagement/service/users/subscriptions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1/subscriptions/5fa9b096f3df14003c070001"), - // Properties: &armapimanagement.SubscriptionContractProperties{ - // AllowTracing: to.Ptr(true), - // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-09T21:11:50.580Z"); return t}()), - // OwnerID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - // Scope: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/starter"), - // State: to.Ptr(armapimanagement.SubscriptionStateActive), - // }, - // } -} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspace_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspace_client.go new file mode 100644 index 000000000000..2528c6e7f502 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspace_client.go @@ -0,0 +1,477 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceClient contains the methods for the Workspace group. +// Don't use this type directly, use NewWorkspaceClient() instead. +type WorkspaceClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceClient creates a new instance of WorkspaceClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates a new workspace or updates an existing one. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - parameters - Create parameters. +// - options - WorkspaceClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceClient.CreateOrUpdate +// method. +func (client *WorkspaceClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, parameters WorkspaceContract, options *WorkspaceClientCreateOrUpdateOptions) (WorkspaceClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, parameters, options) + if err != nil { + return WorkspaceClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, parameters WorkspaceContract, options *WorkspaceClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceClientCreateOrUpdateResponse, error) { + result := WorkspaceClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceContract); err != nil { + return WorkspaceClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceClientDeleteOptions contains the optional parameters for the WorkspaceClient.Delete method. +func (client *WorkspaceClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, ifMatch string, options *WorkspaceClientDeleteOptions) (WorkspaceClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, ifMatch, options) + if err != nil { + return WorkspaceClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceClientDeleteResponse{}, err + } + return WorkspaceClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, ifMatch string, _ *WorkspaceClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the workspace specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceClientGetOptions contains the optional parameters for the WorkspaceClient.Get method. +func (client *WorkspaceClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceClientGetOptions) (WorkspaceClientGetResponse, error) { + var err error + const operationName = "WorkspaceClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + if err != nil { + return WorkspaceClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, _ *WorkspaceClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceClient) getHandleResponse(resp *http.Response) (WorkspaceClientGetResponse, error) { + result := WorkspaceClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceContract); err != nil { + return WorkspaceClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the workspace specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceClientGetEntityTagOptions contains the optional parameters for the WorkspaceClient.GetEntityTag method. +func (client *WorkspaceClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceClientGetEntityTagOptions) (WorkspaceClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + if err != nil { + return WorkspaceClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, _ *WorkspaceClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceClientGetEntityTagResponse, error) { + result := WorkspaceClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Lists all workspaces of the API Management service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - options - WorkspaceClientListByServiceOptions contains the optional parameters for the WorkspaceClient.NewListByServicePager +// method. +func (client *WorkspaceClient) NewListByServicePager(resourceGroupName string, serviceName string, options *WorkspaceClientListByServiceOptions) *runtime.Pager[WorkspaceClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceClientListByServiceResponse]{ + More: func(page WorkspaceClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceClientListByServiceResponse) (WorkspaceClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, nil) + if err != nil { + return WorkspaceClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *WorkspaceClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces" + 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.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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceClientListByServiceResponse, error) { + result := WorkspaceClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceCollection); err != nil { + return WorkspaceClientListByServiceResponse{}, err + } + return result, nil +} + +// Update - Updates the details of the workspace specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Workspace Update parameters. +// - options - WorkspaceClientUpdateOptions contains the optional parameters for the WorkspaceClient.Update method. +func (client *WorkspaceClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, ifMatch string, parameters WorkspaceContract, options *WorkspaceClientUpdateOptions) (WorkspaceClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, ifMatch, parameters, options) + if err != nil { + return WorkspaceClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, ifMatch string, parameters WorkspaceContract, _ *WorkspaceClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceClient) updateHandleResponse(resp *http.Response) (WorkspaceClientUpdateResponse, error) { + result := WorkspaceClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceContract); err != nil { + return WorkspaceClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapi_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapi_client.go new file mode 100644 index 000000000000..a1ba2df80d62 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapi_client.go @@ -0,0 +1,531 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceAPIClient contains the methods for the WorkspaceAPI group. +// Don't use this type directly, use NewWorkspaceAPIClient() instead. +type WorkspaceAPIClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPIClient creates a new instance of WorkspaceAPIClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPIClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPIClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPIClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates new or updates existing specified API of the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - parameters - Create or update parameters. +// - options - WorkspaceAPIClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIClient.BeginCreateOrUpdate +// method. +func (client *WorkspaceAPIClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, parameters APICreateOrUpdateParameter, options *WorkspaceAPIClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspaceAPIClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, workspaceID, apiID, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceAPIClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkspaceAPIClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates new or updates existing specified API of the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *WorkspaceAPIClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, parameters APICreateOrUpdateParameter, options *WorkspaceAPIClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WorkspaceAPIClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceAPIClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, parameters APICreateOrUpdateParameter, options *WorkspaceAPIClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Deletes the specified API of the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceAPIClientDeleteOptions contains the optional parameters for the WorkspaceAPIClient.Delete method. +func (client *WorkspaceAPIClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, ifMatch string, options *WorkspaceAPIClientDeleteOptions) (WorkspaceAPIClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceAPIClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, ifMatch, options) + if err != nil { + return WorkspaceAPIClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIClientDeleteResponse{}, err + } + return WorkspaceAPIClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceAPIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, ifMatch string, options *WorkspaceAPIClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.DeleteRevisions != nil { + reqQP.Set("deleteRevisions", strconv.FormatBool(*options.DeleteRevisions)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the API specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - options - WorkspaceAPIClientGetOptions contains the optional parameters for the WorkspaceAPIClient.Get method. +func (client *WorkspaceAPIClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIClientGetOptions) (WorkspaceAPIClientGetResponse, error) { + var err error + const operationName = "WorkspaceAPIClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, options) + if err != nil { + return WorkspaceAPIClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceAPIClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, _ *WorkspaceAPIClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceAPIClient) getHandleResponse(resp *http.Response) (WorkspaceAPIClientGetResponse, error) { + result := WorkspaceAPIClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIContract); err != nil { + return WorkspaceAPIClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the API specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - options - WorkspaceAPIClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIClient.GetEntityTag +// method. +func (client *WorkspaceAPIClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIClientGetEntityTagOptions) (WorkspaceAPIClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceAPIClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, options) + if err != nil { + return WorkspaceAPIClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceAPIClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, _ *WorkspaceAPIClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceAPIClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceAPIClientGetEntityTagResponse, error) { + result := WorkspaceAPIClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Lists all APIs of the workspace in an API Management service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIClientListByServiceOptions contains the optional parameters for the WorkspaceAPIClient.NewListByServicePager +// method. +func (client *WorkspaceAPIClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceAPIClientListByServiceOptions) *runtime.Pager[WorkspaceAPIClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceAPIClientListByServiceResponse]{ + More: func(page WorkspaceAPIClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceAPIClientListByServiceResponse) (WorkspaceAPIClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceAPIClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceAPIClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceAPIClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceAPIClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.ExpandAPIVersionSet != nil { + reqQP.Set("expandApiVersionSet", strconv.FormatBool(*options.ExpandAPIVersionSet)) + } + if options != nil && options.Tags != nil { + reqQP.Set("tags", *options.Tags) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceAPIClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceAPIClientListByServiceResponse, error) { + result := WorkspaceAPIClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APICollection); err != nil { + return WorkspaceAPIClientListByServiceResponse{}, err + } + return result, nil +} + +// Update - Updates the specified API of the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - API Update Contract parameters. +// - options - WorkspaceAPIClientUpdateOptions contains the optional parameters for the WorkspaceAPIClient.Update method. +func (client *WorkspaceAPIClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, ifMatch string, parameters APIUpdateContract, options *WorkspaceAPIClientUpdateOptions) (WorkspaceAPIClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, ifMatch, parameters, options) + if err != nil { + return WorkspaceAPIClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceAPIClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, ifMatch string, parameters APIUpdateContract, _ *WorkspaceAPIClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceAPIClient) updateHandleResponse(resp *http.Response) (WorkspaceAPIClientUpdateResponse, error) { + result := WorkspaceAPIClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIContract); err != nil { + return WorkspaceAPIClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapidiagnostic_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapidiagnostic_client.go new file mode 100644 index 000000000000..01d7bc70b2b2 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapidiagnostic_client.go @@ -0,0 +1,541 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceAPIDiagnosticClient contains the methods for the WorkspaceAPIDiagnostic group. +// Don't use this type directly, use NewWorkspaceAPIDiagnosticClient() instead. +type WorkspaceAPIDiagnosticClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPIDiagnosticClient creates a new instance of WorkspaceAPIDiagnosticClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPIDiagnosticClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPIDiagnosticClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPIDiagnosticClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates a new Diagnostic for an API or updates an existing one. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - parameters - Create parameters. +// - options - WorkspaceAPIDiagnosticClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.CreateOrUpdate +// method. +func (client *WorkspaceAPIDiagnosticClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, parameters DiagnosticContract, options *WorkspaceAPIDiagnosticClientCreateOrUpdateOptions) (WorkspaceAPIDiagnosticClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIDiagnosticClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, diagnosticID, parameters, options) + if err != nil { + return WorkspaceAPIDiagnosticClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIDiagnosticClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIDiagnosticClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceAPIDiagnosticClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, parameters DiagnosticContract, options *WorkspaceAPIDiagnosticClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceAPIDiagnosticClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceAPIDiagnosticClientCreateOrUpdateResponse, error) { + result := WorkspaceAPIDiagnosticClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticContract); err != nil { + return WorkspaceAPIDiagnosticClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified Diagnostic from an API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceAPIDiagnosticClientDeleteOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.Delete +// method. +func (client *WorkspaceAPIDiagnosticClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, ifMatch string, options *WorkspaceAPIDiagnosticClientDeleteOptions) (WorkspaceAPIDiagnosticClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceAPIDiagnosticClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, diagnosticID, ifMatch, options) + if err != nil { + return WorkspaceAPIDiagnosticClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIDiagnosticClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIDiagnosticClientDeleteResponse{}, err + } + return WorkspaceAPIDiagnosticClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceAPIDiagnosticClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, ifMatch string, _ *WorkspaceAPIDiagnosticClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the Diagnostic for an API specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIDiagnosticClientGetOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.Get +// method. +func (client *WorkspaceAPIDiagnosticClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, options *WorkspaceAPIDiagnosticClientGetOptions) (WorkspaceAPIDiagnosticClientGetResponse, error) { + var err error + const operationName = "WorkspaceAPIDiagnosticClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, diagnosticID, options) + if err != nil { + return WorkspaceAPIDiagnosticClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIDiagnosticClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIDiagnosticClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceAPIDiagnosticClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, _ *WorkspaceAPIDiagnosticClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceAPIDiagnosticClient) getHandleResponse(resp *http.Response) (WorkspaceAPIDiagnosticClientGetResponse, error) { + result := WorkspaceAPIDiagnosticClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticContract); err != nil { + return WorkspaceAPIDiagnosticClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the Diagnostic for an API specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIDiagnosticClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.GetEntityTag +// method. +func (client *WorkspaceAPIDiagnosticClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, options *WorkspaceAPIDiagnosticClientGetEntityTagOptions) (WorkspaceAPIDiagnosticClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceAPIDiagnosticClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, diagnosticID, options) + if err != nil { + return WorkspaceAPIDiagnosticClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIDiagnosticClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIDiagnosticClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceAPIDiagnosticClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, _ *WorkspaceAPIDiagnosticClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceAPIDiagnosticClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceAPIDiagnosticClientGetEntityTagResponse, error) { + result := WorkspaceAPIDiagnosticClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByWorkspacePager - Lists all diagnostics of an API. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIDiagnosticClientListByWorkspaceOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.NewListByWorkspacePager +// method. +func (client *WorkspaceAPIDiagnosticClient) NewListByWorkspacePager(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIDiagnosticClientListByWorkspaceOptions) *runtime.Pager[WorkspaceAPIDiagnosticClientListByWorkspaceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceAPIDiagnosticClientListByWorkspaceResponse]{ + More: func(page WorkspaceAPIDiagnosticClientListByWorkspaceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceAPIDiagnosticClientListByWorkspaceResponse) (WorkspaceAPIDiagnosticClientListByWorkspaceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceAPIDiagnosticClient.NewListByWorkspacePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByWorkspaceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, options) + }, nil) + if err != nil { + return WorkspaceAPIDiagnosticClientListByWorkspaceResponse{}, err + } + return client.listByWorkspaceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *WorkspaceAPIDiagnosticClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIDiagnosticClientListByWorkspaceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *WorkspaceAPIDiagnosticClient) listByWorkspaceHandleResponse(resp *http.Response) (WorkspaceAPIDiagnosticClientListByWorkspaceResponse, error) { + result := WorkspaceAPIDiagnosticClientListByWorkspaceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticCollection); err != nil { + return WorkspaceAPIDiagnosticClientListByWorkspaceResponse{}, err + } + return result, nil +} + +// Update - Updates the details of the Diagnostic for an API specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Diagnostic Update parameters. +// - options - WorkspaceAPIDiagnosticClientUpdateOptions contains the optional parameters for the WorkspaceAPIDiagnosticClient.Update +// method. +func (client *WorkspaceAPIDiagnosticClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, ifMatch string, parameters DiagnosticUpdateContract, options *WorkspaceAPIDiagnosticClientUpdateOptions) (WorkspaceAPIDiagnosticClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIDiagnosticClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, diagnosticID, ifMatch, parameters, options) + if err != nil { + return WorkspaceAPIDiagnosticClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIDiagnosticClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIDiagnosticClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceAPIDiagnosticClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, diagnosticID string, ifMatch string, parameters DiagnosticUpdateContract, _ *WorkspaceAPIDiagnosticClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceAPIDiagnosticClient) updateHandleResponse(resp *http.Response) (WorkspaceAPIDiagnosticClientUpdateResponse, error) { + result := WorkspaceAPIDiagnosticClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticContract); err != nil { + return WorkspaceAPIDiagnosticClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapiexport_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapiexport_client.go new file mode 100644 index 000000000000..fff7951e1670 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapiexport_client.go @@ -0,0 +1,121 @@ +// 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 armapimanagement + +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" +) + +// WorkspaceAPIExportClient contains the methods for the WorkspaceAPIExport group. +// Don't use this type directly, use NewWorkspaceAPIExportClient() instead. +type WorkspaceAPIExportClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPIExportClient creates a new instance of WorkspaceAPIExportClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPIExportClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPIExportClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPIExportClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets the details of the API specified by its identifier in the format specified to the Storage Blob with SAS Key +// valid for 5 minutes. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - formatParam - Format in which to export the Api Details to the Storage Blob with Sas Key valid for 5 minutes. +// - export - Query parameter required to export the API details. +// - options - WorkspaceAPIExportClientGetOptions contains the optional parameters for the WorkspaceAPIExportClient.Get method. +func (client *WorkspaceAPIExportClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, formatParam ExportFormat, export ExportAPI, options *WorkspaceAPIExportClientGetOptions) (WorkspaceAPIExportClientGetResponse, error) { + var err error + const operationName = "WorkspaceAPIExportClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, formatParam, export, options) + if err != nil { + return WorkspaceAPIExportClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIExportClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIExportClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceAPIExportClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, formatParam ExportFormat, export ExportAPI, _ *WorkspaceAPIExportClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + reqQP.Set("export", string(export)) + reqQP.Set("format", string(formatParam)) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceAPIExportClient) getHandleResponse(resp *http.Response) (WorkspaceAPIExportClientGetResponse, error) { + result := WorkspaceAPIExportClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APIExportResult); err != nil { + return WorkspaceAPIExportClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapioperation_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapioperation_client.go new file mode 100644 index 000000000000..3c8dcd1441ba --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapioperation_client.go @@ -0,0 +1,550 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceAPIOperationClient contains the methods for the WorkspaceAPIOperation group. +// Don't use this type directly, use NewWorkspaceAPIOperationClient() instead. +type WorkspaceAPIOperationClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPIOperationClient creates a new instance of WorkspaceAPIOperationClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPIOperationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPIOperationClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPIOperationClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates a new operation in the API or updates an existing one. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - parameters - Create parameters. +// - options - WorkspaceAPIOperationClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIOperationClient.CreateOrUpdate +// method. +func (client *WorkspaceAPIOperationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, parameters OperationContract, options *WorkspaceAPIOperationClientCreateOrUpdateOptions) (WorkspaceAPIOperationClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIOperationClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, parameters, options) + if err != nil { + return WorkspaceAPIOperationClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIOperationClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIOperationClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceAPIOperationClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, parameters OperationContract, options *WorkspaceAPIOperationClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceAPIOperationClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceAPIOperationClientCreateOrUpdateResponse, error) { + result := WorkspaceAPIOperationClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.OperationContract); err != nil { + return WorkspaceAPIOperationClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified operation in the API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceAPIOperationClientDeleteOptions contains the optional parameters for the WorkspaceAPIOperationClient.Delete +// method. +func (client *WorkspaceAPIOperationClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, ifMatch string, options *WorkspaceAPIOperationClientDeleteOptions) (WorkspaceAPIOperationClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceAPIOperationClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, ifMatch, options) + if err != nil { + return WorkspaceAPIOperationClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIOperationClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIOperationClientDeleteResponse{}, err + } + return WorkspaceAPIOperationClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceAPIOperationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, ifMatch string, _ *WorkspaceAPIOperationClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the API Operation specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIOperationClientGetOptions contains the optional parameters for the WorkspaceAPIOperationClient.Get +// method. +func (client *WorkspaceAPIOperationClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, options *WorkspaceAPIOperationClientGetOptions) (WorkspaceAPIOperationClientGetResponse, error) { + var err error + const operationName = "WorkspaceAPIOperationClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, options) + if err != nil { + return WorkspaceAPIOperationClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIOperationClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIOperationClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceAPIOperationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, _ *WorkspaceAPIOperationClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceAPIOperationClient) getHandleResponse(resp *http.Response) (WorkspaceAPIOperationClientGetResponse, error) { + result := WorkspaceAPIOperationClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.OperationContract); err != nil { + return WorkspaceAPIOperationClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the API operation specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIOperationClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIOperationClient.GetEntityTag +// method. +func (client *WorkspaceAPIOperationClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, options *WorkspaceAPIOperationClientGetEntityTagOptions) (WorkspaceAPIOperationClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceAPIOperationClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, options) + if err != nil { + return WorkspaceAPIOperationClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIOperationClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIOperationClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceAPIOperationClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, _ *WorkspaceAPIOperationClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceAPIOperationClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceAPIOperationClientGetEntityTagResponse, error) { + result := WorkspaceAPIOperationClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByAPIPager - Lists a collection of the operations for the specified API. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - options - WorkspaceAPIOperationClientListByAPIOptions contains the optional parameters for the WorkspaceAPIOperationClient.NewListByAPIPager +// method. +func (client *WorkspaceAPIOperationClient) NewListByAPIPager(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIOperationClientListByAPIOptions) *runtime.Pager[WorkspaceAPIOperationClientListByAPIResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceAPIOperationClientListByAPIResponse]{ + More: func(page WorkspaceAPIOperationClientListByAPIResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceAPIOperationClientListByAPIResponse) (WorkspaceAPIOperationClientListByAPIResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceAPIOperationClient.NewListByAPIPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByAPICreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, options) + }, nil) + if err != nil { + return WorkspaceAPIOperationClientListByAPIResponse{}, err + } + return client.listByAPIHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByAPICreateRequest creates the ListByAPI request. +func (client *WorkspaceAPIOperationClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIOperationClientListByAPIOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.Tags != nil { + reqQP.Set("tags", *options.Tags) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByAPIHandleResponse handles the ListByAPI response. +func (client *WorkspaceAPIOperationClient) listByAPIHandleResponse(resp *http.Response) (WorkspaceAPIOperationClientListByAPIResponse, error) { + result := WorkspaceAPIOperationClientListByAPIResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationCollection); err != nil { + return WorkspaceAPIOperationClientListByAPIResponse{}, err + } + return result, nil +} + +// Update - Updates the details of the operation in the API specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - API Operation Update parameters. +// - options - WorkspaceAPIOperationClientUpdateOptions contains the optional parameters for the WorkspaceAPIOperationClient.Update +// method. +func (client *WorkspaceAPIOperationClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, ifMatch string, parameters OperationUpdateContract, options *WorkspaceAPIOperationClientUpdateOptions) (WorkspaceAPIOperationClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIOperationClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, ifMatch, parameters, options) + if err != nil { + return WorkspaceAPIOperationClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIOperationClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIOperationClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceAPIOperationClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, ifMatch string, parameters OperationUpdateContract, _ *WorkspaceAPIOperationClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceAPIOperationClient) updateHandleResponse(resp *http.Response) (WorkspaceAPIOperationClientUpdateResponse, error) { + result := WorkspaceAPIOperationClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.OperationContract); err != nil { + return WorkspaceAPIOperationClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapioperationpolicy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapioperationpolicy_client.go new file mode 100644 index 000000000000..59b4d69107f5 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapioperationpolicy_client.go @@ -0,0 +1,474 @@ +// 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 armapimanagement + +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" +) + +// WorkspaceAPIOperationPolicyClient contains the methods for the WorkspaceAPIOperationPolicy group. +// Don't use this type directly, use NewWorkspaceAPIOperationPolicyClient() instead. +type WorkspaceAPIOperationPolicyClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPIOperationPolicyClient creates a new instance of WorkspaceAPIOperationPolicyClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPIOperationPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPIOperationPolicyClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPIOperationPolicyClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates policy configuration for the API Operation level. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - parameters - The policy contents to apply. +// - options - WorkspaceAPIOperationPolicyClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.CreateOrUpdate +// method. +func (client *WorkspaceAPIOperationPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID PolicyIDName, parameters PolicyContract, options *WorkspaceAPIOperationPolicyClientCreateOrUpdateOptions) (WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIOperationPolicyClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, policyID, parameters, options) + if err != nil { + return WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceAPIOperationPolicyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID PolicyIDName, parameters PolicyContract, options *WorkspaceAPIOperationPolicyClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceAPIOperationPolicyClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse, error) { + result := WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyContract); err != nil { + return WorkspaceAPIOperationPolicyClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the policy configuration at the Api Operation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceAPIOperationPolicyClientDeleteOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.Delete +// method. +func (client *WorkspaceAPIOperationPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID PolicyIDName, ifMatch string, options *WorkspaceAPIOperationPolicyClientDeleteOptions) (WorkspaceAPIOperationPolicyClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceAPIOperationPolicyClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, policyID, ifMatch, options) + if err != nil { + return WorkspaceAPIOperationPolicyClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIOperationPolicyClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIOperationPolicyClientDeleteResponse{}, err + } + return WorkspaceAPIOperationPolicyClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceAPIOperationPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID PolicyIDName, ifMatch string, _ *WorkspaceAPIOperationPolicyClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Get the policy configuration at the API Operation level. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - options - WorkspaceAPIOperationPolicyClientGetOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.Get +// method. +func (client *WorkspaceAPIOperationPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID PolicyIDName, options *WorkspaceAPIOperationPolicyClientGetOptions) (WorkspaceAPIOperationPolicyClientGetResponse, error) { + var err error + const operationName = "WorkspaceAPIOperationPolicyClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, policyID, options) + if err != nil { + return WorkspaceAPIOperationPolicyClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIOperationPolicyClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIOperationPolicyClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceAPIOperationPolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID PolicyIDName, options *WorkspaceAPIOperationPolicyClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.Format != nil { + reqQP.Set("format", string(*options.Format)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceAPIOperationPolicyClient) getHandleResponse(resp *http.Response) (WorkspaceAPIOperationPolicyClientGetResponse, error) { + result := WorkspaceAPIOperationPolicyClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyContract); err != nil { + return WorkspaceAPIOperationPolicyClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the API operation policy specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - options - WorkspaceAPIOperationPolicyClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.GetEntityTag +// method. +func (client *WorkspaceAPIOperationPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID PolicyIDName, options *WorkspaceAPIOperationPolicyClientGetEntityTagOptions) (WorkspaceAPIOperationPolicyClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceAPIOperationPolicyClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, policyID, options) + if err != nil { + return WorkspaceAPIOperationPolicyClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIOperationPolicyClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIOperationPolicyClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceAPIOperationPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, policyID PolicyIDName, _ *WorkspaceAPIOperationPolicyClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceAPIOperationPolicyClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceAPIOperationPolicyClientGetEntityTagResponse, error) { + result := WorkspaceAPIOperationPolicyClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByOperationPager - Get the list of policy configuration at the API Operation level. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - operationID - Operation identifier within an API. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIOperationPolicyClientListByOperationOptions contains the optional parameters for the WorkspaceAPIOperationPolicyClient.NewListByOperationPager +// method. +func (client *WorkspaceAPIOperationPolicyClient) NewListByOperationPager(resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, options *WorkspaceAPIOperationPolicyClientListByOperationOptions) *runtime.Pager[WorkspaceAPIOperationPolicyClientListByOperationResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceAPIOperationPolicyClientListByOperationResponse]{ + More: func(page WorkspaceAPIOperationPolicyClientListByOperationResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceAPIOperationPolicyClientListByOperationResponse) (WorkspaceAPIOperationPolicyClientListByOperationResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceAPIOperationPolicyClient.NewListByOperationPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByOperationCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, operationID, options) + }, nil) + if err != nil { + return WorkspaceAPIOperationPolicyClientListByOperationResponse{}, err + } + return client.listByOperationHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByOperationCreateRequest creates the ListByOperation request. +func (client *WorkspaceAPIOperationPolicyClient) listByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, operationID string, _ *WorkspaceAPIOperationPolicyClientListByOperationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByOperationHandleResponse handles the ListByOperation response. +func (client *WorkspaceAPIOperationPolicyClient) listByOperationHandleResponse(resp *http.Response) (WorkspaceAPIOperationPolicyClientListByOperationResponse, error) { + result := WorkspaceAPIOperationPolicyClientListByOperationResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyCollection); err != nil { + return WorkspaceAPIOperationPolicyClientListByOperationResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapipolicy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapipolicy_client.go new file mode 100644 index 000000000000..e87273169b6e --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapipolicy_client.go @@ -0,0 +1,448 @@ +// 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 armapimanagement + +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" +) + +// WorkspaceAPIPolicyClient contains the methods for the WorkspaceAPIPolicy group. +// Don't use this type directly, use NewWorkspaceAPIPolicyClient() instead. +type WorkspaceAPIPolicyClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPIPolicyClient creates a new instance of WorkspaceAPIPolicyClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPIPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPIPolicyClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPIPolicyClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates policy configuration for the API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - policyID - The identifier of the Policy. +// - parameters - The policy contents to apply. +// - options - WorkspaceAPIPolicyClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIPolicyClient.CreateOrUpdate +// method. +func (client *WorkspaceAPIPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID PolicyIDName, parameters PolicyContract, options *WorkspaceAPIPolicyClientCreateOrUpdateOptions) (WorkspaceAPIPolicyClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIPolicyClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, policyID, parameters, options) + if err != nil { + return WorkspaceAPIPolicyClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIPolicyClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIPolicyClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceAPIPolicyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID PolicyIDName, parameters PolicyContract, options *WorkspaceAPIPolicyClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceAPIPolicyClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceAPIPolicyClientCreateOrUpdateResponse, error) { + result := WorkspaceAPIPolicyClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyContract); err != nil { + return WorkspaceAPIPolicyClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the policy configuration at the Api. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - policyID - The identifier of the Policy. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceAPIPolicyClientDeleteOptions contains the optional parameters for the WorkspaceAPIPolicyClient.Delete +// method. +func (client *WorkspaceAPIPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID PolicyIDName, ifMatch string, options *WorkspaceAPIPolicyClientDeleteOptions) (WorkspaceAPIPolicyClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceAPIPolicyClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, policyID, ifMatch, options) + if err != nil { + return WorkspaceAPIPolicyClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIPolicyClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIPolicyClientDeleteResponse{}, err + } + return WorkspaceAPIPolicyClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceAPIPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID PolicyIDName, ifMatch string, _ *WorkspaceAPIPolicyClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Get the policy configuration at the API level. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - policyID - The identifier of the Policy. +// - options - WorkspaceAPIPolicyClientGetOptions contains the optional parameters for the WorkspaceAPIPolicyClient.Get method. +func (client *WorkspaceAPIPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID PolicyIDName, options *WorkspaceAPIPolicyClientGetOptions) (WorkspaceAPIPolicyClientGetResponse, error) { + var err error + const operationName = "WorkspaceAPIPolicyClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, policyID, options) + if err != nil { + return WorkspaceAPIPolicyClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIPolicyClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIPolicyClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceAPIPolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID PolicyIDName, options *WorkspaceAPIPolicyClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.Format != nil { + reqQP.Set("format", string(*options.Format)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceAPIPolicyClient) getHandleResponse(resp *http.Response) (WorkspaceAPIPolicyClientGetResponse, error) { + result := WorkspaceAPIPolicyClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyContract); err != nil { + return WorkspaceAPIPolicyClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the API policy specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - policyID - The identifier of the Policy. +// - options - WorkspaceAPIPolicyClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIPolicyClient.GetEntityTag +// method. +func (client *WorkspaceAPIPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID PolicyIDName, options *WorkspaceAPIPolicyClientGetEntityTagOptions) (WorkspaceAPIPolicyClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceAPIPolicyClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, policyID, options) + if err != nil { + return WorkspaceAPIPolicyClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIPolicyClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIPolicyClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceAPIPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, policyID PolicyIDName, _ *WorkspaceAPIPolicyClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceAPIPolicyClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceAPIPolicyClientGetEntityTagResponse, error) { + result := WorkspaceAPIPolicyClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByAPIPager - Get the policy configuration at the API level. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - options - WorkspaceAPIPolicyClientListByAPIOptions contains the optional parameters for the WorkspaceAPIPolicyClient.NewListByAPIPager +// method. +func (client *WorkspaceAPIPolicyClient) NewListByAPIPager(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIPolicyClientListByAPIOptions) *runtime.Pager[WorkspaceAPIPolicyClientListByAPIResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceAPIPolicyClientListByAPIResponse]{ + More: func(page WorkspaceAPIPolicyClientListByAPIResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceAPIPolicyClientListByAPIResponse) (WorkspaceAPIPolicyClientListByAPIResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceAPIPolicyClient.NewListByAPIPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByAPICreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, options) + }, nil) + if err != nil { + return WorkspaceAPIPolicyClientListByAPIResponse{}, err + } + return client.listByAPIHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByAPICreateRequest creates the ListByAPI request. +func (client *WorkspaceAPIPolicyClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, _ *WorkspaceAPIPolicyClientListByAPIOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByAPIHandleResponse handles the ListByAPI response. +func (client *WorkspaceAPIPolicyClient) listByAPIHandleResponse(resp *http.Response) (WorkspaceAPIPolicyClientListByAPIResponse, error) { + result := WorkspaceAPIPolicyClientListByAPIResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyCollection); err != nil { + return WorkspaceAPIPolicyClientListByAPIResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapirelease_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapirelease_client.go new file mode 100644 index 000000000000..2045736c18b1 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapirelease_client.go @@ -0,0 +1,542 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceAPIReleaseClient contains the methods for the WorkspaceAPIRelease group. +// Don't use this type directly, use NewWorkspaceAPIReleaseClient() instead. +type WorkspaceAPIReleaseClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPIReleaseClient creates a new instance of WorkspaceAPIReleaseClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPIReleaseClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPIReleaseClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPIReleaseClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates a new Release for the API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - releaseID - Release identifier within an API. Must be unique in the current API Management service instance. +// - parameters - Create parameters. +// - options - WorkspaceAPIReleaseClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIReleaseClient.CreateOrUpdate +// method. +func (client *WorkspaceAPIReleaseClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, parameters APIReleaseContract, options *WorkspaceAPIReleaseClientCreateOrUpdateOptions) (WorkspaceAPIReleaseClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIReleaseClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, releaseID, parameters, options) + if err != nil { + return WorkspaceAPIReleaseClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIReleaseClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIReleaseClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceAPIReleaseClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, parameters APIReleaseContract, options *WorkspaceAPIReleaseClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceAPIReleaseClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceAPIReleaseClientCreateOrUpdateResponse, error) { + result := WorkspaceAPIReleaseClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIReleaseContract); err != nil { + return WorkspaceAPIReleaseClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified release in the API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - releaseID - Release identifier within an API. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceAPIReleaseClientDeleteOptions contains the optional parameters for the WorkspaceAPIReleaseClient.Delete +// method. +func (client *WorkspaceAPIReleaseClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, ifMatch string, options *WorkspaceAPIReleaseClientDeleteOptions) (WorkspaceAPIReleaseClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceAPIReleaseClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, releaseID, ifMatch, options) + if err != nil { + return WorkspaceAPIReleaseClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIReleaseClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIReleaseClientDeleteResponse{}, err + } + return WorkspaceAPIReleaseClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceAPIReleaseClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, ifMatch string, _ *WorkspaceAPIReleaseClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Returns the details of an API release. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - releaseID - Release identifier within an API. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIReleaseClientGetOptions contains the optional parameters for the WorkspaceAPIReleaseClient.Get method. +func (client *WorkspaceAPIReleaseClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, options *WorkspaceAPIReleaseClientGetOptions) (WorkspaceAPIReleaseClientGetResponse, error) { + var err error + const operationName = "WorkspaceAPIReleaseClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, releaseID, options) + if err != nil { + return WorkspaceAPIReleaseClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIReleaseClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIReleaseClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceAPIReleaseClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, _ *WorkspaceAPIReleaseClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceAPIReleaseClient) getHandleResponse(resp *http.Response) (WorkspaceAPIReleaseClientGetResponse, error) { + result := WorkspaceAPIReleaseClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIReleaseContract); err != nil { + return WorkspaceAPIReleaseClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Returns the etag of an API release. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - releaseID - Release identifier within an API. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIReleaseClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIReleaseClient.GetEntityTag +// method. +func (client *WorkspaceAPIReleaseClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, options *WorkspaceAPIReleaseClientGetEntityTagOptions) (WorkspaceAPIReleaseClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceAPIReleaseClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, releaseID, options) + if err != nil { + return WorkspaceAPIReleaseClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIReleaseClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIReleaseClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceAPIReleaseClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, _ *WorkspaceAPIReleaseClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceAPIReleaseClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceAPIReleaseClientGetEntityTagResponse, error) { + result := WorkspaceAPIReleaseClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Lists all releases of an API. An API release is created when making an API Revision current. Releases +// are also used to rollback to previous revisions. Results will be paged and can be constrained by +// the $top and $skip parameters. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIReleaseClientListByServiceOptions contains the optional parameters for the WorkspaceAPIReleaseClient.NewListByServicePager +// method. +func (client *WorkspaceAPIReleaseClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIReleaseClientListByServiceOptions) *runtime.Pager[WorkspaceAPIReleaseClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceAPIReleaseClientListByServiceResponse]{ + More: func(page WorkspaceAPIReleaseClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceAPIReleaseClientListByServiceResponse) (WorkspaceAPIReleaseClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceAPIReleaseClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, options) + }, nil) + if err != nil { + return WorkspaceAPIReleaseClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceAPIReleaseClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIReleaseClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceAPIReleaseClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceAPIReleaseClientListByServiceResponse, error) { + result := WorkspaceAPIReleaseClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APIReleaseCollection); err != nil { + return WorkspaceAPIReleaseClientListByServiceResponse{}, err + } + return result, nil +} + +// Update - Updates the details of the release of the API specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - releaseID - Release identifier within an API. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - API Release Update parameters. +// - options - WorkspaceAPIReleaseClientUpdateOptions contains the optional parameters for the WorkspaceAPIReleaseClient.Update +// method. +func (client *WorkspaceAPIReleaseClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, ifMatch string, parameters APIReleaseContract, options *WorkspaceAPIReleaseClientUpdateOptions) (WorkspaceAPIReleaseClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIReleaseClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, releaseID, ifMatch, parameters, options) + if err != nil { + return WorkspaceAPIReleaseClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIReleaseClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIReleaseClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceAPIReleaseClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, releaseID string, ifMatch string, parameters APIReleaseContract, _ *WorkspaceAPIReleaseClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceAPIReleaseClient) updateHandleResponse(resp *http.Response) (WorkspaceAPIReleaseClientUpdateResponse, error) { + result := WorkspaceAPIReleaseClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIReleaseContract); err != nil { + return WorkspaceAPIReleaseClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapirevision_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapirevision_client.go new file mode 100644 index 000000000000..ee60aa393b47 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapirevision_client.go @@ -0,0 +1,126 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceAPIRevisionClient contains the methods for the WorkspaceAPIRevision group. +// Don't use this type directly, use NewWorkspaceAPIRevisionClient() instead. +type WorkspaceAPIRevisionClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPIRevisionClient creates a new instance of WorkspaceAPIRevisionClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPIRevisionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPIRevisionClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPIRevisionClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListByServicePager - Lists all revisions of an API. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIRevisionClientListByServiceOptions contains the optional parameters for the WorkspaceAPIRevisionClient.NewListByServicePager +// method. +func (client *WorkspaceAPIRevisionClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIRevisionClientListByServiceOptions) *runtime.Pager[WorkspaceAPIRevisionClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceAPIRevisionClientListByServiceResponse]{ + More: func(page WorkspaceAPIRevisionClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceAPIRevisionClientListByServiceResponse) (WorkspaceAPIRevisionClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceAPIRevisionClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, options) + }, nil) + if err != nil { + return WorkspaceAPIRevisionClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceAPIRevisionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPIRevisionClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/revisions" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceAPIRevisionClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceAPIRevisionClientListByServiceResponse, error) { + result := WorkspaceAPIRevisionClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APIRevisionCollection); err != nil { + return WorkspaceAPIRevisionClientListByServiceResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapischema_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapischema_client.go new file mode 100644 index 000000000000..9dcf88278346 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapischema_client.go @@ -0,0 +1,467 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceAPISchemaClient contains the methods for the WorkspaceAPISchema group. +// Don't use this type directly, use NewWorkspaceAPISchemaClient() instead. +type WorkspaceAPISchemaClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPISchemaClient creates a new instance of WorkspaceAPISchemaClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPISchemaClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPISchemaClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPISchemaClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates schema configuration for the API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - schemaID - Schema id identifier. Must be unique in the current API Management service instance. +// - parameters - The schema contents to apply. +// - options - WorkspaceAPISchemaClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPISchemaClient.BeginCreateOrUpdate +// method. +func (client *WorkspaceAPISchemaClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, parameters SchemaContract, options *WorkspaceAPISchemaClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspaceAPISchemaClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, workspaceID, apiID, schemaID, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceAPISchemaClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkspaceAPISchemaClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates or updates schema configuration for the API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *WorkspaceAPISchemaClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, parameters SchemaContract, options *WorkspaceAPISchemaClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WorkspaceAPISchemaClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, schemaID, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceAPISchemaClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, parameters SchemaContract, options *WorkspaceAPISchemaClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Deletes the schema configuration at the Api. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - schemaID - Schema id identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceAPISchemaClientDeleteOptions contains the optional parameters for the WorkspaceAPISchemaClient.Delete +// method. +func (client *WorkspaceAPISchemaClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, ifMatch string, options *WorkspaceAPISchemaClientDeleteOptions) (WorkspaceAPISchemaClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceAPISchemaClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, schemaID, ifMatch, options) + if err != nil { + return WorkspaceAPISchemaClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPISchemaClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPISchemaClientDeleteResponse{}, err + } + return WorkspaceAPISchemaClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceAPISchemaClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, ifMatch string, options *WorkspaceAPISchemaClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Get the schema configuration at the API level. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - schemaID - Schema id identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPISchemaClientGetOptions contains the optional parameters for the WorkspaceAPISchemaClient.Get method. +func (client *WorkspaceAPISchemaClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, options *WorkspaceAPISchemaClientGetOptions) (WorkspaceAPISchemaClientGetResponse, error) { + var err error + const operationName = "WorkspaceAPISchemaClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, schemaID, options) + if err != nil { + return WorkspaceAPISchemaClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPISchemaClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPISchemaClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceAPISchemaClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, _ *WorkspaceAPISchemaClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceAPISchemaClient) getHandleResponse(resp *http.Response) (WorkspaceAPISchemaClientGetResponse, error) { + result := WorkspaceAPISchemaClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.SchemaContract); err != nil { + return WorkspaceAPISchemaClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the schema specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - schemaID - Schema id identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPISchemaClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPISchemaClient.GetEntityTag +// method. +func (client *WorkspaceAPISchemaClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, options *WorkspaceAPISchemaClientGetEntityTagOptions) (WorkspaceAPISchemaClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceAPISchemaClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, schemaID, options) + if err != nil { + return WorkspaceAPISchemaClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPISchemaClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPISchemaClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceAPISchemaClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, schemaID string, _ *WorkspaceAPISchemaClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceAPISchemaClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceAPISchemaClientGetEntityTagResponse, error) { + result := WorkspaceAPISchemaClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByAPIPager - Get the schema configuration at the API level. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - apiID - API revision identifier. Must be unique in the current API Management service instance. Non-current revision has +// ;rev=n as a suffix where n is the revision number. +// - options - WorkspaceAPISchemaClientListByAPIOptions contains the optional parameters for the WorkspaceAPISchemaClient.NewListByAPIPager +// method. +func (client *WorkspaceAPISchemaClient) NewListByAPIPager(resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPISchemaClientListByAPIOptions) *runtime.Pager[WorkspaceAPISchemaClientListByAPIResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceAPISchemaClientListByAPIResponse]{ + More: func(page WorkspaceAPISchemaClientListByAPIResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceAPISchemaClientListByAPIResponse) (WorkspaceAPISchemaClientListByAPIResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceAPISchemaClient.NewListByAPIPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByAPICreateRequest(ctx, resourceGroupName, serviceName, workspaceID, apiID, options) + }, nil) + if err != nil { + return WorkspaceAPISchemaClientListByAPIResponse{}, err + } + return client.listByAPIHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByAPICreateRequest creates the ListByAPI request. +func (client *WorkspaceAPISchemaClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, apiID string, options *WorkspaceAPISchemaClientListByAPIOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByAPIHandleResponse handles the ListByAPI response. +func (client *WorkspaceAPISchemaClient) listByAPIHandleResponse(resp *http.Response) (WorkspaceAPISchemaClientListByAPIResponse, error) { + result := WorkspaceAPISchemaClientListByAPIResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SchemaCollection); err != nil { + return WorkspaceAPISchemaClientListByAPIResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapiversionset_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapiversionset_client.go new file mode 100644 index 000000000000..75dc9a34282c --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceapiversionset_client.go @@ -0,0 +1,511 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceAPIVersionSetClient contains the methods for the WorkspaceAPIVersionSet group. +// Don't use this type directly, use NewWorkspaceAPIVersionSetClient() instead. +type WorkspaceAPIVersionSetClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceAPIVersionSetClient creates a new instance of WorkspaceAPIVersionSetClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceAPIVersionSetClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAPIVersionSetClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceAPIVersionSetClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or Updates a Api Version Set. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - WorkspaceAPIVersionSetClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.CreateOrUpdate +// method. +func (client *WorkspaceAPIVersionSetClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, parameters APIVersionSetContract, options *WorkspaceAPIVersionSetClientCreateOrUpdateOptions) (WorkspaceAPIVersionSetClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIVersionSetClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, versionSetID, parameters, options) + if err != nil { + return WorkspaceAPIVersionSetClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIVersionSetClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIVersionSetClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceAPIVersionSetClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, parameters APIVersionSetContract, options *WorkspaceAPIVersionSetClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceAPIVersionSetClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceAPIVersionSetClientCreateOrUpdateResponse, error) { + result := WorkspaceAPIVersionSetClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIVersionSetContract); err != nil { + return WorkspaceAPIVersionSetClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes specific Api Version Set. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceAPIVersionSetClientDeleteOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.Delete +// method. +func (client *WorkspaceAPIVersionSetClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, ifMatch string, options *WorkspaceAPIVersionSetClientDeleteOptions) (WorkspaceAPIVersionSetClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceAPIVersionSetClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, versionSetID, ifMatch, options) + if err != nil { + return WorkspaceAPIVersionSetClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIVersionSetClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIVersionSetClientDeleteResponse{}, err + } + return WorkspaceAPIVersionSetClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceAPIVersionSetClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, ifMatch string, _ *WorkspaceAPIVersionSetClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the Api Version Set specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIVersionSetClientGetOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.Get +// method. +func (client *WorkspaceAPIVersionSetClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, options *WorkspaceAPIVersionSetClientGetOptions) (WorkspaceAPIVersionSetClientGetResponse, error) { + var err error + const operationName = "WorkspaceAPIVersionSetClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, versionSetID, options) + if err != nil { + return WorkspaceAPIVersionSetClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIVersionSetClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIVersionSetClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceAPIVersionSetClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, _ *WorkspaceAPIVersionSetClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceAPIVersionSetClient) getHandleResponse(resp *http.Response) (WorkspaceAPIVersionSetClientGetResponse, error) { + result := WorkspaceAPIVersionSetClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIVersionSetContract); err != nil { + return WorkspaceAPIVersionSetClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the Api Version Set specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIVersionSetClientGetEntityTagOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.GetEntityTag +// method. +func (client *WorkspaceAPIVersionSetClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, options *WorkspaceAPIVersionSetClientGetEntityTagOptions) (WorkspaceAPIVersionSetClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceAPIVersionSetClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, versionSetID, options) + if err != nil { + return WorkspaceAPIVersionSetClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIVersionSetClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIVersionSetClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceAPIVersionSetClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, _ *WorkspaceAPIVersionSetClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceAPIVersionSetClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceAPIVersionSetClientGetEntityTagResponse, error) { + result := WorkspaceAPIVersionSetClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Lists a collection of API Version Sets in the specified workspace with a service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceAPIVersionSetClientListByServiceOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.NewListByServicePager +// method. +func (client *WorkspaceAPIVersionSetClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceAPIVersionSetClientListByServiceOptions) *runtime.Pager[WorkspaceAPIVersionSetClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceAPIVersionSetClientListByServiceResponse]{ + More: func(page WorkspaceAPIVersionSetClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceAPIVersionSetClientListByServiceResponse) (WorkspaceAPIVersionSetClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceAPIVersionSetClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceAPIVersionSetClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceAPIVersionSetClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceAPIVersionSetClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceAPIVersionSetClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceAPIVersionSetClientListByServiceResponse, error) { + result := WorkspaceAPIVersionSetClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APIVersionSetCollection); err != nil { + return WorkspaceAPIVersionSetClientListByServiceResponse{}, err + } + return result, nil +} + +// Update - Updates the details of the Api VersionSet specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - versionSetID - Api Version Set identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Update parameters. +// - options - WorkspaceAPIVersionSetClientUpdateOptions contains the optional parameters for the WorkspaceAPIVersionSetClient.Update +// method. +func (client *WorkspaceAPIVersionSetClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, ifMatch string, parameters APIVersionSetUpdateParameters, options *WorkspaceAPIVersionSetClientUpdateOptions) (WorkspaceAPIVersionSetClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceAPIVersionSetClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, versionSetID, ifMatch, parameters, options) + if err != nil { + return WorkspaceAPIVersionSetClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceAPIVersionSetClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceAPIVersionSetClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceAPIVersionSetClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, versionSetID string, ifMatch string, parameters APIVersionSetUpdateParameters, _ *WorkspaceAPIVersionSetClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceAPIVersionSetClient) updateHandleResponse(resp *http.Response) (WorkspaceAPIVersionSetClientUpdateResponse, error) { + result := WorkspaceAPIVersionSetClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIVersionSetContract); err != nil { + return WorkspaceAPIVersionSetClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacebackend_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacebackend_client.go new file mode 100644 index 000000000000..19bccbbb7211 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacebackend_client.go @@ -0,0 +1,508 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceBackendClient contains the methods for the WorkspaceBackend group. +// Don't use this type directly, use NewWorkspaceBackendClient() instead. +type WorkspaceBackendClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceBackendClient creates a new instance of WorkspaceBackendClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceBackendClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceBackendClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceBackendClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or Updates a backend. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. +// - parameters - Create parameters. +// - options - WorkspaceBackendClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceBackendClient.CreateOrUpdate +// method. +func (client *WorkspaceBackendClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, parameters BackendContract, options *WorkspaceBackendClientCreateOrUpdateOptions) (WorkspaceBackendClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceBackendClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, backendID, parameters, options) + if err != nil { + return WorkspaceBackendClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceBackendClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceBackendClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceBackendClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, parameters BackendContract, options *WorkspaceBackendClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceBackendClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceBackendClientCreateOrUpdateResponse, error) { + result := WorkspaceBackendClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.BackendContract); err != nil { + return WorkspaceBackendClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified backend. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceBackendClientDeleteOptions contains the optional parameters for the WorkspaceBackendClient.Delete method. +func (client *WorkspaceBackendClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, ifMatch string, options *WorkspaceBackendClientDeleteOptions) (WorkspaceBackendClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceBackendClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, backendID, ifMatch, options) + if err != nil { + return WorkspaceBackendClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceBackendClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceBackendClientDeleteResponse{}, err + } + return WorkspaceBackendClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceBackendClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, ifMatch string, _ *WorkspaceBackendClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the backend specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. +// - options - WorkspaceBackendClientGetOptions contains the optional parameters for the WorkspaceBackendClient.Get method. +func (client *WorkspaceBackendClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, options *WorkspaceBackendClientGetOptions) (WorkspaceBackendClientGetResponse, error) { + var err error + const operationName = "WorkspaceBackendClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, backendID, options) + if err != nil { + return WorkspaceBackendClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceBackendClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceBackendClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceBackendClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, _ *WorkspaceBackendClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceBackendClient) getHandleResponse(resp *http.Response) (WorkspaceBackendClientGetResponse, error) { + result := WorkspaceBackendClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.BackendContract); err != nil { + return WorkspaceBackendClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the backend specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. +// - options - WorkspaceBackendClientGetEntityTagOptions contains the optional parameters for the WorkspaceBackendClient.GetEntityTag +// method. +func (client *WorkspaceBackendClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, options *WorkspaceBackendClientGetEntityTagOptions) (WorkspaceBackendClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceBackendClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, backendID, options) + if err != nil { + return WorkspaceBackendClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceBackendClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceBackendClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceBackendClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, _ *WorkspaceBackendClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceBackendClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceBackendClientGetEntityTagResponse, error) { + result := WorkspaceBackendClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByWorkspacePager - Lists a collection of backends in the specified workspace. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceBackendClientListByWorkspaceOptions contains the optional parameters for the WorkspaceBackendClient.NewListByWorkspacePager +// method. +func (client *WorkspaceBackendClient) NewListByWorkspacePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceBackendClientListByWorkspaceOptions) *runtime.Pager[WorkspaceBackendClientListByWorkspaceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceBackendClientListByWorkspaceResponse]{ + More: func(page WorkspaceBackendClientListByWorkspaceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceBackendClientListByWorkspaceResponse) (WorkspaceBackendClientListByWorkspaceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceBackendClient.NewListByWorkspacePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByWorkspaceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceBackendClientListByWorkspaceResponse{}, err + } + return client.listByWorkspaceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *WorkspaceBackendClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceBackendClientListByWorkspaceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *WorkspaceBackendClient) listByWorkspaceHandleResponse(resp *http.Response) (WorkspaceBackendClientListByWorkspaceResponse, error) { + result := WorkspaceBackendClientListByWorkspaceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BackendCollection); err != nil { + return WorkspaceBackendClientListByWorkspaceResponse{}, err + } + return result, nil +} + +// Update - Updates an existing backend. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - backendID - Identifier of the Backend entity. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Update parameters. +// - options - WorkspaceBackendClientUpdateOptions contains the optional parameters for the WorkspaceBackendClient.Update method. +func (client *WorkspaceBackendClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, ifMatch string, parameters BackendUpdateParameters, options *WorkspaceBackendClientUpdateOptions) (WorkspaceBackendClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceBackendClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, backendID, ifMatch, parameters, options) + if err != nil { + return WorkspaceBackendClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceBackendClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceBackendClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceBackendClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, backendID string, ifMatch string, parameters BackendUpdateParameters, _ *WorkspaceBackendClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceBackendClient) updateHandleResponse(resp *http.Response) (WorkspaceBackendClientUpdateResponse, error) { + result := WorkspaceBackendClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.BackendContract); err != nil { + return WorkspaceBackendClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacecertificate_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacecertificate_client.go new file mode 100644 index 000000000000..cab6e250da68 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacecertificate_client.go @@ -0,0 +1,507 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceCertificateClient contains the methods for the WorkspaceCertificate group. +// Don't use this type directly, use NewWorkspaceCertificateClient() instead. +type WorkspaceCertificateClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceCertificateClient creates a new instance of WorkspaceCertificateClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceCertificateClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceCertificateClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceCertificateClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates the certificate being used for authentication with the backend. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. +// - parameters - Create or Update parameters. +// - options - WorkspaceCertificateClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceCertificateClient.CreateOrUpdate +// method. +func (client *WorkspaceCertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, parameters CertificateCreateOrUpdateParameters, options *WorkspaceCertificateClientCreateOrUpdateOptions) (WorkspaceCertificateClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceCertificateClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, certificateID, parameters, options) + if err != nil { + return WorkspaceCertificateClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceCertificateClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceCertificateClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceCertificateClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, parameters CertificateCreateOrUpdateParameters, options *WorkspaceCertificateClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceCertificateClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceCertificateClientCreateOrUpdateResponse, error) { + result := WorkspaceCertificateClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.CertificateContract); err != nil { + return WorkspaceCertificateClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes specific certificate. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceCertificateClientDeleteOptions contains the optional parameters for the WorkspaceCertificateClient.Delete +// method. +func (client *WorkspaceCertificateClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, ifMatch string, options *WorkspaceCertificateClientDeleteOptions) (WorkspaceCertificateClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceCertificateClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, certificateID, ifMatch, options) + if err != nil { + return WorkspaceCertificateClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceCertificateClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceCertificateClientDeleteResponse{}, err + } + return WorkspaceCertificateClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceCertificateClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, ifMatch string, _ *WorkspaceCertificateClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the certificate specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. +// - options - WorkspaceCertificateClientGetOptions contains the optional parameters for the WorkspaceCertificateClient.Get +// method. +func (client *WorkspaceCertificateClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, options *WorkspaceCertificateClientGetOptions) (WorkspaceCertificateClientGetResponse, error) { + var err error + const operationName = "WorkspaceCertificateClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, certificateID, options) + if err != nil { + return WorkspaceCertificateClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceCertificateClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceCertificateClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceCertificateClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, _ *WorkspaceCertificateClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceCertificateClient) getHandleResponse(resp *http.Response) (WorkspaceCertificateClientGetResponse, error) { + result := WorkspaceCertificateClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.CertificateContract); err != nil { + return WorkspaceCertificateClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the certificate specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. +// - options - WorkspaceCertificateClientGetEntityTagOptions contains the optional parameters for the WorkspaceCertificateClient.GetEntityTag +// method. +func (client *WorkspaceCertificateClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, options *WorkspaceCertificateClientGetEntityTagOptions) (WorkspaceCertificateClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceCertificateClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, certificateID, options) + if err != nil { + return WorkspaceCertificateClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceCertificateClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceCertificateClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceCertificateClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, _ *WorkspaceCertificateClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceCertificateClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceCertificateClientGetEntityTagResponse, error) { + result := WorkspaceCertificateClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByWorkspacePager - Lists a collection of all certificates in the specified workspace. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceCertificateClientListByWorkspaceOptions contains the optional parameters for the WorkspaceCertificateClient.NewListByWorkspacePager +// method. +func (client *WorkspaceCertificateClient) NewListByWorkspacePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceCertificateClientListByWorkspaceOptions) *runtime.Pager[WorkspaceCertificateClientListByWorkspaceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceCertificateClientListByWorkspaceResponse]{ + More: func(page WorkspaceCertificateClientListByWorkspaceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceCertificateClientListByWorkspaceResponse) (WorkspaceCertificateClientListByWorkspaceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceCertificateClient.NewListByWorkspacePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByWorkspaceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceCertificateClientListByWorkspaceResponse{}, err + } + return client.listByWorkspaceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *WorkspaceCertificateClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceCertificateClientListByWorkspaceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.IsKeyVaultRefreshFailed != nil { + reqQP.Set("isKeyVaultRefreshFailed", strconv.FormatBool(*options.IsKeyVaultRefreshFailed)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *WorkspaceCertificateClient) listByWorkspaceHandleResponse(resp *http.Response) (WorkspaceCertificateClientListByWorkspaceResponse, error) { + result := WorkspaceCertificateClientListByWorkspaceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CertificateCollection); err != nil { + return WorkspaceCertificateClientListByWorkspaceResponse{}, err + } + return result, nil +} + +// RefreshSecret - From KeyVault, Refresh the certificate being used for authentication with the backend. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - certificateID - Identifier of the certificate entity. Must be unique in the current API Management service instance. +// - options - WorkspaceCertificateClientRefreshSecretOptions contains the optional parameters for the WorkspaceCertificateClient.RefreshSecret +// method. +func (client *WorkspaceCertificateClient) RefreshSecret(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, options *WorkspaceCertificateClientRefreshSecretOptions) (WorkspaceCertificateClientRefreshSecretResponse, error) { + var err error + const operationName = "WorkspaceCertificateClient.RefreshSecret" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.refreshSecretCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, certificateID, options) + if err != nil { + return WorkspaceCertificateClientRefreshSecretResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceCertificateClientRefreshSecretResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceCertificateClientRefreshSecretResponse{}, err + } + resp, err := client.refreshSecretHandleResponse(httpResp) + return resp, err +} + +// refreshSecretCreateRequest creates the RefreshSecret request. +func (client *WorkspaceCertificateClient) refreshSecretCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, certificateID string, _ *WorkspaceCertificateClientRefreshSecretOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}/refreshSecret" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// refreshSecretHandleResponse handles the RefreshSecret response. +func (client *WorkspaceCertificateClient) refreshSecretHandleResponse(resp *http.Response) (WorkspaceCertificateClientRefreshSecretResponse, error) { + result := WorkspaceCertificateClientRefreshSecretResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.CertificateContract); err != nil { + return WorkspaceCertificateClientRefreshSecretResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacediagnostic_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacediagnostic_client.go new file mode 100644 index 000000000000..660f38a135fe --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacediagnostic_client.go @@ -0,0 +1,510 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceDiagnosticClient contains the methods for the WorkspaceDiagnostic group. +// Don't use this type directly, use NewWorkspaceDiagnosticClient() instead. +type WorkspaceDiagnosticClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceDiagnosticClient creates a new instance of WorkspaceDiagnosticClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceDiagnosticClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceDiagnosticClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceDiagnosticClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates a new Diagnostic or updates an existing one. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - parameters - Create parameters. +// - options - WorkspaceDiagnosticClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceDiagnosticClient.CreateOrUpdate +// method. +func (client *WorkspaceDiagnosticClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, parameters DiagnosticContract, options *WorkspaceDiagnosticClientCreateOrUpdateOptions) (WorkspaceDiagnosticClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceDiagnosticClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, diagnosticID, parameters, options) + if err != nil { + return WorkspaceDiagnosticClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceDiagnosticClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceDiagnosticClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceDiagnosticClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, parameters DiagnosticContract, options *WorkspaceDiagnosticClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceDiagnosticClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceDiagnosticClientCreateOrUpdateResponse, error) { + result := WorkspaceDiagnosticClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticContract); err != nil { + return WorkspaceDiagnosticClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified Diagnostic. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceDiagnosticClientDeleteOptions contains the optional parameters for the WorkspaceDiagnosticClient.Delete +// method. +func (client *WorkspaceDiagnosticClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, ifMatch string, options *WorkspaceDiagnosticClientDeleteOptions) (WorkspaceDiagnosticClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceDiagnosticClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, diagnosticID, ifMatch, options) + if err != nil { + return WorkspaceDiagnosticClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceDiagnosticClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceDiagnosticClientDeleteResponse{}, err + } + return WorkspaceDiagnosticClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceDiagnosticClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, ifMatch string, _ *WorkspaceDiagnosticClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the Diagnostic specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceDiagnosticClientGetOptions contains the optional parameters for the WorkspaceDiagnosticClient.Get method. +func (client *WorkspaceDiagnosticClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, options *WorkspaceDiagnosticClientGetOptions) (WorkspaceDiagnosticClientGetResponse, error) { + var err error + const operationName = "WorkspaceDiagnosticClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, diagnosticID, options) + if err != nil { + return WorkspaceDiagnosticClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceDiagnosticClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceDiagnosticClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceDiagnosticClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, _ *WorkspaceDiagnosticClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceDiagnosticClient) getHandleResponse(resp *http.Response) (WorkspaceDiagnosticClientGetResponse, error) { + result := WorkspaceDiagnosticClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticContract); err != nil { + return WorkspaceDiagnosticClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the Diagnostic specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceDiagnosticClientGetEntityTagOptions contains the optional parameters for the WorkspaceDiagnosticClient.GetEntityTag +// method. +func (client *WorkspaceDiagnosticClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, options *WorkspaceDiagnosticClientGetEntityTagOptions) (WorkspaceDiagnosticClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceDiagnosticClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, diagnosticID, options) + if err != nil { + return WorkspaceDiagnosticClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceDiagnosticClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceDiagnosticClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceDiagnosticClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, _ *WorkspaceDiagnosticClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceDiagnosticClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceDiagnosticClientGetEntityTagResponse, error) { + result := WorkspaceDiagnosticClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByWorkspacePager - Lists all diagnostics in the specified workspace. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceDiagnosticClientListByWorkspaceOptions contains the optional parameters for the WorkspaceDiagnosticClient.NewListByWorkspacePager +// method. +func (client *WorkspaceDiagnosticClient) NewListByWorkspacePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceDiagnosticClientListByWorkspaceOptions) *runtime.Pager[WorkspaceDiagnosticClientListByWorkspaceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceDiagnosticClientListByWorkspaceResponse]{ + More: func(page WorkspaceDiagnosticClientListByWorkspaceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceDiagnosticClientListByWorkspaceResponse) (WorkspaceDiagnosticClientListByWorkspaceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceDiagnosticClient.NewListByWorkspacePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByWorkspaceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceDiagnosticClientListByWorkspaceResponse{}, err + } + return client.listByWorkspaceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *WorkspaceDiagnosticClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceDiagnosticClientListByWorkspaceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *WorkspaceDiagnosticClient) listByWorkspaceHandleResponse(resp *http.Response) (WorkspaceDiagnosticClientListByWorkspaceResponse, error) { + result := WorkspaceDiagnosticClientListByWorkspaceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticCollection); err != nil { + return WorkspaceDiagnosticClientListByWorkspaceResponse{}, err + } + return result, nil +} + +// Update - Updates the details of the Diagnostic specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - diagnosticID - Diagnostic identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Diagnostic Update parameters. +// - options - WorkspaceDiagnosticClientUpdateOptions contains the optional parameters for the WorkspaceDiagnosticClient.Update +// method. +func (client *WorkspaceDiagnosticClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, ifMatch string, parameters DiagnosticUpdateContract, options *WorkspaceDiagnosticClientUpdateOptions) (WorkspaceDiagnosticClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceDiagnosticClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, diagnosticID, ifMatch, parameters, options) + if err != nil { + return WorkspaceDiagnosticClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceDiagnosticClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceDiagnosticClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceDiagnosticClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, diagnosticID string, ifMatch string, parameters DiagnosticUpdateContract, _ *WorkspaceDiagnosticClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceDiagnosticClient) updateHandleResponse(resp *http.Response) (WorkspaceDiagnosticClientUpdateResponse, error) { + result := WorkspaceDiagnosticClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticContract); err != nil { + return WorkspaceDiagnosticClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceglobalschema_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceglobalschema_client.go new file mode 100644 index 000000000000..ec71d3f1af73 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceglobalschema_client.go @@ -0,0 +1,435 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceGlobalSchemaClient contains the methods for the WorkspaceGlobalSchema group. +// Don't use this type directly, use NewWorkspaceGlobalSchemaClient() instead. +type WorkspaceGlobalSchemaClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceGlobalSchemaClient creates a new instance of WorkspaceGlobalSchemaClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceGlobalSchemaClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceGlobalSchemaClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceGlobalSchemaClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates new or updates existing specified Schema of the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - schemaID - Schema id identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.BeginCreateOrUpdate +// method. +func (client *WorkspaceGlobalSchemaClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, parameters GlobalSchemaContract, options *WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspaceGlobalSchemaClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, workspaceID, schemaID, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceGlobalSchemaClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkspaceGlobalSchemaClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates new or updates existing specified Schema of the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *WorkspaceGlobalSchemaClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, parameters GlobalSchemaContract, options *WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WorkspaceGlobalSchemaClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, schemaID, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceGlobalSchemaClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, parameters GlobalSchemaContract, options *WorkspaceGlobalSchemaClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Deletes specific Schema. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - schemaID - Schema id identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceGlobalSchemaClientDeleteOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.Delete +// method. +func (client *WorkspaceGlobalSchemaClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, ifMatch string, options *WorkspaceGlobalSchemaClientDeleteOptions) (WorkspaceGlobalSchemaClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceGlobalSchemaClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, schemaID, ifMatch, options) + if err != nil { + return WorkspaceGlobalSchemaClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGlobalSchemaClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGlobalSchemaClientDeleteResponse{}, err + } + return WorkspaceGlobalSchemaClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceGlobalSchemaClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, ifMatch string, _ *WorkspaceGlobalSchemaClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the Schema specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - schemaID - Schema id identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGlobalSchemaClientGetOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.Get +// method. +func (client *WorkspaceGlobalSchemaClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, options *WorkspaceGlobalSchemaClientGetOptions) (WorkspaceGlobalSchemaClientGetResponse, error) { + var err error + const operationName = "WorkspaceGlobalSchemaClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, schemaID, options) + if err != nil { + return WorkspaceGlobalSchemaClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGlobalSchemaClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGlobalSchemaClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceGlobalSchemaClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, _ *WorkspaceGlobalSchemaClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceGlobalSchemaClient) getHandleResponse(resp *http.Response) (WorkspaceGlobalSchemaClientGetResponse, error) { + result := WorkspaceGlobalSchemaClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.GlobalSchemaContract); err != nil { + return WorkspaceGlobalSchemaClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the Schema specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - schemaID - Schema id identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGlobalSchemaClientGetEntityTagOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.GetEntityTag +// method. +func (client *WorkspaceGlobalSchemaClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, options *WorkspaceGlobalSchemaClientGetEntityTagOptions) (WorkspaceGlobalSchemaClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceGlobalSchemaClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, schemaID, options) + if err != nil { + return WorkspaceGlobalSchemaClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGlobalSchemaClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGlobalSchemaClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceGlobalSchemaClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, schemaID string, _ *WorkspaceGlobalSchemaClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceGlobalSchemaClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceGlobalSchemaClientGetEntityTagResponse, error) { + result := WorkspaceGlobalSchemaClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Lists a collection of schemas registered with workspace in a service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGlobalSchemaClientListByServiceOptions contains the optional parameters for the WorkspaceGlobalSchemaClient.NewListByServicePager +// method. +func (client *WorkspaceGlobalSchemaClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceGlobalSchemaClientListByServiceOptions) *runtime.Pager[WorkspaceGlobalSchemaClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceGlobalSchemaClientListByServiceResponse]{ + More: func(page WorkspaceGlobalSchemaClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceGlobalSchemaClientListByServiceResponse) (WorkspaceGlobalSchemaClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceGlobalSchemaClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceGlobalSchemaClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceGlobalSchemaClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceGlobalSchemaClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceGlobalSchemaClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceGlobalSchemaClientListByServiceResponse, error) { + result := WorkspaceGlobalSchemaClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GlobalSchemaCollection); err != nil { + return WorkspaceGlobalSchemaClientListByServiceResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacegroup_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacegroup_client.go new file mode 100644 index 000000000000..c554cefc6724 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacegroup_client.go @@ -0,0 +1,508 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceGroupClient contains the methods for the WorkspaceGroup group. +// Don't use this type directly, use NewWorkspaceGroupClient() instead. +type WorkspaceGroupClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceGroupClient creates a new instance of WorkspaceGroupClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceGroupClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceGroupClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or Updates a group. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - groupID - Group identifier. Must be unique in the current API Management service instance. +// - parameters - Create parameters. +// - options - WorkspaceGroupClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceGroupClient.CreateOrUpdate +// method. +func (client *WorkspaceGroupClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, parameters GroupCreateParameters, options *WorkspaceGroupClientCreateOrUpdateOptions) (WorkspaceGroupClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceGroupClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, groupID, parameters, options) + if err != nil { + return WorkspaceGroupClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGroupClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGroupClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceGroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, parameters GroupCreateParameters, options *WorkspaceGroupClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceGroupClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceGroupClientCreateOrUpdateResponse, error) { + result := WorkspaceGroupClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.GroupContract); err != nil { + return WorkspaceGroupClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes specific group of the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - groupID - Group identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceGroupClientDeleteOptions contains the optional parameters for the WorkspaceGroupClient.Delete method. +func (client *WorkspaceGroupClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, ifMatch string, options *WorkspaceGroupClientDeleteOptions) (WorkspaceGroupClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceGroupClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, groupID, ifMatch, options) + if err != nil { + return WorkspaceGroupClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGroupClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGroupClientDeleteResponse{}, err + } + return WorkspaceGroupClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceGroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, ifMatch string, _ *WorkspaceGroupClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the group specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - groupID - Group identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGroupClientGetOptions contains the optional parameters for the WorkspaceGroupClient.Get method. +func (client *WorkspaceGroupClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, options *WorkspaceGroupClientGetOptions) (WorkspaceGroupClientGetResponse, error) { + var err error + const operationName = "WorkspaceGroupClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, groupID, options) + if err != nil { + return WorkspaceGroupClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGroupClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGroupClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceGroupClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, _ *WorkspaceGroupClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceGroupClient) getHandleResponse(resp *http.Response) (WorkspaceGroupClientGetResponse, error) { + result := WorkspaceGroupClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.GroupContract); err != nil { + return WorkspaceGroupClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the group specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - groupID - Group identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGroupClientGetEntityTagOptions contains the optional parameters for the WorkspaceGroupClient.GetEntityTag +// method. +func (client *WorkspaceGroupClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, options *WorkspaceGroupClientGetEntityTagOptions) (WorkspaceGroupClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceGroupClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, groupID, options) + if err != nil { + return WorkspaceGroupClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGroupClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGroupClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceGroupClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, _ *WorkspaceGroupClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceGroupClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceGroupClientGetEntityTagResponse, error) { + result := WorkspaceGroupClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Lists a collection of groups defined within a workspace in a service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGroupClientListByServiceOptions contains the optional parameters for the WorkspaceGroupClient.NewListByServicePager +// method. +func (client *WorkspaceGroupClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceGroupClientListByServiceOptions) *runtime.Pager[WorkspaceGroupClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceGroupClientListByServiceResponse]{ + More: func(page WorkspaceGroupClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceGroupClientListByServiceResponse) (WorkspaceGroupClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceGroupClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceGroupClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceGroupClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceGroupClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceGroupClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceGroupClientListByServiceResponse, error) { + result := WorkspaceGroupClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GroupCollection); err != nil { + return WorkspaceGroupClientListByServiceResponse{}, err + } + return result, nil +} + +// Update - Updates the details of the group specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - groupID - Group identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Update parameters. +// - options - WorkspaceGroupClientUpdateOptions contains the optional parameters for the WorkspaceGroupClient.Update method. +func (client *WorkspaceGroupClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, ifMatch string, parameters GroupUpdateParameters, options *WorkspaceGroupClientUpdateOptions) (WorkspaceGroupClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceGroupClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, groupID, ifMatch, parameters, options) + if err != nil { + return WorkspaceGroupClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGroupClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGroupClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceGroupClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, ifMatch string, parameters GroupUpdateParameters, _ *WorkspaceGroupClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceGroupClient) updateHandleResponse(resp *http.Response) (WorkspaceGroupClientUpdateResponse, error) { + result := WorkspaceGroupClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.GroupContract); err != nil { + return WorkspaceGroupClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacegroupuser_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacegroupuser_client.go new file mode 100644 index 000000000000..abce313a4dd3 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacegroupuser_client.go @@ -0,0 +1,345 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceGroupUserClient contains the methods for the WorkspaceGroupUser group. +// Don't use this type directly, use NewWorkspaceGroupUserClient() instead. +type WorkspaceGroupUserClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceGroupUserClient creates a new instance of WorkspaceGroupUserClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceGroupUserClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceGroupUserClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceGroupUserClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CheckEntityExists - Checks that user entity specified by identifier is associated with the group entity. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - groupID - Group identifier. Must be unique in the current API Management service instance. +// - userID - User identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGroupUserClientCheckEntityExistsOptions contains the optional parameters for the WorkspaceGroupUserClient.CheckEntityExists +// method. +func (client *WorkspaceGroupUserClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, userID string, options *WorkspaceGroupUserClientCheckEntityExistsOptions) (WorkspaceGroupUserClientCheckEntityExistsResponse, error) { + var err error + const operationName = "WorkspaceGroupUserClient.CheckEntityExists" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkEntityExistsCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, groupID, userID, options) + if err != nil { + return WorkspaceGroupUserClientCheckEntityExistsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGroupUserClientCheckEntityExistsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent, http.StatusNotFound) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGroupUserClientCheckEntityExistsResponse{}, err + } + return WorkspaceGroupUserClientCheckEntityExistsResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// checkEntityExistsCreateRequest creates the CheckEntityExists request. +func (client *WorkspaceGroupUserClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, userID string, _ *WorkspaceGroupUserClientCheckEntityExistsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users/{userId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Create - Add existing user to existing group +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - groupID - Group identifier. Must be unique in the current API Management service instance. +// - userID - User identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGroupUserClientCreateOptions contains the optional parameters for the WorkspaceGroupUserClient.Create +// method. +func (client *WorkspaceGroupUserClient) Create(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, userID string, options *WorkspaceGroupUserClientCreateOptions) (WorkspaceGroupUserClientCreateResponse, error) { + var err error + const operationName = "WorkspaceGroupUserClient.Create" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, groupID, userID, options) + if err != nil { + return WorkspaceGroupUserClientCreateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGroupUserClientCreateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGroupUserClientCreateResponse{}, err + } + resp, err := client.createHandleResponse(httpResp) + return resp, err +} + +// createCreateRequest creates the Create request. +func (client *WorkspaceGroupUserClient) createCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, userID string, _ *WorkspaceGroupUserClientCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users/{userId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *WorkspaceGroupUserClient) createHandleResponse(resp *http.Response) (WorkspaceGroupUserClientCreateResponse, error) { + result := WorkspaceGroupUserClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.UserContract); err != nil { + return WorkspaceGroupUserClientCreateResponse{}, err + } + return result, nil +} + +// Delete - Remove existing user from existing group. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - groupID - Group identifier. Must be unique in the current API Management service instance. +// - userID - User identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGroupUserClientDeleteOptions contains the optional parameters for the WorkspaceGroupUserClient.Delete +// method. +func (client *WorkspaceGroupUserClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, userID string, options *WorkspaceGroupUserClientDeleteOptions) (WorkspaceGroupUserClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceGroupUserClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, groupID, userID, options) + if err != nil { + return WorkspaceGroupUserClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceGroupUserClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceGroupUserClientDeleteResponse{}, err + } + return WorkspaceGroupUserClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceGroupUserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, userID string, _ *WorkspaceGroupUserClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users/{userId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListPager - Lists a collection of user entities associated with the group. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - groupID - Group identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceGroupUserClientListOptions contains the optional parameters for the WorkspaceGroupUserClient.NewListPager +// method. +func (client *WorkspaceGroupUserClient) NewListPager(resourceGroupName string, serviceName string, workspaceID string, groupID string, options *WorkspaceGroupUserClientListOptions) *runtime.Pager[WorkspaceGroupUserClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceGroupUserClientListResponse]{ + More: func(page WorkspaceGroupUserClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceGroupUserClientListResponse) (WorkspaceGroupUserClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceGroupUserClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, groupID, options) + }, nil) + if err != nil { + return WorkspaceGroupUserClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *WorkspaceGroupUserClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, groupID string, options *WorkspaceGroupUserClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *WorkspaceGroupUserClient) listHandleResponse(resp *http.Response) (WorkspaceGroupUserClientListResponse, error) { + result := WorkspaceGroupUserClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.UserCollection); err != nil { + return WorkspaceGroupUserClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacelink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacelink_client.go new file mode 100644 index 000000000000..f0f704fa10f1 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacelink_client.go @@ -0,0 +1,110 @@ +// 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 armapimanagement + +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" +) + +// WorkspaceLinkClient contains the methods for the APIManagementWorkspaceLink group. +// Don't use this type directly, use NewWorkspaceLinkClient() instead. +type WorkspaceLinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceLinkClient creates a new instance of WorkspaceLinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceLinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceLinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceLinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets an API Management WorkspaceLink resource description. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceLinkClientGetOptions contains the optional parameters for the WorkspaceLinkClient.Get method. +func (client *WorkspaceLinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceLinkClientGetOptions) (WorkspaceLinkClientGetResponse, error) { + var err error + const operationName = "WorkspaceLinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + if err != nil { + return WorkspaceLinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceLinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceLinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceLinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, _ *WorkspaceLinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaceLinks/{workspaceId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceLinkClient) getHandleResponse(resp *http.Response) (WorkspaceLinkClientGetResponse, error) { + result := WorkspaceLinkClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceLinksResource); err != nil { + return WorkspaceLinkClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacelinks_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacelinks_client.go new file mode 100644 index 000000000000..58747ca72351 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacelinks_client.go @@ -0,0 +1,106 @@ +// 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 armapimanagement + +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" +) + +// WorkspaceLinksClient contains the methods for the APIManagementWorkspaceLinks group. +// Don't use this type directly, use NewWorkspaceLinksClient() instead. +type WorkspaceLinksClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceLinksClient creates a new instance of WorkspaceLinksClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceLinksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceLinksClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceLinksClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListByServicePager - List all API Management workspaceLinks for a service. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - options - WorkspaceLinksClientListByServiceOptions contains the optional parameters for the WorkspaceLinksClient.NewListByServicePager +// method. +func (client *WorkspaceLinksClient) NewListByServicePager(resourceGroupName string, serviceName string, options *WorkspaceLinksClientListByServiceOptions) *runtime.Pager[WorkspaceLinksClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceLinksClientListByServiceResponse]{ + More: func(page WorkspaceLinksClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceLinksClientListByServiceResponse) (WorkspaceLinksClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceLinksClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, nil) + if err != nil { + return WorkspaceLinksClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceLinksClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, _ *WorkspaceLinksClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaceLinks" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceLinksClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceLinksClientListByServiceResponse, error) { + result := WorkspaceLinksClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceLinksListResult); err != nil { + return WorkspaceLinksClientListByServiceResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacelogger_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacelogger_client.go new file mode 100644 index 000000000000..1a591ce56d13 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacelogger_client.go @@ -0,0 +1,508 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceLoggerClient contains the methods for the WorkspaceLogger group. +// Don't use this type directly, use NewWorkspaceLoggerClient() instead. +type WorkspaceLoggerClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceLoggerClient creates a new instance of WorkspaceLoggerClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceLoggerClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceLoggerClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceLoggerClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or Updates a logger. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - loggerID - Logger identifier. Must be unique in the API Management service instance. +// - parameters - Create parameters. +// - options - WorkspaceLoggerClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceLoggerClient.CreateOrUpdate +// method. +func (client *WorkspaceLoggerClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, parameters LoggerContract, options *WorkspaceLoggerClientCreateOrUpdateOptions) (WorkspaceLoggerClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceLoggerClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, loggerID, parameters, options) + if err != nil { + return WorkspaceLoggerClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceLoggerClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceLoggerClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceLoggerClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, parameters LoggerContract, options *WorkspaceLoggerClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceLoggerClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceLoggerClientCreateOrUpdateResponse, error) { + result := WorkspaceLoggerClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.LoggerContract); err != nil { + return WorkspaceLoggerClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified logger. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - loggerID - Logger identifier. Must be unique in the API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceLoggerClientDeleteOptions contains the optional parameters for the WorkspaceLoggerClient.Delete method. +func (client *WorkspaceLoggerClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, ifMatch string, options *WorkspaceLoggerClientDeleteOptions) (WorkspaceLoggerClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceLoggerClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, loggerID, ifMatch, options) + if err != nil { + return WorkspaceLoggerClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceLoggerClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceLoggerClientDeleteResponse{}, err + } + return WorkspaceLoggerClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceLoggerClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, ifMatch string, _ *WorkspaceLoggerClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the logger specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - loggerID - Logger identifier. Must be unique in the API Management service instance. +// - options - WorkspaceLoggerClientGetOptions contains the optional parameters for the WorkspaceLoggerClient.Get method. +func (client *WorkspaceLoggerClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, options *WorkspaceLoggerClientGetOptions) (WorkspaceLoggerClientGetResponse, error) { + var err error + const operationName = "WorkspaceLoggerClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, loggerID, options) + if err != nil { + return WorkspaceLoggerClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceLoggerClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceLoggerClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceLoggerClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, _ *WorkspaceLoggerClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceLoggerClient) getHandleResponse(resp *http.Response) (WorkspaceLoggerClientGetResponse, error) { + result := WorkspaceLoggerClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.LoggerContract); err != nil { + return WorkspaceLoggerClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the logger specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - loggerID - Logger identifier. Must be unique in the API Management service instance. +// - options - WorkspaceLoggerClientGetEntityTagOptions contains the optional parameters for the WorkspaceLoggerClient.GetEntityTag +// method. +func (client *WorkspaceLoggerClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, options *WorkspaceLoggerClientGetEntityTagOptions) (WorkspaceLoggerClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceLoggerClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, loggerID, options) + if err != nil { + return WorkspaceLoggerClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceLoggerClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceLoggerClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceLoggerClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, _ *WorkspaceLoggerClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceLoggerClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceLoggerClientGetEntityTagResponse, error) { + result := WorkspaceLoggerClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByWorkspacePager - Lists a collection of loggers in the specified workspace. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceLoggerClientListByWorkspaceOptions contains the optional parameters for the WorkspaceLoggerClient.NewListByWorkspacePager +// method. +func (client *WorkspaceLoggerClient) NewListByWorkspacePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceLoggerClientListByWorkspaceOptions) *runtime.Pager[WorkspaceLoggerClientListByWorkspaceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceLoggerClientListByWorkspaceResponse]{ + More: func(page WorkspaceLoggerClientListByWorkspaceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceLoggerClientListByWorkspaceResponse) (WorkspaceLoggerClientListByWorkspaceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceLoggerClient.NewListByWorkspacePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByWorkspaceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceLoggerClientListByWorkspaceResponse{}, err + } + return client.listByWorkspaceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByWorkspaceCreateRequest creates the ListByWorkspace request. +func (client *WorkspaceLoggerClient) listByWorkspaceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceLoggerClientListByWorkspaceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByWorkspaceHandleResponse handles the ListByWorkspace response. +func (client *WorkspaceLoggerClient) listByWorkspaceHandleResponse(resp *http.Response) (WorkspaceLoggerClientListByWorkspaceResponse, error) { + result := WorkspaceLoggerClientListByWorkspaceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LoggerCollection); err != nil { + return WorkspaceLoggerClientListByWorkspaceResponse{}, err + } + return result, nil +} + +// Update - Updates an existing logger. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - loggerID - Logger identifier. Must be unique in the API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Update parameters. +// - options - WorkspaceLoggerClientUpdateOptions contains the optional parameters for the WorkspaceLoggerClient.Update method. +func (client *WorkspaceLoggerClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, ifMatch string, parameters LoggerUpdateContract, options *WorkspaceLoggerClientUpdateOptions) (WorkspaceLoggerClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceLoggerClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, loggerID, ifMatch, parameters, options) + if err != nil { + return WorkspaceLoggerClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceLoggerClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceLoggerClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceLoggerClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, loggerID string, ifMatch string, parameters LoggerUpdateContract, _ *WorkspaceLoggerClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceLoggerClient) updateHandleResponse(resp *http.Response) (WorkspaceLoggerClientUpdateResponse, error) { + result := WorkspaceLoggerClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.LoggerContract); err != nil { + return WorkspaceLoggerClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacenamedvalue_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacenamedvalue_client.go new file mode 100644 index 000000000000..72620669e6c8 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacenamedvalue_client.go @@ -0,0 +1,696 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceNamedValueClient contains the methods for the WorkspaceNamedValue group. +// Don't use this type directly, use NewWorkspaceNamedValueClient() instead. +type WorkspaceNamedValueClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceNamedValueClient creates a new instance of WorkspaceNamedValueClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceNamedValueClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceNamedValueClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceNamedValueClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates named value. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - namedValueID - Identifier of the NamedValue. +// - parameters - Create parameters. +// - options - WorkspaceNamedValueClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspaceNamedValueClient.BeginCreateOrUpdate +// method. +func (client *WorkspaceNamedValueClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, parameters NamedValueCreateContract, options *WorkspaceNamedValueClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspaceNamedValueClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceNamedValueClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkspaceNamedValueClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates or updates named value. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *WorkspaceNamedValueClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, parameters NamedValueCreateContract, options *WorkspaceNamedValueClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WorkspaceNamedValueClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceNamedValueClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, parameters NamedValueCreateContract, options *WorkspaceNamedValueClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Deletes specific named value from the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - namedValueID - Identifier of the NamedValue. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceNamedValueClientDeleteOptions contains the optional parameters for the WorkspaceNamedValueClient.Delete +// method. +func (client *WorkspaceNamedValueClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, ifMatch string, options *WorkspaceNamedValueClientDeleteOptions) (WorkspaceNamedValueClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceNamedValueClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, ifMatch, options) + if err != nil { + return WorkspaceNamedValueClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNamedValueClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNamedValueClientDeleteResponse{}, err + } + return WorkspaceNamedValueClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceNamedValueClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, ifMatch string, _ *WorkspaceNamedValueClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the named value specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - namedValueID - Identifier of the NamedValue. +// - options - WorkspaceNamedValueClientGetOptions contains the optional parameters for the WorkspaceNamedValueClient.Get method. +func (client *WorkspaceNamedValueClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *WorkspaceNamedValueClientGetOptions) (WorkspaceNamedValueClientGetResponse, error) { + var err error + const operationName = "WorkspaceNamedValueClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, options) + if err != nil { + return WorkspaceNamedValueClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNamedValueClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNamedValueClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceNamedValueClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, _ *WorkspaceNamedValueClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceNamedValueClient) getHandleResponse(resp *http.Response) (WorkspaceNamedValueClientGetResponse, error) { + result := WorkspaceNamedValueClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.NamedValueContract); err != nil { + return WorkspaceNamedValueClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the named value specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - namedValueID - Identifier of the NamedValue. +// - options - WorkspaceNamedValueClientGetEntityTagOptions contains the optional parameters for the WorkspaceNamedValueClient.GetEntityTag +// method. +func (client *WorkspaceNamedValueClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *WorkspaceNamedValueClientGetEntityTagOptions) (WorkspaceNamedValueClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceNamedValueClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, options) + if err != nil { + return WorkspaceNamedValueClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNamedValueClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNamedValueClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceNamedValueClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, _ *WorkspaceNamedValueClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceNamedValueClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceNamedValueClientGetEntityTagResponse, error) { + result := WorkspaceNamedValueClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Lists a collection of named values defined within a workspace in a service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceNamedValueClientListByServiceOptions contains the optional parameters for the WorkspaceNamedValueClient.NewListByServicePager +// method. +func (client *WorkspaceNamedValueClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceNamedValueClientListByServiceOptions) *runtime.Pager[WorkspaceNamedValueClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceNamedValueClientListByServiceResponse]{ + More: func(page WorkspaceNamedValueClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceNamedValueClientListByServiceResponse) (WorkspaceNamedValueClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceNamedValueClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceNamedValueClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceNamedValueClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceNamedValueClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.IsKeyVaultRefreshFailed != nil { + reqQP.Set("isKeyVaultRefreshFailed", string(*options.IsKeyVaultRefreshFailed)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceNamedValueClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceNamedValueClientListByServiceResponse, error) { + result := WorkspaceNamedValueClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NamedValueCollection); err != nil { + return WorkspaceNamedValueClientListByServiceResponse{}, err + } + return result, nil +} + +// ListValue - Gets the secret of the named value specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - namedValueID - Identifier of the NamedValue. +// - options - WorkspaceNamedValueClientListValueOptions contains the optional parameters for the WorkspaceNamedValueClient.ListValue +// method. +func (client *WorkspaceNamedValueClient) ListValue(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *WorkspaceNamedValueClientListValueOptions) (WorkspaceNamedValueClientListValueResponse, error) { + var err error + const operationName = "WorkspaceNamedValueClient.ListValue" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listValueCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, options) + if err != nil { + return WorkspaceNamedValueClientListValueResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNamedValueClientListValueResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNamedValueClientListValueResponse{}, err + } + resp, err := client.listValueHandleResponse(httpResp) + return resp, err +} + +// listValueCreateRequest creates the ListValue request. +func (client *WorkspaceNamedValueClient) listValueCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, _ *WorkspaceNamedValueClientListValueOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}/listValue" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listValueHandleResponse handles the ListValue response. +func (client *WorkspaceNamedValueClient) listValueHandleResponse(resp *http.Response) (WorkspaceNamedValueClientListValueResponse, error) { + result := WorkspaceNamedValueClientListValueResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.NamedValueSecretContract); err != nil { + return WorkspaceNamedValueClientListValueResponse{}, err + } + return result, nil +} + +// BeginRefreshSecret - Refresh the secret of the named value specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - namedValueID - Identifier of the NamedValue. +// - options - WorkspaceNamedValueClientBeginRefreshSecretOptions contains the optional parameters for the WorkspaceNamedValueClient.BeginRefreshSecret +// method. +func (client *WorkspaceNamedValueClient) BeginRefreshSecret(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *WorkspaceNamedValueClientBeginRefreshSecretOptions) (*runtime.Poller[WorkspaceNamedValueClientRefreshSecretResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.refreshSecret(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceNamedValueClientRefreshSecretResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkspaceNamedValueClientRefreshSecretResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// RefreshSecret - Refresh the secret of the named value specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *WorkspaceNamedValueClient) refreshSecret(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *WorkspaceNamedValueClientBeginRefreshSecretOptions) (*http.Response, error) { + var err error + const operationName = "WorkspaceNamedValueClient.BeginRefreshSecret" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.refreshSecretCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// refreshSecretCreateRequest creates the RefreshSecret request. +func (client *WorkspaceNamedValueClient) refreshSecretCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, _ *WorkspaceNamedValueClientBeginRefreshSecretOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}/refreshSecret" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginUpdate - Updates the specific named value. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - namedValueID - Identifier of the NamedValue. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Update parameters. +// - options - WorkspaceNamedValueClientBeginUpdateOptions contains the optional parameters for the WorkspaceNamedValueClient.BeginUpdate +// method. +func (client *WorkspaceNamedValueClient) BeginUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, ifMatch string, parameters NamedValueUpdateParameters, options *WorkspaceNamedValueClientBeginUpdateOptions) (*runtime.Poller[WorkspaceNamedValueClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, ifMatch, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceNamedValueClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkspaceNamedValueClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Updates the specific named value. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *WorkspaceNamedValueClient) update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, ifMatch string, parameters NamedValueUpdateParameters, options *WorkspaceNamedValueClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WorkspaceNamedValueClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, namedValueID, ifMatch, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceNamedValueClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, ifMatch string, parameters NamedValueUpdateParameters, _ *WorkspaceNamedValueClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacenotification_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacenotification_client.go new file mode 100644 index 000000000000..81be3979fdba --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacenotification_client.go @@ -0,0 +1,271 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceNotificationClient contains the methods for the WorkspaceNotification group. +// Don't use this type directly, use NewWorkspaceNotificationClient() instead. +type WorkspaceNotificationClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceNotificationClient creates a new instance of WorkspaceNotificationClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceNotificationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceNotificationClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceNotificationClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create or Update API Management publisher notification for the workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - options - WorkspaceNotificationClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceNotificationClient.CreateOrUpdate +// method. +func (client *WorkspaceNotificationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, options *WorkspaceNotificationClientCreateOrUpdateOptions) (WorkspaceNotificationClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceNotificationClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, options) + if err != nil { + return WorkspaceNotificationClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceNotificationClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, options *WorkspaceNotificationClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceNotificationClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceNotificationClientCreateOrUpdateResponse, error) { + result := WorkspaceNotificationClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NotificationContract); err != nil { + return WorkspaceNotificationClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Get - Gets the details of the Notification specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - options - WorkspaceNotificationClientGetOptions contains the optional parameters for the WorkspaceNotificationClient.Get +// method. +func (client *WorkspaceNotificationClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, options *WorkspaceNotificationClientGetOptions) (WorkspaceNotificationClientGetResponse, error) { + var err error + const operationName = "WorkspaceNotificationClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, options) + if err != nil { + return WorkspaceNotificationClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceNotificationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, _ *WorkspaceNotificationClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceNotificationClient) getHandleResponse(resp *http.Response) (WorkspaceNotificationClientGetResponse, error) { + result := WorkspaceNotificationClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NotificationContract); err != nil { + return WorkspaceNotificationClientGetResponse{}, err + } + return result, nil +} + +// NewListByServicePager - Lists a collection of properties defined within a service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceNotificationClientListByServiceOptions contains the optional parameters for the WorkspaceNotificationClient.NewListByServicePager +// method. +func (client *WorkspaceNotificationClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceNotificationClientListByServiceOptions) *runtime.Pager[WorkspaceNotificationClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceNotificationClientListByServiceResponse]{ + More: func(page WorkspaceNotificationClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceNotificationClientListByServiceResponse) (WorkspaceNotificationClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceNotificationClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceNotificationClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceNotificationClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceNotificationClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceNotificationClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceNotificationClientListByServiceResponse, error) { + result := WorkspaceNotificationClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NotificationCollection); err != nil { + return WorkspaceNotificationClientListByServiceResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacenotificationrecipientemail_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacenotificationrecipientemail_client.go new file mode 100644 index 000000000000..5c26873c1943 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacenotificationrecipientemail_client.go @@ -0,0 +1,335 @@ +// 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 armapimanagement + +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" +) + +// WorkspaceNotificationRecipientEmailClient contains the methods for the WorkspaceNotificationRecipientEmail group. +// Don't use this type directly, use NewWorkspaceNotificationRecipientEmailClient() instead. +type WorkspaceNotificationRecipientEmailClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceNotificationRecipientEmailClient creates a new instance of WorkspaceNotificationRecipientEmailClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceNotificationRecipientEmailClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceNotificationRecipientEmailClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceNotificationRecipientEmailClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CheckEntityExists - Determine if Notification Recipient Email subscribed to the notification. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - email - Email identifier. +// - options - WorkspaceNotificationRecipientEmailClientCheckEntityExistsOptions contains the optional parameters for the WorkspaceNotificationRecipientEmailClient.CheckEntityExists +// method. +func (client *WorkspaceNotificationRecipientEmailClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, email string, options *WorkspaceNotificationRecipientEmailClientCheckEntityExistsOptions) (WorkspaceNotificationRecipientEmailClientCheckEntityExistsResponse, error) { + var err error + const operationName = "WorkspaceNotificationRecipientEmailClient.CheckEntityExists" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkEntityExistsCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, email, options) + if err != nil { + return WorkspaceNotificationRecipientEmailClientCheckEntityExistsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationRecipientEmailClientCheckEntityExistsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent, http.StatusNotFound) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationRecipientEmailClientCheckEntityExistsResponse{}, err + } + return WorkspaceNotificationRecipientEmailClientCheckEntityExistsResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// checkEntityExistsCreateRequest creates the CheckEntityExists request. +func (client *WorkspaceNotificationRecipientEmailClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, email string, _ *WorkspaceNotificationRecipientEmailClientCheckEntityExistsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails/{email}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if email == "" { + return nil, errors.New("parameter email cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{email}", url.PathEscape(email)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// CreateOrUpdate - Adds the Email address to the list of Recipients for the Notification. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - email - Email identifier. +// - options - WorkspaceNotificationRecipientEmailClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceNotificationRecipientEmailClient.CreateOrUpdate +// method. +func (client *WorkspaceNotificationRecipientEmailClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, email string, options *WorkspaceNotificationRecipientEmailClientCreateOrUpdateOptions) (WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceNotificationRecipientEmailClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, email, options) + if err != nil { + return WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceNotificationRecipientEmailClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, email string, _ *WorkspaceNotificationRecipientEmailClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails/{email}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if email == "" { + return nil, errors.New("parameter email cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{email}", url.PathEscape(email)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceNotificationRecipientEmailClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse, error) { + result := WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecipientEmailContract); err != nil { + return WorkspaceNotificationRecipientEmailClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Removes the email from the list of Notification. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - email - Email identifier. +// - options - WorkspaceNotificationRecipientEmailClientDeleteOptions contains the optional parameters for the WorkspaceNotificationRecipientEmailClient.Delete +// method. +func (client *WorkspaceNotificationRecipientEmailClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, email string, options *WorkspaceNotificationRecipientEmailClientDeleteOptions) (WorkspaceNotificationRecipientEmailClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceNotificationRecipientEmailClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, email, options) + if err != nil { + return WorkspaceNotificationRecipientEmailClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationRecipientEmailClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationRecipientEmailClientDeleteResponse{}, err + } + return WorkspaceNotificationRecipientEmailClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceNotificationRecipientEmailClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, email string, _ *WorkspaceNotificationRecipientEmailClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails/{email}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if email == "" { + return nil, errors.New("parameter email cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{email}", url.PathEscape(email)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// ListByNotification - Gets the list of the Notification Recipient Emails subscribed to a notification. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - options - WorkspaceNotificationRecipientEmailClientListByNotificationOptions contains the optional parameters for the WorkspaceNotificationRecipientEmailClient.ListByNotification +// method. +func (client *WorkspaceNotificationRecipientEmailClient) ListByNotification(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, options *WorkspaceNotificationRecipientEmailClientListByNotificationOptions) (WorkspaceNotificationRecipientEmailClientListByNotificationResponse, error) { + var err error + const operationName = "WorkspaceNotificationRecipientEmailClient.ListByNotification" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listByNotificationCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, options) + if err != nil { + return WorkspaceNotificationRecipientEmailClientListByNotificationResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationRecipientEmailClientListByNotificationResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationRecipientEmailClientListByNotificationResponse{}, err + } + resp, err := client.listByNotificationHandleResponse(httpResp) + return resp, err +} + +// listByNotificationCreateRequest creates the ListByNotification request. +func (client *WorkspaceNotificationRecipientEmailClient) listByNotificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, _ *WorkspaceNotificationRecipientEmailClientListByNotificationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByNotificationHandleResponse handles the ListByNotification response. +func (client *WorkspaceNotificationRecipientEmailClient) listByNotificationHandleResponse(resp *http.Response) (WorkspaceNotificationRecipientEmailClientListByNotificationResponse, error) { + result := WorkspaceNotificationRecipientEmailClientListByNotificationResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecipientEmailCollection); err != nil { + return WorkspaceNotificationRecipientEmailClientListByNotificationResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacenotificationrecipientuser_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacenotificationrecipientuser_client.go new file mode 100644 index 000000000000..b463d2ec96b5 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacenotificationrecipientuser_client.go @@ -0,0 +1,335 @@ +// 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 armapimanagement + +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" +) + +// WorkspaceNotificationRecipientUserClient contains the methods for the WorkspaceNotificationRecipientUser group. +// Don't use this type directly, use NewWorkspaceNotificationRecipientUserClient() instead. +type WorkspaceNotificationRecipientUserClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceNotificationRecipientUserClient creates a new instance of WorkspaceNotificationRecipientUserClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceNotificationRecipientUserClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceNotificationRecipientUserClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceNotificationRecipientUserClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CheckEntityExists - Determine if the Notification Recipient User is subscribed to the notification. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - userID - User identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceNotificationRecipientUserClientCheckEntityExistsOptions contains the optional parameters for the WorkspaceNotificationRecipientUserClient.CheckEntityExists +// method. +func (client *WorkspaceNotificationRecipientUserClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, userID string, options *WorkspaceNotificationRecipientUserClientCheckEntityExistsOptions) (WorkspaceNotificationRecipientUserClientCheckEntityExistsResponse, error) { + var err error + const operationName = "WorkspaceNotificationRecipientUserClient.CheckEntityExists" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkEntityExistsCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, userID, options) + if err != nil { + return WorkspaceNotificationRecipientUserClientCheckEntityExistsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationRecipientUserClientCheckEntityExistsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent, http.StatusNotFound) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationRecipientUserClientCheckEntityExistsResponse{}, err + } + return WorkspaceNotificationRecipientUserClientCheckEntityExistsResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// checkEntityExistsCreateRequest creates the CheckEntityExists request. +func (client *WorkspaceNotificationRecipientUserClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, userID string, _ *WorkspaceNotificationRecipientUserClientCheckEntityExistsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers/{userId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// CreateOrUpdate - Adds the API Management User to the list of Recipients for the Notification. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - userID - User identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceNotificationRecipientUserClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceNotificationRecipientUserClient.CreateOrUpdate +// method. +func (client *WorkspaceNotificationRecipientUserClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, userID string, options *WorkspaceNotificationRecipientUserClientCreateOrUpdateOptions) (WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceNotificationRecipientUserClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, userID, options) + if err != nil { + return WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceNotificationRecipientUserClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, userID string, _ *WorkspaceNotificationRecipientUserClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers/{userId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceNotificationRecipientUserClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse, error) { + result := WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecipientUserContract); err != nil { + return WorkspaceNotificationRecipientUserClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Removes the API Management user from the list of Notification. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - userID - User identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceNotificationRecipientUserClientDeleteOptions contains the optional parameters for the WorkspaceNotificationRecipientUserClient.Delete +// method. +func (client *WorkspaceNotificationRecipientUserClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, userID string, options *WorkspaceNotificationRecipientUserClientDeleteOptions) (WorkspaceNotificationRecipientUserClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceNotificationRecipientUserClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, userID, options) + if err != nil { + return WorkspaceNotificationRecipientUserClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationRecipientUserClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationRecipientUserClientDeleteResponse{}, err + } + return WorkspaceNotificationRecipientUserClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceNotificationRecipientUserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, userID string, _ *WorkspaceNotificationRecipientUserClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers/{userId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// ListByNotification - Gets the list of the Notification Recipient User subscribed to the notification. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - notificationName - Notification Name Identifier. +// - options - WorkspaceNotificationRecipientUserClientListByNotificationOptions contains the optional parameters for the WorkspaceNotificationRecipientUserClient.ListByNotification +// method. +func (client *WorkspaceNotificationRecipientUserClient) ListByNotification(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, options *WorkspaceNotificationRecipientUserClientListByNotificationOptions) (WorkspaceNotificationRecipientUserClientListByNotificationResponse, error) { + var err error + const operationName = "WorkspaceNotificationRecipientUserClient.ListByNotification" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listByNotificationCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, notificationName, options) + if err != nil { + return WorkspaceNotificationRecipientUserClientListByNotificationResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceNotificationRecipientUserClientListByNotificationResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceNotificationRecipientUserClientListByNotificationResponse{}, err + } + resp, err := client.listByNotificationHandleResponse(httpResp) + return resp, err +} + +// listByNotificationCreateRequest creates the ListByNotification request. +func (client *WorkspaceNotificationRecipientUserClient) listByNotificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, notificationName NotificationName, _ *WorkspaceNotificationRecipientUserClientListByNotificationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByNotificationHandleResponse handles the ListByNotification response. +func (client *WorkspaceNotificationRecipientUserClient) listByNotificationHandleResponse(resp *http.Response) (WorkspaceNotificationRecipientUserClientListByNotificationResponse, error) { + result := WorkspaceNotificationRecipientUserClientListByNotificationResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecipientUserCollection); err != nil { + return WorkspaceNotificationRecipientUserClientListByNotificationResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacepolicy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacepolicy_client.go new file mode 100644 index 000000000000..34d56f7d9973 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacepolicy_client.go @@ -0,0 +1,417 @@ +// 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 armapimanagement + +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" +) + +// WorkspacePolicyClient contains the methods for the WorkspacePolicy group. +// Don't use this type directly, use NewWorkspacePolicyClient() instead. +type WorkspacePolicyClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspacePolicyClient creates a new instance of WorkspacePolicyClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspacePolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspacePolicyClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspacePolicyClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates policy configuration for the workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - parameters - The policy contents to apply. +// - options - WorkspacePolicyClientCreateOrUpdateOptions contains the optional parameters for the WorkspacePolicyClient.CreateOrUpdate +// method. +func (client *WorkspacePolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID PolicyIDName, parameters PolicyContract, options *WorkspacePolicyClientCreateOrUpdateOptions) (WorkspacePolicyClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspacePolicyClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, policyID, parameters, options) + if err != nil { + return WorkspacePolicyClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacePolicyClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspacePolicyClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspacePolicyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID PolicyIDName, parameters PolicyContract, options *WorkspacePolicyClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspacePolicyClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspacePolicyClientCreateOrUpdateResponse, error) { + result := WorkspacePolicyClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyContract); err != nil { + return WorkspacePolicyClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the policy configuration at the workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspacePolicyClientDeleteOptions contains the optional parameters for the WorkspacePolicyClient.Delete method. +func (client *WorkspacePolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID PolicyIDName, ifMatch string, options *WorkspacePolicyClientDeleteOptions) (WorkspacePolicyClientDeleteResponse, error) { + var err error + const operationName = "WorkspacePolicyClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, policyID, ifMatch, options) + if err != nil { + return WorkspacePolicyClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacePolicyClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspacePolicyClientDeleteResponse{}, err + } + return WorkspacePolicyClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspacePolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID PolicyIDName, ifMatch string, _ *WorkspacePolicyClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Get the policy configuration at the API level. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - options - WorkspacePolicyClientGetOptions contains the optional parameters for the WorkspacePolicyClient.Get method. +func (client *WorkspacePolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID PolicyIDName, options *WorkspacePolicyClientGetOptions) (WorkspacePolicyClientGetResponse, error) { + var err error + const operationName = "WorkspacePolicyClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, policyID, options) + if err != nil { + return WorkspacePolicyClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacePolicyClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacePolicyClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspacePolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID PolicyIDName, options *WorkspacePolicyClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.Format != nil { + reqQP.Set("format", string(*options.Format)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspacePolicyClient) getHandleResponse(resp *http.Response) (WorkspacePolicyClientGetResponse, error) { + result := WorkspacePolicyClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyContract); err != nil { + return WorkspacePolicyClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the workspace policy specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - options - WorkspacePolicyClientGetEntityTagOptions contains the optional parameters for the WorkspacePolicyClient.GetEntityTag +// method. +func (client *WorkspacePolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID PolicyIDName, options *WorkspacePolicyClientGetEntityTagOptions) (WorkspacePolicyClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspacePolicyClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, policyID, options) + if err != nil { + return WorkspacePolicyClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacePolicyClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacePolicyClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspacePolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, policyID PolicyIDName, _ *WorkspacePolicyClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspacePolicyClient) getEntityTagHandleResponse(resp *http.Response) (WorkspacePolicyClientGetEntityTagResponse, error) { + result := WorkspacePolicyClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByAPIPager - Get the policy configuration at the workspace level. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspacePolicyClientListByAPIOptions contains the optional parameters for the WorkspacePolicyClient.NewListByAPIPager +// method. +func (client *WorkspacePolicyClient) NewListByAPIPager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspacePolicyClientListByAPIOptions) *runtime.Pager[WorkspacePolicyClientListByAPIResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspacePolicyClientListByAPIResponse]{ + More: func(page WorkspacePolicyClientListByAPIResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspacePolicyClientListByAPIResponse) (WorkspacePolicyClientListByAPIResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspacePolicyClient.NewListByAPIPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByAPICreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspacePolicyClientListByAPIResponse{}, err + } + return client.listByAPIHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByAPICreateRequest creates the ListByAPI request. +func (client *WorkspacePolicyClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, _ *WorkspacePolicyClientListByAPIOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByAPIHandleResponse handles the ListByAPI response. +func (client *WorkspacePolicyClient) listByAPIHandleResponse(resp *http.Response) (WorkspacePolicyClientListByAPIResponse, error) { + result := WorkspacePolicyClientListByAPIResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyCollection); err != nil { + return WorkspacePolicyClientListByAPIResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacepolicyfragment_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacepolicyfragment_client.go new file mode 100644 index 000000000000..071cef9b3e83 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacepolicyfragment_client.go @@ -0,0 +1,522 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspacePolicyFragmentClient contains the methods for the WorkspacePolicyFragment group. +// Don't use this type directly, use NewWorkspacePolicyFragmentClient() instead. +type WorkspacePolicyFragmentClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspacePolicyFragmentClient creates a new instance of WorkspacePolicyFragmentClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspacePolicyFragmentClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspacePolicyFragmentClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspacePolicyFragmentClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a policy fragment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - id - A resource identifier. +// - parameters - The policy fragment contents to apply. +// - options - WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspacePolicyFragmentClient.BeginCreateOrUpdate +// method. +func (client *WorkspacePolicyFragmentClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, parameters PolicyFragmentContract, options *WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspacePolicyFragmentClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, workspaceID, id, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspacePolicyFragmentClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkspacePolicyFragmentClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates or updates a policy fragment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +func (client *WorkspacePolicyFragmentClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, parameters PolicyFragmentContract, options *WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WorkspacePolicyFragmentClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, id, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspacePolicyFragmentClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, parameters PolicyFragmentContract, options *WorkspacePolicyFragmentClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Deletes a policy fragment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - id - A resource identifier. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspacePolicyFragmentClientDeleteOptions contains the optional parameters for the WorkspacePolicyFragmentClient.Delete +// method. +func (client *WorkspacePolicyFragmentClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, ifMatch string, options *WorkspacePolicyFragmentClientDeleteOptions) (WorkspacePolicyFragmentClientDeleteResponse, error) { + var err error + const operationName = "WorkspacePolicyFragmentClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, id, ifMatch, options) + if err != nil { + return WorkspacePolicyFragmentClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacePolicyFragmentClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspacePolicyFragmentClientDeleteResponse{}, err + } + return WorkspacePolicyFragmentClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspacePolicyFragmentClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, ifMatch string, _ *WorkspacePolicyFragmentClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets a policy fragment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - id - A resource identifier. +// - options - WorkspacePolicyFragmentClientGetOptions contains the optional parameters for the WorkspacePolicyFragmentClient.Get +// method. +func (client *WorkspacePolicyFragmentClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, options *WorkspacePolicyFragmentClientGetOptions) (WorkspacePolicyFragmentClientGetResponse, error) { + var err error + const operationName = "WorkspacePolicyFragmentClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, id, options) + if err != nil { + return WorkspacePolicyFragmentClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacePolicyFragmentClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacePolicyFragmentClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspacePolicyFragmentClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, options *WorkspacePolicyFragmentClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.Format != nil { + reqQP.Set("format", string(*options.Format)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspacePolicyFragmentClient) getHandleResponse(resp *http.Response) (WorkspacePolicyFragmentClientGetResponse, error) { + result := WorkspacePolicyFragmentClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyFragmentContract); err != nil { + return WorkspacePolicyFragmentClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of a policy fragment. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - id - A resource identifier. +// - options - WorkspacePolicyFragmentClientGetEntityTagOptions contains the optional parameters for the WorkspacePolicyFragmentClient.GetEntityTag +// method. +func (client *WorkspacePolicyFragmentClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, options *WorkspacePolicyFragmentClientGetEntityTagOptions) (WorkspacePolicyFragmentClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspacePolicyFragmentClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, id, options) + if err != nil { + return WorkspacePolicyFragmentClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacePolicyFragmentClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacePolicyFragmentClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspacePolicyFragmentClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, _ *WorkspacePolicyFragmentClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspacePolicyFragmentClient) getEntityTagHandleResponse(resp *http.Response) (WorkspacePolicyFragmentClientGetEntityTagResponse, error) { + result := WorkspacePolicyFragmentClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Gets all policy fragments defined within a workspace. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspacePolicyFragmentClientListByServiceOptions contains the optional parameters for the WorkspacePolicyFragmentClient.NewListByServicePager +// method. +func (client *WorkspacePolicyFragmentClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspacePolicyFragmentClientListByServiceOptions) *runtime.Pager[WorkspacePolicyFragmentClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspacePolicyFragmentClientListByServiceResponse]{ + More: func(page WorkspacePolicyFragmentClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspacePolicyFragmentClientListByServiceResponse) (WorkspacePolicyFragmentClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspacePolicyFragmentClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspacePolicyFragmentClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspacePolicyFragmentClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspacePolicyFragmentClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspacePolicyFragmentClient) listByServiceHandleResponse(resp *http.Response) (WorkspacePolicyFragmentClientListByServiceResponse, error) { + result := WorkspacePolicyFragmentClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyFragmentCollection); err != nil { + return WorkspacePolicyFragmentClientListByServiceResponse{}, err + } + return result, nil +} + +// ListReferences - Lists policy resources that reference the policy fragment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - id - A resource identifier. +// - options - WorkspacePolicyFragmentClientListReferencesOptions contains the optional parameters for the WorkspacePolicyFragmentClient.ListReferences +// method. +func (client *WorkspacePolicyFragmentClient) ListReferences(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, options *WorkspacePolicyFragmentClientListReferencesOptions) (WorkspacePolicyFragmentClientListReferencesResponse, error) { + var err error + const operationName = "WorkspacePolicyFragmentClient.ListReferences" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listReferencesCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, id, options) + if err != nil { + return WorkspacePolicyFragmentClientListReferencesResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacePolicyFragmentClientListReferencesResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacePolicyFragmentClientListReferencesResponse{}, err + } + resp, err := client.listReferencesHandleResponse(httpResp) + return resp, err +} + +// listReferencesCreateRequest creates the ListReferences request. +func (client *WorkspacePolicyFragmentClient) listReferencesCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, id string, options *WorkspacePolicyFragmentClientListReferencesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}/listReferences" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if id == "" { + return nil, errors.New("parameter id cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listReferencesHandleResponse handles the ListReferences response. +func (client *WorkspacePolicyFragmentClient) listReferencesHandleResponse(resp *http.Response) (WorkspacePolicyFragmentClientListReferencesResponse, error) { + result := WorkspacePolicyFragmentClientListReferencesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceCollection); err != nil { + return WorkspacePolicyFragmentClientListReferencesResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproduct_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproduct_client.go new file mode 100644 index 000000000000..4f49a163c172 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproduct_client.go @@ -0,0 +1,517 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceProductClient contains the methods for the WorkspaceProduct group. +// Don't use this type directly, use NewWorkspaceProductClient() instead. +type WorkspaceProductClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceProductClient creates a new instance of WorkspaceProductClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceProductClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceProductClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceProductClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or Updates a product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - WorkspaceProductClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceProductClient.CreateOrUpdate +// method. +func (client *WorkspaceProductClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, parameters ProductContract, options *WorkspaceProductClientCreateOrUpdateOptions) (WorkspaceProductClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceProductClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, parameters, options) + if err != nil { + return WorkspaceProductClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceProductClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, parameters ProductContract, options *WorkspaceProductClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceProductClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceProductClientCreateOrUpdateResponse, error) { + result := WorkspaceProductClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.ProductContract); err != nil { + return WorkspaceProductClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceProductClientDeleteOptions contains the optional parameters for the WorkspaceProductClient.Delete method. +func (client *WorkspaceProductClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, ifMatch string, options *WorkspaceProductClientDeleteOptions) (WorkspaceProductClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceProductClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, ifMatch, options) + if err != nil { + return WorkspaceProductClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductClientDeleteResponse{}, err + } + return WorkspaceProductClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceProductClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, ifMatch string, options *WorkspaceProductClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.DeleteSubscriptions != nil { + reqQP.Set("deleteSubscriptions", strconv.FormatBool(*options.DeleteSubscriptions)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the product specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductClientGetOptions contains the optional parameters for the WorkspaceProductClient.Get method. +func (client *WorkspaceProductClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, options *WorkspaceProductClientGetOptions) (WorkspaceProductClientGetResponse, error) { + var err error + const operationName = "WorkspaceProductClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, options) + if err != nil { + return WorkspaceProductClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceProductClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, _ *WorkspaceProductClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceProductClient) getHandleResponse(resp *http.Response) (WorkspaceProductClientGetResponse, error) { + result := WorkspaceProductClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.ProductContract); err != nil { + return WorkspaceProductClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the product specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductClientGetEntityTagOptions contains the optional parameters for the WorkspaceProductClient.GetEntityTag +// method. +func (client *WorkspaceProductClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, options *WorkspaceProductClientGetEntityTagOptions) (WorkspaceProductClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceProductClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, options) + if err != nil { + return WorkspaceProductClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceProductClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, _ *WorkspaceProductClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceProductClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceProductClientGetEntityTagResponse, error) { + result := WorkspaceProductClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Lists a collection of products in the specified workspace in a service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductClientListByServiceOptions contains the optional parameters for the WorkspaceProductClient.NewListByServicePager +// method. +func (client *WorkspaceProductClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceProductClientListByServiceOptions) *runtime.Pager[WorkspaceProductClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceProductClientListByServiceResponse]{ + More: func(page WorkspaceProductClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceProductClientListByServiceResponse) (WorkspaceProductClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceProductClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceProductClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceProductClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceProductClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.ExpandGroups != nil { + reqQP.Set("expandGroups", strconv.FormatBool(*options.ExpandGroups)) + } + if options != nil && options.Tags != nil { + reqQP.Set("tags", *options.Tags) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceProductClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceProductClientListByServiceResponse, error) { + result := WorkspaceProductClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductCollection); err != nil { + return WorkspaceProductClientListByServiceResponse{}, err + } + return result, nil +} + +// Update - Update existing product details. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Update parameters. +// - options - WorkspaceProductClientUpdateOptions contains the optional parameters for the WorkspaceProductClient.Update method. +func (client *WorkspaceProductClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, ifMatch string, parameters ProductUpdateParameters, options *WorkspaceProductClientUpdateOptions) (WorkspaceProductClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceProductClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, ifMatch, parameters, options) + if err != nil { + return WorkspaceProductClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceProductClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, ifMatch string, parameters ProductUpdateParameters, _ *WorkspaceProductClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceProductClient) updateHandleResponse(resp *http.Response) (WorkspaceProductClientUpdateResponse, error) { + result := WorkspaceProductClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.ProductContract); err != nil { + return WorkspaceProductClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproductapilink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproductapilink_client.go new file mode 100644 index 000000000000..2908b4f87d4e --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproductapilink_client.go @@ -0,0 +1,363 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceProductAPILinkClient contains the methods for the WorkspaceProductAPILink group. +// Don't use this type directly, use NewWorkspaceProductAPILinkClient() instead. +type WorkspaceProductAPILinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceProductAPILinkClient creates a new instance of WorkspaceProductAPILinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceProductAPILinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceProductAPILinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceProductAPILinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds an API to the specified product via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Product-API link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - WorkspaceProductAPILinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceProductAPILinkClient.CreateOrUpdate +// method. +func (client *WorkspaceProductAPILinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, apiLinkID string, parameters ProductAPILinkContract, options *WorkspaceProductAPILinkClientCreateOrUpdateOptions) (WorkspaceProductAPILinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceProductAPILinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, apiLinkID, parameters, options) + if err != nil { + return WorkspaceProductAPILinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductAPILinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductAPILinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceProductAPILinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, apiLinkID string, parameters ProductAPILinkContract, _ *WorkspaceProductAPILinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks/{apiLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceProductAPILinkClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceProductAPILinkClientCreateOrUpdateResponse, error) { + result := WorkspaceProductAPILinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductAPILinkContract); err != nil { + return WorkspaceProductAPILinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified API from the specified product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Product-API link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductAPILinkClientDeleteOptions contains the optional parameters for the WorkspaceProductAPILinkClient.Delete +// method. +func (client *WorkspaceProductAPILinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, apiLinkID string, options *WorkspaceProductAPILinkClientDeleteOptions) (WorkspaceProductAPILinkClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceProductAPILinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, apiLinkID, options) + if err != nil { + return WorkspaceProductAPILinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductAPILinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductAPILinkClientDeleteResponse{}, err + } + return WorkspaceProductAPILinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceProductAPILinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, apiLinkID string, _ *WorkspaceProductAPILinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks/{apiLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the API link for the product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Product-API link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductAPILinkClientGetOptions contains the optional parameters for the WorkspaceProductAPILinkClient.Get +// method. +func (client *WorkspaceProductAPILinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, apiLinkID string, options *WorkspaceProductAPILinkClientGetOptions) (WorkspaceProductAPILinkClientGetResponse, error) { + var err error + const operationName = "WorkspaceProductAPILinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, apiLinkID, options) + if err != nil { + return WorkspaceProductAPILinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductAPILinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductAPILinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceProductAPILinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, apiLinkID string, _ *WorkspaceProductAPILinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks/{apiLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceProductAPILinkClient) getHandleResponse(resp *http.Response) (WorkspaceProductAPILinkClientGetResponse, error) { + result := WorkspaceProductAPILinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.ProductAPILinkContract); err != nil { + return WorkspaceProductAPILinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the API links associated with a product. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductAPILinkClientListByProductOptions contains the optional parameters for the WorkspaceProductAPILinkClient.NewListByProductPager +// method. +func (client *WorkspaceProductAPILinkClient) NewListByProductPager(resourceGroupName string, serviceName string, workspaceID string, productID string, options *WorkspaceProductAPILinkClientListByProductOptions) *runtime.Pager[WorkspaceProductAPILinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceProductAPILinkClientListByProductResponse]{ + More: func(page WorkspaceProductAPILinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceProductAPILinkClientListByProductResponse) (WorkspaceProductAPILinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceProductAPILinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, options) + }, nil) + if err != nil { + return WorkspaceProductAPILinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *WorkspaceProductAPILinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, options *WorkspaceProductAPILinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *WorkspaceProductAPILinkClient) listByProductHandleResponse(resp *http.Response) (WorkspaceProductAPILinkClientListByProductResponse, error) { + result := WorkspaceProductAPILinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductAPILinkCollection); err != nil { + return WorkspaceProductAPILinkClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproductgrouplink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproductgrouplink_client.go new file mode 100644 index 000000000000..0a472e42f1a7 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproductgrouplink_client.go @@ -0,0 +1,363 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceProductGroupLinkClient contains the methods for the WorkspaceProductGroupLink group. +// Don't use this type directly, use NewWorkspaceProductGroupLinkClient() instead. +type WorkspaceProductGroupLinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceProductGroupLinkClient creates a new instance of WorkspaceProductGroupLinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceProductGroupLinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceProductGroupLinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceProductGroupLinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds a group to the specified product via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - groupLinkID - Product-Group link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - WorkspaceProductGroupLinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceProductGroupLinkClient.CreateOrUpdate +// method. +func (client *WorkspaceProductGroupLinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, groupLinkID string, parameters ProductGroupLinkContract, options *WorkspaceProductGroupLinkClientCreateOrUpdateOptions) (WorkspaceProductGroupLinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceProductGroupLinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, groupLinkID, parameters, options) + if err != nil { + return WorkspaceProductGroupLinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductGroupLinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductGroupLinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceProductGroupLinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, groupLinkID string, parameters ProductGroupLinkContract, _ *WorkspaceProductGroupLinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks/{groupLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if groupLinkID == "" { + return nil, errors.New("parameter groupLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupLinkId}", url.PathEscape(groupLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceProductGroupLinkClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceProductGroupLinkClientCreateOrUpdateResponse, error) { + result := WorkspaceProductGroupLinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductGroupLinkContract); err != nil { + return WorkspaceProductGroupLinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified group from the specified product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - groupLinkID - Product-Group link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductGroupLinkClientDeleteOptions contains the optional parameters for the WorkspaceProductGroupLinkClient.Delete +// method. +func (client *WorkspaceProductGroupLinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, groupLinkID string, options *WorkspaceProductGroupLinkClientDeleteOptions) (WorkspaceProductGroupLinkClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceProductGroupLinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, groupLinkID, options) + if err != nil { + return WorkspaceProductGroupLinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductGroupLinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductGroupLinkClientDeleteResponse{}, err + } + return WorkspaceProductGroupLinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceProductGroupLinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, groupLinkID string, _ *WorkspaceProductGroupLinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks/{groupLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if groupLinkID == "" { + return nil, errors.New("parameter groupLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupLinkId}", url.PathEscape(groupLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the group link for the product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - groupLinkID - Product-Group link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductGroupLinkClientGetOptions contains the optional parameters for the WorkspaceProductGroupLinkClient.Get +// method. +func (client *WorkspaceProductGroupLinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, groupLinkID string, options *WorkspaceProductGroupLinkClientGetOptions) (WorkspaceProductGroupLinkClientGetResponse, error) { + var err error + const operationName = "WorkspaceProductGroupLinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, groupLinkID, options) + if err != nil { + return WorkspaceProductGroupLinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductGroupLinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductGroupLinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceProductGroupLinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, groupLinkID string, _ *WorkspaceProductGroupLinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks/{groupLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if groupLinkID == "" { + return nil, errors.New("parameter groupLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupLinkId}", url.PathEscape(groupLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceProductGroupLinkClient) getHandleResponse(resp *http.Response) (WorkspaceProductGroupLinkClientGetResponse, error) { + result := WorkspaceProductGroupLinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.ProductGroupLinkContract); err != nil { + return WorkspaceProductGroupLinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the group links associated with a product. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductGroupLinkClientListByProductOptions contains the optional parameters for the WorkspaceProductGroupLinkClient.NewListByProductPager +// method. +func (client *WorkspaceProductGroupLinkClient) NewListByProductPager(resourceGroupName string, serviceName string, workspaceID string, productID string, options *WorkspaceProductGroupLinkClientListByProductOptions) *runtime.Pager[WorkspaceProductGroupLinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceProductGroupLinkClientListByProductResponse]{ + More: func(page WorkspaceProductGroupLinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceProductGroupLinkClientListByProductResponse) (WorkspaceProductGroupLinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceProductGroupLinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, options) + }, nil) + if err != nil { + return WorkspaceProductGroupLinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *WorkspaceProductGroupLinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, options *WorkspaceProductGroupLinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *WorkspaceProductGroupLinkClient) listByProductHandleResponse(resp *http.Response) (WorkspaceProductGroupLinkClientListByProductResponse, error) { + result := WorkspaceProductGroupLinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductGroupLinkCollection); err != nil { + return WorkspaceProductGroupLinkClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproductpolicy_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproductpolicy_client.go new file mode 100644 index 000000000000..ead92807ba5e --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspaceproductpolicy_client.go @@ -0,0 +1,444 @@ +// 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 armapimanagement + +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" +) + +// WorkspaceProductPolicyClient contains the methods for the WorkspaceProductPolicy group. +// Don't use this type directly, use NewWorkspaceProductPolicyClient() instead. +type WorkspaceProductPolicyClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceProductPolicyClient creates a new instance of WorkspaceProductPolicyClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceProductPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceProductPolicyClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceProductPolicyClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates policy configuration for the Product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - parameters - The policy contents to apply. +// - options - WorkspaceProductPolicyClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceProductPolicyClient.CreateOrUpdate +// method. +func (client *WorkspaceProductPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID PolicyIDName, parameters PolicyContract, options *WorkspaceProductPolicyClientCreateOrUpdateOptions) (WorkspaceProductPolicyClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceProductPolicyClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, policyID, parameters, options) + if err != nil { + return WorkspaceProductPolicyClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductPolicyClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductPolicyClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceProductPolicyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID PolicyIDName, parameters PolicyContract, options *WorkspaceProductPolicyClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceProductPolicyClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceProductPolicyClientCreateOrUpdateResponse, error) { + result := WorkspaceProductPolicyClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyContract); err != nil { + return WorkspaceProductPolicyClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the policy configuration at the Product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceProductPolicyClientDeleteOptions contains the optional parameters for the WorkspaceProductPolicyClient.Delete +// method. +func (client *WorkspaceProductPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID PolicyIDName, ifMatch string, options *WorkspaceProductPolicyClientDeleteOptions) (WorkspaceProductPolicyClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceProductPolicyClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, policyID, ifMatch, options) + if err != nil { + return WorkspaceProductPolicyClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductPolicyClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductPolicyClientDeleteResponse{}, err + } + return WorkspaceProductPolicyClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceProductPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID PolicyIDName, ifMatch string, _ *WorkspaceProductPolicyClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Get the policy configuration at the Product level. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - options - WorkspaceProductPolicyClientGetOptions contains the optional parameters for the WorkspaceProductPolicyClient.Get +// method. +func (client *WorkspaceProductPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID PolicyIDName, options *WorkspaceProductPolicyClientGetOptions) (WorkspaceProductPolicyClientGetResponse, error) { + var err error + const operationName = "WorkspaceProductPolicyClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, policyID, options) + if err != nil { + return WorkspaceProductPolicyClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductPolicyClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductPolicyClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceProductPolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID PolicyIDName, options *WorkspaceProductPolicyClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.Format != nil { + reqQP.Set("format", string(*options.Format)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceProductPolicyClient) getHandleResponse(resp *http.Response) (WorkspaceProductPolicyClientGetResponse, error) { + result := WorkspaceProductPolicyClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyContract); err != nil { + return WorkspaceProductPolicyClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Get the ETag of the policy configuration at the Product level. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - policyID - The identifier of the Policy. +// - options - WorkspaceProductPolicyClientGetEntityTagOptions contains the optional parameters for the WorkspaceProductPolicyClient.GetEntityTag +// method. +func (client *WorkspaceProductPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID PolicyIDName, options *WorkspaceProductPolicyClientGetEntityTagOptions) (WorkspaceProductPolicyClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceProductPolicyClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, policyID, options) + if err != nil { + return WorkspaceProductPolicyClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductPolicyClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductPolicyClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceProductPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, policyID PolicyIDName, _ *WorkspaceProductPolicyClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceProductPolicyClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceProductPolicyClientGetEntityTagResponse, error) { + result := WorkspaceProductPolicyClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// ListByProduct - Get the policy configuration at the Product level. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - productID - Product identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceProductPolicyClientListByProductOptions contains the optional parameters for the WorkspaceProductPolicyClient.ListByProduct +// method. +func (client *WorkspaceProductPolicyClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, options *WorkspaceProductPolicyClientListByProductOptions) (WorkspaceProductPolicyClientListByProductResponse, error) { + var err error + const operationName = "WorkspaceProductPolicyClient.ListByProduct" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, productID, options) + if err != nil { + return WorkspaceProductPolicyClientListByProductResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceProductPolicyClientListByProductResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceProductPolicyClientListByProductResponse{}, err + } + resp, err := client.listByProductHandleResponse(httpResp) + return resp, err +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *WorkspaceProductPolicyClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, productID string, _ *WorkspaceProductPolicyClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *WorkspaceProductPolicyClient) listByProductHandleResponse(resp *http.Response) (WorkspaceProductPolicyClientListByProductResponse, error) { + result := WorkspaceProductPolicyClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyCollection); err != nil { + return WorkspaceProductPolicyClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacesubscription_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacesubscription_client.go new file mode 100644 index 000000000000..ccb3adb12f6d --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacesubscription_client.go @@ -0,0 +1,732 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceSubscriptionClient contains the methods for the WorkspaceSubscription group. +// Don't use this type directly, use NewWorkspaceSubscriptionClient() instead. +type WorkspaceSubscriptionClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceSubscriptionClient creates a new instance of WorkspaceSubscriptionClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceSubscriptionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceSubscriptionClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceSubscriptionClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates the subscription of specified user to the specified product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. +// - parameters - Create parameters. +// - options - WorkspaceSubscriptionClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceSubscriptionClient.CreateOrUpdate +// method. +func (client *WorkspaceSubscriptionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, parameters SubscriptionCreateParameters, options *WorkspaceSubscriptionClientCreateOrUpdateOptions) (WorkspaceSubscriptionClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceSubscriptionClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, sid, parameters, options) + if err != nil { + return WorkspaceSubscriptionClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceSubscriptionClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceSubscriptionClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceSubscriptionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, parameters SubscriptionCreateParameters, options *WorkspaceSubscriptionClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.AppType != nil { + reqQP.Set("appType", string(*options.AppType)) + } + if options != nil && options.Notify != nil { + reqQP.Set("notify", strconv.FormatBool(*options.Notify)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceSubscriptionClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceSubscriptionClientCreateOrUpdateResponse, error) { + result := WorkspaceSubscriptionClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionContract); err != nil { + return WorkspaceSubscriptionClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceSubscriptionClientDeleteOptions contains the optional parameters for the WorkspaceSubscriptionClient.Delete +// method. +func (client *WorkspaceSubscriptionClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, ifMatch string, options *WorkspaceSubscriptionClientDeleteOptions) (WorkspaceSubscriptionClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceSubscriptionClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, sid, ifMatch, options) + if err != nil { + return WorkspaceSubscriptionClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceSubscriptionClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceSubscriptionClientDeleteResponse{}, err + } + return WorkspaceSubscriptionClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceSubscriptionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, ifMatch string, _ *WorkspaceSubscriptionClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the specified Subscription entity. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. +// - options - WorkspaceSubscriptionClientGetOptions contains the optional parameters for the WorkspaceSubscriptionClient.Get +// method. +func (client *WorkspaceSubscriptionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *WorkspaceSubscriptionClientGetOptions) (WorkspaceSubscriptionClientGetResponse, error) { + var err error + const operationName = "WorkspaceSubscriptionClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, sid, options) + if err != nil { + return WorkspaceSubscriptionClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceSubscriptionClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceSubscriptionClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceSubscriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, _ *WorkspaceSubscriptionClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceSubscriptionClient) getHandleResponse(resp *http.Response) (WorkspaceSubscriptionClientGetResponse, error) { + result := WorkspaceSubscriptionClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionContract); err != nil { + return WorkspaceSubscriptionClientGetResponse{}, err + } + return result, nil +} + +// GetEntityTag - Gets the entity state (Etag) version of the apimanagement subscription specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. +// - options - WorkspaceSubscriptionClientGetEntityTagOptions contains the optional parameters for the WorkspaceSubscriptionClient.GetEntityTag +// method. +func (client *WorkspaceSubscriptionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *WorkspaceSubscriptionClientGetEntityTagOptions) (WorkspaceSubscriptionClientGetEntityTagResponse, error) { + var err error + const operationName = "WorkspaceSubscriptionClient.GetEntityTag" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, sid, options) + if err != nil { + return WorkspaceSubscriptionClientGetEntityTagResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceSubscriptionClientGetEntityTagResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceSubscriptionClientGetEntityTagResponse{}, err + } + resp, err := client.getEntityTagHandleResponse(httpResp) + return resp, err +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *WorkspaceSubscriptionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, _ *WorkspaceSubscriptionClientGetEntityTagOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *WorkspaceSubscriptionClient) getEntityTagHandleResponse(resp *http.Response) (WorkspaceSubscriptionClientGetEntityTagResponse, error) { + result := WorkspaceSubscriptionClientGetEntityTagResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListPager - Lists all subscriptions of the workspace in an API Management service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceSubscriptionClientListOptions contains the optional parameters for the WorkspaceSubscriptionClient.NewListPager +// method. +func (client *WorkspaceSubscriptionClient) NewListPager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceSubscriptionClientListOptions) *runtime.Pager[WorkspaceSubscriptionClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceSubscriptionClientListResponse]{ + More: func(page WorkspaceSubscriptionClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceSubscriptionClientListResponse) (WorkspaceSubscriptionClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceSubscriptionClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceSubscriptionClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *WorkspaceSubscriptionClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceSubscriptionClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *WorkspaceSubscriptionClient) listHandleResponse(resp *http.Response) (WorkspaceSubscriptionClientListResponse, error) { + result := WorkspaceSubscriptionClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionCollection); err != nil { + return WorkspaceSubscriptionClientListResponse{}, err + } + return result, nil +} + +// ListSecrets - Gets the specified Subscription keys. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. +// - options - WorkspaceSubscriptionClientListSecretsOptions contains the optional parameters for the WorkspaceSubscriptionClient.ListSecrets +// method. +func (client *WorkspaceSubscriptionClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *WorkspaceSubscriptionClientListSecretsOptions) (WorkspaceSubscriptionClientListSecretsResponse, error) { + var err error + const operationName = "WorkspaceSubscriptionClient.ListSecrets" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listSecretsCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, sid, options) + if err != nil { + return WorkspaceSubscriptionClientListSecretsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceSubscriptionClientListSecretsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceSubscriptionClientListSecretsResponse{}, err + } + resp, err := client.listSecretsHandleResponse(httpResp) + return resp, err +} + +// listSecretsCreateRequest creates the ListSecrets request. +func (client *WorkspaceSubscriptionClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, _ *WorkspaceSubscriptionClientListSecretsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}/listSecrets" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listSecretsHandleResponse handles the ListSecrets response. +func (client *WorkspaceSubscriptionClient) listSecretsHandleResponse(resp *http.Response) (WorkspaceSubscriptionClientListSecretsResponse, error) { + result := WorkspaceSubscriptionClientListSecretsResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionKeysContract); err != nil { + return WorkspaceSubscriptionClientListSecretsResponse{}, err + } + return result, nil +} + +// RegeneratePrimaryKey - Regenerates primary key of existing subscription of the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. +// - options - WorkspaceSubscriptionClientRegeneratePrimaryKeyOptions contains the optional parameters for the WorkspaceSubscriptionClient.RegeneratePrimaryKey +// method. +func (client *WorkspaceSubscriptionClient) RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *WorkspaceSubscriptionClientRegeneratePrimaryKeyOptions) (WorkspaceSubscriptionClientRegeneratePrimaryKeyResponse, error) { + var err error + const operationName = "WorkspaceSubscriptionClient.RegeneratePrimaryKey" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.regeneratePrimaryKeyCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, sid, options) + if err != nil { + return WorkspaceSubscriptionClientRegeneratePrimaryKeyResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceSubscriptionClientRegeneratePrimaryKeyResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceSubscriptionClientRegeneratePrimaryKeyResponse{}, err + } + return WorkspaceSubscriptionClientRegeneratePrimaryKeyResponse{}, nil +} + +// regeneratePrimaryKeyCreateRequest creates the RegeneratePrimaryKey request. +func (client *WorkspaceSubscriptionClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, _ *WorkspaceSubscriptionClientRegeneratePrimaryKeyOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}/regeneratePrimaryKey" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// RegenerateSecondaryKey - Regenerates secondary key of existing subscription of the workspace in an API Management service +// instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. +// - options - WorkspaceSubscriptionClientRegenerateSecondaryKeyOptions contains the optional parameters for the WorkspaceSubscriptionClient.RegenerateSecondaryKey +// method. +func (client *WorkspaceSubscriptionClient) RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, options *WorkspaceSubscriptionClientRegenerateSecondaryKeyOptions) (WorkspaceSubscriptionClientRegenerateSecondaryKeyResponse, error) { + var err error + const operationName = "WorkspaceSubscriptionClient.RegenerateSecondaryKey" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.regenerateSecondaryKeyCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, sid, options) + if err != nil { + return WorkspaceSubscriptionClientRegenerateSecondaryKeyResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceSubscriptionClientRegenerateSecondaryKeyResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceSubscriptionClientRegenerateSecondaryKeyResponse{}, err + } + return WorkspaceSubscriptionClientRegenerateSecondaryKeyResponse{}, nil +} + +// regenerateSecondaryKeyCreateRequest creates the RegenerateSecondaryKey request. +func (client *WorkspaceSubscriptionClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, _ *WorkspaceSubscriptionClientRegenerateSecondaryKeyOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}/regenerateSecondaryKey" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + 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.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Update - Updates the details of a subscription specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - sid - Subscription entity Identifier. The entity represents the association between a user and a product in API Management. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Update parameters. +// - options - WorkspaceSubscriptionClientUpdateOptions contains the optional parameters for the WorkspaceSubscriptionClient.Update +// method. +func (client *WorkspaceSubscriptionClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, ifMatch string, parameters SubscriptionUpdateParameters, options *WorkspaceSubscriptionClientUpdateOptions) (WorkspaceSubscriptionClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceSubscriptionClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, sid, ifMatch, parameters, options) + if err != nil { + return WorkspaceSubscriptionClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceSubscriptionClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceSubscriptionClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceSubscriptionClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, sid string, ifMatch string, parameters SubscriptionUpdateParameters, options *WorkspaceSubscriptionClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.AppType != nil { + reqQP.Set("appType", string(*options.AppType)) + } + if options != nil && options.Notify != nil { + reqQP.Set("notify", strconv.FormatBool(*options.Notify)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceSubscriptionClient) updateHandleResponse(resp *http.Response) (WorkspaceSubscriptionClientUpdateResponse, error) { + result := WorkspaceSubscriptionClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionContract); err != nil { + return WorkspaceSubscriptionClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacetag_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacetag_client.go new file mode 100644 index 000000000000..0b8c9b7db7a7 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacetag_client.go @@ -0,0 +1,511 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceTagClient contains the methods for the WorkspaceTag group. +// Don't use this type directly, use NewWorkspaceTagClient() instead. +type WorkspaceTagClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceTagClient creates a new instance of WorkspaceTagClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceTagClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceTagClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceTagClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates a tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - parameters - Create parameters. +// - options - WorkspaceTagClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceTagClient.CreateOrUpdate +// method. +func (client *WorkspaceTagClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, parameters TagCreateUpdateParameters, options *WorkspaceTagClientCreateOrUpdateOptions) (WorkspaceTagClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceTagClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, parameters, options) + if err != nil { + return WorkspaceTagClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceTagClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, parameters TagCreateUpdateParameters, options *WorkspaceTagClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceTagClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceTagClientCreateOrUpdateResponse, error) { + result := WorkspaceTagClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.TagContract); err != nil { + return WorkspaceTagClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes specific tag of the workspace in an API Management service instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - options - WorkspaceTagClientDeleteOptions contains the optional parameters for the WorkspaceTagClient.Delete method. +func (client *WorkspaceTagClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, ifMatch string, options *WorkspaceTagClientDeleteOptions) (WorkspaceTagClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceTagClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, ifMatch, options) + if err != nil { + return WorkspaceTagClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagClientDeleteResponse{}, err + } + return WorkspaceTagClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceTagClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, ifMatch string, _ *WorkspaceTagClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + return req, nil +} + +// Get - Gets the details of the tag specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagClientGetOptions contains the optional parameters for the WorkspaceTagClient.Get method. +func (client *WorkspaceTagClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, options *WorkspaceTagClientGetOptions) (WorkspaceTagClientGetResponse, error) { + var err error + const operationName = "WorkspaceTagClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, options) + if err != nil { + return WorkspaceTagClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceTagClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, _ *WorkspaceTagClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceTagClient) getHandleResponse(resp *http.Response) (WorkspaceTagClientGetResponse, error) { + result := WorkspaceTagClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.TagContract); err != nil { + return WorkspaceTagClientGetResponse{}, err + } + return result, nil +} + +// GetEntityState - Gets the entity state version of the tag specified by its identifier. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagClientGetEntityStateOptions contains the optional parameters for the WorkspaceTagClient.GetEntityState +// method. +func (client *WorkspaceTagClient) GetEntityState(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, options *WorkspaceTagClientGetEntityStateOptions) (WorkspaceTagClientGetEntityStateResponse, error) { + var err error + const operationName = "WorkspaceTagClient.GetEntityState" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getEntityStateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, options) + if err != nil { + return WorkspaceTagClientGetEntityStateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagClientGetEntityStateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagClientGetEntityStateResponse{}, err + } + resp, err := client.getEntityStateHandleResponse(httpResp) + return resp, err +} + +// getEntityStateCreateRequest creates the GetEntityState request. +func (client *WorkspaceTagClient) getEntityStateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, _ *WorkspaceTagClientGetEntityStateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + 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.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getEntityStateHandleResponse handles the GetEntityState response. +func (client *WorkspaceTagClient) getEntityStateHandleResponse(resp *http.Response) (WorkspaceTagClientGetEntityStateResponse, error) { + result := WorkspaceTagClientGetEntityStateResponse{Success: resp.StatusCode >= 200 && resp.StatusCode < 300} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// NewListByServicePager - Lists a collection of tags defined within a workspace in a service instance. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagClientListByServiceOptions contains the optional parameters for the WorkspaceTagClient.NewListByServicePager +// method. +func (client *WorkspaceTagClient) NewListByServicePager(resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceTagClientListByServiceOptions) *runtime.Pager[WorkspaceTagClientListByServiceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceTagClientListByServiceResponse]{ + More: func(page WorkspaceTagClientListByServiceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceTagClientListByServiceResponse) (WorkspaceTagClientListByServiceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceTagClient.NewListByServicePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, options) + }, nil) + if err != nil { + return WorkspaceTagClientListByServiceResponse{}, err + } + return client.listByServiceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *WorkspaceTagClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, options *WorkspaceTagClientListByServiceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + if options != nil && options.Scope != nil { + reqQP.Set("scope", *options.Scope) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *WorkspaceTagClient) listByServiceHandleResponse(resp *http.Response) (WorkspaceTagClientListByServiceResponse, error) { + result := WorkspaceTagClientListByServiceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagCollection); err != nil { + return WorkspaceTagClientListByServiceResponse{}, err + } + return result, nil +} + +// Update - Updates the details of the tag specified by its identifier. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - ifMatch - ETag of the Entity. ETag should match the current entity state from the header response of the GET request or +// it should be * for unconditional update. +// - parameters - Update parameters. +// - options - WorkspaceTagClientUpdateOptions contains the optional parameters for the WorkspaceTagClient.Update method. +func (client *WorkspaceTagClient) Update(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, ifMatch string, parameters TagCreateUpdateParameters, options *WorkspaceTagClientUpdateOptions) (WorkspaceTagClientUpdateResponse, error) { + var err error + const operationName = "WorkspaceTagClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, ifMatch, parameters, options) + if err != nil { + return WorkspaceTagClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspaceTagClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, ifMatch string, parameters TagCreateUpdateParameters, _ *WorkspaceTagClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["If-Match"] = []string{ifMatch} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspaceTagClient) updateHandleResponse(resp *http.Response) (WorkspaceTagClientUpdateResponse, error) { + result := WorkspaceTagClientUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.TagContract); err != nil { + return WorkspaceTagClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacetagapilink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacetagapilink_client.go new file mode 100644 index 000000000000..45a2fa02a924 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacetagapilink_client.go @@ -0,0 +1,362 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceTagAPILinkClient contains the methods for the WorkspaceTagAPILink group. +// Don't use this type directly, use NewWorkspaceTagAPILinkClient() instead. +type WorkspaceTagAPILinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceTagAPILinkClient creates a new instance of WorkspaceTagAPILinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceTagAPILinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceTagAPILinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceTagAPILinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds an API to the specified tag via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Tag-API link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - WorkspaceTagAPILinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceTagAPILinkClient.CreateOrUpdate +// method. +func (client *WorkspaceTagAPILinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, apiLinkID string, parameters TagAPILinkContract, options *WorkspaceTagAPILinkClientCreateOrUpdateOptions) (WorkspaceTagAPILinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceTagAPILinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, apiLinkID, parameters, options) + if err != nil { + return WorkspaceTagAPILinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagAPILinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagAPILinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceTagAPILinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, apiLinkID string, parameters TagAPILinkContract, _ *WorkspaceTagAPILinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks/{apiLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceTagAPILinkClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceTagAPILinkClientCreateOrUpdateResponse, error) { + result := WorkspaceTagAPILinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagAPILinkContract); err != nil { + return WorkspaceTagAPILinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified API from the specified tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Tag-API link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagAPILinkClientDeleteOptions contains the optional parameters for the WorkspaceTagAPILinkClient.Delete +// method. +func (client *WorkspaceTagAPILinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, apiLinkID string, options *WorkspaceTagAPILinkClientDeleteOptions) (WorkspaceTagAPILinkClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceTagAPILinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, apiLinkID, options) + if err != nil { + return WorkspaceTagAPILinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagAPILinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagAPILinkClientDeleteResponse{}, err + } + return WorkspaceTagAPILinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceTagAPILinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, apiLinkID string, _ *WorkspaceTagAPILinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks/{apiLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the API link for the tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - apiLinkID - Tag-API link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagAPILinkClientGetOptions contains the optional parameters for the WorkspaceTagAPILinkClient.Get method. +func (client *WorkspaceTagAPILinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, apiLinkID string, options *WorkspaceTagAPILinkClientGetOptions) (WorkspaceTagAPILinkClientGetResponse, error) { + var err error + const operationName = "WorkspaceTagAPILinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, apiLinkID, options) + if err != nil { + return WorkspaceTagAPILinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagAPILinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagAPILinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceTagAPILinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, apiLinkID string, _ *WorkspaceTagAPILinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks/{apiLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if apiLinkID == "" { + return nil, errors.New("parameter apiLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiLinkId}", url.PathEscape(apiLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceTagAPILinkClient) getHandleResponse(resp *http.Response) (WorkspaceTagAPILinkClientGetResponse, error) { + result := WorkspaceTagAPILinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.TagAPILinkContract); err != nil { + return WorkspaceTagAPILinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the API links associated with a tag. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagAPILinkClientListByProductOptions contains the optional parameters for the WorkspaceTagAPILinkClient.NewListByProductPager +// method. +func (client *WorkspaceTagAPILinkClient) NewListByProductPager(resourceGroupName string, serviceName string, workspaceID string, tagID string, options *WorkspaceTagAPILinkClientListByProductOptions) *runtime.Pager[WorkspaceTagAPILinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceTagAPILinkClientListByProductResponse]{ + More: func(page WorkspaceTagAPILinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceTagAPILinkClientListByProductResponse) (WorkspaceTagAPILinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceTagAPILinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, options) + }, nil) + if err != nil { + return WorkspaceTagAPILinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *WorkspaceTagAPILinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, options *WorkspaceTagAPILinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *WorkspaceTagAPILinkClient) listByProductHandleResponse(resp *http.Response) (WorkspaceTagAPILinkClientListByProductResponse, error) { + result := WorkspaceTagAPILinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagAPILinkCollection); err != nil { + return WorkspaceTagAPILinkClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacetagoperationlink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacetagoperationlink_client.go new file mode 100644 index 000000000000..5f01da294b57 --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacetagoperationlink_client.go @@ -0,0 +1,363 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceTagOperationLinkClient contains the methods for the WorkspaceTagOperationLink group. +// Don't use this type directly, use NewWorkspaceTagOperationLinkClient() instead. +type WorkspaceTagOperationLinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceTagOperationLinkClient creates a new instance of WorkspaceTagOperationLinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceTagOperationLinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceTagOperationLinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceTagOperationLinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds an operation to the specified tag via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - operationLinkID - Tag-operation link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - WorkspaceTagOperationLinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceTagOperationLinkClient.CreateOrUpdate +// method. +func (client *WorkspaceTagOperationLinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, operationLinkID string, parameters TagOperationLinkContract, options *WorkspaceTagOperationLinkClientCreateOrUpdateOptions) (WorkspaceTagOperationLinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceTagOperationLinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, operationLinkID, parameters, options) + if err != nil { + return WorkspaceTagOperationLinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagOperationLinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagOperationLinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceTagOperationLinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, operationLinkID string, parameters TagOperationLinkContract, _ *WorkspaceTagOperationLinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks/{operationLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if operationLinkID == "" { + return nil, errors.New("parameter operationLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationLinkId}", url.PathEscape(operationLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceTagOperationLinkClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceTagOperationLinkClientCreateOrUpdateResponse, error) { + result := WorkspaceTagOperationLinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagOperationLinkContract); err != nil { + return WorkspaceTagOperationLinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified operation from the specified tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - operationLinkID - Tag-operation link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagOperationLinkClientDeleteOptions contains the optional parameters for the WorkspaceTagOperationLinkClient.Delete +// method. +func (client *WorkspaceTagOperationLinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, operationLinkID string, options *WorkspaceTagOperationLinkClientDeleteOptions) (WorkspaceTagOperationLinkClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceTagOperationLinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, operationLinkID, options) + if err != nil { + return WorkspaceTagOperationLinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagOperationLinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagOperationLinkClientDeleteResponse{}, err + } + return WorkspaceTagOperationLinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceTagOperationLinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, operationLinkID string, _ *WorkspaceTagOperationLinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks/{operationLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if operationLinkID == "" { + return nil, errors.New("parameter operationLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationLinkId}", url.PathEscape(operationLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the operation link for the tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - operationLinkID - Tag-operation link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagOperationLinkClientGetOptions contains the optional parameters for the WorkspaceTagOperationLinkClient.Get +// method. +func (client *WorkspaceTagOperationLinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, operationLinkID string, options *WorkspaceTagOperationLinkClientGetOptions) (WorkspaceTagOperationLinkClientGetResponse, error) { + var err error + const operationName = "WorkspaceTagOperationLinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, operationLinkID, options) + if err != nil { + return WorkspaceTagOperationLinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagOperationLinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagOperationLinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceTagOperationLinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, operationLinkID string, _ *WorkspaceTagOperationLinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks/{operationLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if operationLinkID == "" { + return nil, errors.New("parameter operationLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationLinkId}", url.PathEscape(operationLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceTagOperationLinkClient) getHandleResponse(resp *http.Response) (WorkspaceTagOperationLinkClientGetResponse, error) { + result := WorkspaceTagOperationLinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.TagOperationLinkContract); err != nil { + return WorkspaceTagOperationLinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the operation links associated with a tag. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagOperationLinkClientListByProductOptions contains the optional parameters for the WorkspaceTagOperationLinkClient.NewListByProductPager +// method. +func (client *WorkspaceTagOperationLinkClient) NewListByProductPager(resourceGroupName string, serviceName string, workspaceID string, tagID string, options *WorkspaceTagOperationLinkClientListByProductOptions) *runtime.Pager[WorkspaceTagOperationLinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceTagOperationLinkClientListByProductResponse]{ + More: func(page WorkspaceTagOperationLinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceTagOperationLinkClientListByProductResponse) (WorkspaceTagOperationLinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceTagOperationLinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, options) + }, nil) + if err != nil { + return WorkspaceTagOperationLinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *WorkspaceTagOperationLinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, options *WorkspaceTagOperationLinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *WorkspaceTagOperationLinkClient) listByProductHandleResponse(resp *http.Response) (WorkspaceTagOperationLinkClientListByProductResponse, error) { + result := WorkspaceTagOperationLinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagOperationLinkCollection); err != nil { + return WorkspaceTagOperationLinkClientListByProductResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apimanagement/armapimanagement/workspacetagproductlink_client.go b/sdk/resourcemanager/apimanagement/armapimanagement/workspacetagproductlink_client.go new file mode 100644 index 000000000000..8a304cfbafea --- /dev/null +++ b/sdk/resourcemanager/apimanagement/armapimanagement/workspacetagproductlink_client.go @@ -0,0 +1,363 @@ +// 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 armapimanagement + +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" + "strconv" + "strings" +) + +// WorkspaceTagProductLinkClient contains the methods for the WorkspaceTagProductLink group. +// Don't use this type directly, use NewWorkspaceTagProductLinkClient() instead. +type WorkspaceTagProductLinkClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspaceTagProductLinkClient creates a new instance of WorkspaceTagProductLinkClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspaceTagProductLinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceTagProductLinkClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspaceTagProductLinkClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Adds a product to the specified tag via link. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - productLinkID - Tag-product link identifier. Must be unique in the current API Management service instance. +// - parameters - Create or update parameters. +// - options - WorkspaceTagProductLinkClientCreateOrUpdateOptions contains the optional parameters for the WorkspaceTagProductLinkClient.CreateOrUpdate +// method. +func (client *WorkspaceTagProductLinkClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, productLinkID string, parameters TagProductLinkContract, options *WorkspaceTagProductLinkClientCreateOrUpdateOptions) (WorkspaceTagProductLinkClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkspaceTagProductLinkClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, productLinkID, parameters, options) + if err != nil { + return WorkspaceTagProductLinkClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagProductLinkClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagProductLinkClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspaceTagProductLinkClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, productLinkID string, parameters TagProductLinkContract, _ *WorkspaceTagProductLinkClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks/{productLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if productLinkID == "" { + return nil, errors.New("parameter productLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productLinkId}", url.PathEscape(productLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspaceTagProductLinkClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspaceTagProductLinkClientCreateOrUpdateResponse, error) { + result := WorkspaceTagProductLinkClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagProductLinkContract); err != nil { + return WorkspaceTagProductLinkClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the specified product from the specified tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - productLinkID - Tag-product link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagProductLinkClientDeleteOptions contains the optional parameters for the WorkspaceTagProductLinkClient.Delete +// method. +func (client *WorkspaceTagProductLinkClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, productLinkID string, options *WorkspaceTagProductLinkClientDeleteOptions) (WorkspaceTagProductLinkClientDeleteResponse, error) { + var err error + const operationName = "WorkspaceTagProductLinkClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, productLinkID, options) + if err != nil { + return WorkspaceTagProductLinkClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagProductLinkClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagProductLinkClientDeleteResponse{}, err + } + return WorkspaceTagProductLinkClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspaceTagProductLinkClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, productLinkID string, _ *WorkspaceTagProductLinkClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks/{productLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if productLinkID == "" { + return nil, errors.New("parameter productLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productLinkId}", url.PathEscape(productLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the product link for the tag. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - productLinkID - Tag-product link identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagProductLinkClientGetOptions contains the optional parameters for the WorkspaceTagProductLinkClient.Get +// method. +func (client *WorkspaceTagProductLinkClient) Get(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, productLinkID string, options *WorkspaceTagProductLinkClientGetOptions) (WorkspaceTagProductLinkClientGetResponse, error) { + var err error + const operationName = "WorkspaceTagProductLinkClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, productLinkID, options) + if err != nil { + return WorkspaceTagProductLinkClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspaceTagProductLinkClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspaceTagProductLinkClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspaceTagProductLinkClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, productLinkID string, _ *WorkspaceTagProductLinkClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks/{productLinkId}" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if productLinkID == "" { + return nil, errors.New("parameter productLinkID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productLinkId}", url.PathEscape(productLinkID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspaceTagProductLinkClient) getHandleResponse(resp *http.Response) (WorkspaceTagProductLinkClientGetResponse, error) { + result := WorkspaceTagProductLinkClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.TagProductLinkContract); err != nil { + return WorkspaceTagProductLinkClientGetResponse{}, err + } + return result, nil +} + +// NewListByProductPager - Lists a collection of the product links associated with a tag. +// +// Generated from API version 2024-05-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of the API Management service. +// - workspaceID - Workspace identifier. Must be unique in the current API Management service instance. +// - tagID - Tag identifier. Must be unique in the current API Management service instance. +// - options - WorkspaceTagProductLinkClientListByProductOptions contains the optional parameters for the WorkspaceTagProductLinkClient.NewListByProductPager +// method. +func (client *WorkspaceTagProductLinkClient) NewListByProductPager(resourceGroupName string, serviceName string, workspaceID string, tagID string, options *WorkspaceTagProductLinkClientListByProductOptions) *runtime.Pager[WorkspaceTagProductLinkClientListByProductResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspaceTagProductLinkClientListByProductResponse]{ + More: func(page WorkspaceTagProductLinkClientListByProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspaceTagProductLinkClientListByProductResponse) (WorkspaceTagProductLinkClientListByProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspaceTagProductLinkClient.NewListByProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, workspaceID, tagID, options) + }, nil) + if err != nil { + return WorkspaceTagProductLinkClientListByProductResponse{}, err + } + return client.listByProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *WorkspaceTagProductLinkClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, tagID string, options *WorkspaceTagProductLinkClientListByProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks" + 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 workspaceID == "" { + return nil, errors.New("parameter workspaceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceId}", url.PathEscape(workspaceID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + 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() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *WorkspaceTagProductLinkClient) listByProductHandleResponse(resp *http.Response) (WorkspaceTagProductLinkClientListByProductResponse, error) { + result := WorkspaceTagProductLinkClientListByProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TagProductLinkCollection); err != nil { + return WorkspaceTagProductLinkClientListByProductResponse{}, err + } + return result, nil +}