diff --git a/CHANGELOG.md b/CHANGELOG.md index d56944131570..9bfa5092a7fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # CHANGELOG +## `v55.5.0` + +### New Packages + +- `github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement` +- `github.com/Azure/azure-sdk-for-go/services/preview/appinsights/mgmt/2020-02-02-preview/insights` +- `github.com/Azure/azure-sdk-for-go/services/preview/signalr/mgmt/2021-06-01-preview/signalr` +- `github.com/Azure/azure-sdk-for-go/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub` + +### Updated Packages + +| Package Path | Changelog | +| :--- | :---: | +| `github.com/Azure/azure-sdk-for-go/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration` | [details](https://github.com/Azure/azure-sdk-for-go/tree/master/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/CHANGELOG.md) | + ## `v55.4.0` ### New Packages diff --git a/profiles/preview/preview/apimanagement/mgmt/apimanagement/apimanagementapi/models.go b/profiles/preview/preview/apimanagement/mgmt/apimanagement/apimanagementapi/models.go index 4ed2a99f458b..59c6b02159fa 100644 --- a/profiles/preview/preview/apimanagement/mgmt/apimanagement/apimanagementapi/models.go +++ b/profiles/preview/preview/apimanagement/mgmt/apimanagement/apimanagementapi/models.go @@ -8,7 +8,7 @@ package apimanagementapi -import original "github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2019-12-01-preview/apimanagement/apimanagementapi" +import original "github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apimanagementapi" type APIClientAPI = original.APIClientAPI type APIDiagnosticClientAPI = original.APIDiagnosticClientAPI @@ -29,10 +29,14 @@ type AuthorizationServerClientAPI = original.AuthorizationServerClientAPI type BackendClientAPI = original.BackendClientAPI type CacheClientAPI = original.CacheClientAPI type CertificateClientAPI = original.CertificateClientAPI +type ContentItemClientAPI = original.ContentItemClientAPI +type ContentTypeClientAPI = original.ContentTypeClientAPI type DelegationSettingsClientAPI = original.DelegationSettingsClientAPI +type DeletedServicesClientAPI = original.DeletedServicesClientAPI type DiagnosticClientAPI = original.DiagnosticClientAPI type EmailTemplateClientAPI = original.EmailTemplateClientAPI type GatewayAPIClientAPI = original.GatewayAPIClientAPI +type GatewayCertificateAuthorityClientAPI = original.GatewayCertificateAuthorityClientAPI type GatewayClientAPI = original.GatewayClientAPI type GatewayHostnameConfigurationClientAPI = original.GatewayHostnameConfigurationClientAPI type GroupClientAPI = original.GroupClientAPI @@ -50,6 +54,8 @@ type OperationClientAPI = original.OperationClientAPI type OperationsClientAPI = original.OperationsClientAPI type PolicyClientAPI = original.PolicyClientAPI type PolicyDescriptionClientAPI = original.PolicyDescriptionClientAPI +type PortalRevisionClientAPI = original.PortalRevisionClientAPI +type PortalSettingsClientAPI = original.PortalSettingsClientAPI type ProductAPIClientAPI = original.ProductAPIClientAPI type ProductClientAPI = original.ProductClientAPI type ProductGroupClientAPI = original.ProductGroupClientAPI @@ -63,12 +69,14 @@ type ServiceClientAPI = original.ServiceClientAPI type ServiceSkusClientAPI = original.ServiceSkusClientAPI type SignInSettingsClientAPI = original.SignInSettingsClientAPI type SignUpSettingsClientAPI = original.SignUpSettingsClientAPI +type SkusClientAPI = original.SkusClientAPI type SubscriptionClientAPI = original.SubscriptionClientAPI type TagClientAPI = original.TagClientAPI type TagResourceClientAPI = original.TagResourceClientAPI type TenantAccessClientAPI = original.TenantAccessClientAPI type TenantAccessGitClientAPI = original.TenantAccessGitClientAPI type TenantConfigurationClientAPI = original.TenantConfigurationClientAPI +type TenantSettingsClientAPI = original.TenantSettingsClientAPI type UserClientAPI = original.UserClientAPI type UserConfirmationPasswordClientAPI = original.UserConfirmationPasswordClientAPI type UserGroupClientAPI = original.UserGroupClientAPI diff --git a/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go b/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go index cd0e328e04e1..5d48f2f7b8ea 100644 --- a/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go +++ b/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go @@ -11,7 +11,7 @@ package apimanagement import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2019-12-01-preview/apimanagement" + original "github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement" ) const ( @@ -21,51 +21,60 @@ const ( type APIType = original.APIType const ( - HTTP APIType = original.HTTP - Soap APIType = original.Soap + APITypeHTTP APIType = original.APITypeHTTP + APITypeSoap APIType = original.APITypeSoap + APITypeWebsocket APIType = original.APITypeWebsocket +) + +type AccessIDName = original.AccessIDName + +const ( + AccessIDNameAccess AccessIDName = original.AccessIDNameAccess + AccessIDNameGitAccess AccessIDName = original.AccessIDNameGitAccess ) type AlwaysLog = original.AlwaysLog const ( - AllErrors AlwaysLog = original.AllErrors + AlwaysLogAllErrors AlwaysLog = original.AlwaysLogAllErrors ) type ApimIdentityType = original.ApimIdentityType const ( - None ApimIdentityType = original.None - SystemAssigned ApimIdentityType = original.SystemAssigned - SystemAssignedUserAssigned ApimIdentityType = original.SystemAssignedUserAssigned - UserAssigned ApimIdentityType = original.UserAssigned + ApimIdentityTypeNone ApimIdentityType = original.ApimIdentityTypeNone + ApimIdentityTypeSystemAssigned ApimIdentityType = original.ApimIdentityTypeSystemAssigned + ApimIdentityTypeSystemAssignedUserAssigned ApimIdentityType = original.ApimIdentityTypeSystemAssignedUserAssigned + ApimIdentityTypeUserAssigned ApimIdentityType = original.ApimIdentityTypeUserAssigned ) type AppType = original.AppType const ( - DeveloperPortal AppType = original.DeveloperPortal + AppTypeDeveloperPortal AppType = original.AppTypeDeveloperPortal + AppTypePortal AppType = original.AppTypePortal ) type AsyncOperationStatus = original.AsyncOperationStatus const ( - Failed AsyncOperationStatus = original.Failed - InProgress AsyncOperationStatus = original.InProgress - Started AsyncOperationStatus = original.Started - Succeeded AsyncOperationStatus = original.Succeeded + AsyncOperationStatusFailed AsyncOperationStatus = original.AsyncOperationStatusFailed + AsyncOperationStatusInProgress AsyncOperationStatus = original.AsyncOperationStatusInProgress + AsyncOperationStatusStarted AsyncOperationStatus = original.AsyncOperationStatusStarted + AsyncOperationStatusSucceeded AsyncOperationStatus = original.AsyncOperationStatusSucceeded ) type AuthorizationMethod = original.AuthorizationMethod const ( - DELETE AuthorizationMethod = original.DELETE - GET AuthorizationMethod = original.GET - HEAD AuthorizationMethod = original.HEAD - OPTIONS AuthorizationMethod = original.OPTIONS - PATCH AuthorizationMethod = original.PATCH - POST AuthorizationMethod = original.POST - PUT AuthorizationMethod = original.PUT - TRACE AuthorizationMethod = original.TRACE + AuthorizationMethodDELETE AuthorizationMethod = original.AuthorizationMethodDELETE + AuthorizationMethodGET AuthorizationMethod = original.AuthorizationMethodGET + AuthorizationMethodHEAD AuthorizationMethod = original.AuthorizationMethodHEAD + AuthorizationMethodOPTIONS AuthorizationMethod = original.AuthorizationMethodOPTIONS + AuthorizationMethodPATCH AuthorizationMethod = original.AuthorizationMethodPATCH + AuthorizationMethodPOST AuthorizationMethod = original.AuthorizationMethodPOST + AuthorizationMethodPUT AuthorizationMethod = original.AuthorizationMethodPUT + AuthorizationMethodTRACE AuthorizationMethod = original.AuthorizationMethodTRACE ) type BackendProtocol = original.BackendProtocol @@ -78,8 +87,8 @@ const ( type BearerTokenSendingMethod = original.BearerTokenSendingMethod const ( - AuthorizationHeader BearerTokenSendingMethod = original.AuthorizationHeader - Query BearerTokenSendingMethod = original.Query + BearerTokenSendingMethodAuthorizationHeader BearerTokenSendingMethod = original.BearerTokenSendingMethodAuthorizationHeader + BearerTokenSendingMethodQuery BearerTokenSendingMethod = original.BearerTokenSendingMethodQuery ) type BearerTokenSendingMethods = original.BearerTokenSendingMethods @@ -89,41 +98,65 @@ const ( BearerTokenSendingMethodsQuery BearerTokenSendingMethods = original.BearerTokenSendingMethodsQuery ) +type CertificateSource = original.CertificateSource + +const ( + CertificateSourceBuiltIn CertificateSource = original.CertificateSourceBuiltIn + CertificateSourceCustom CertificateSource = original.CertificateSourceCustom + CertificateSourceKeyVault CertificateSource = original.CertificateSourceKeyVault + CertificateSourceManaged CertificateSource = original.CertificateSourceManaged +) + +type CertificateStatus = original.CertificateStatus + +const ( + CertificateStatusCompleted CertificateStatus = original.CertificateStatusCompleted + CertificateStatusFailed CertificateStatus = original.CertificateStatusFailed + CertificateStatusInProgress CertificateStatus = original.CertificateStatusInProgress +) + type ClientAuthenticationMethod = original.ClientAuthenticationMethod const ( - Basic ClientAuthenticationMethod = original.Basic - Body ClientAuthenticationMethod = original.Body + ClientAuthenticationMethodBasic ClientAuthenticationMethod = original.ClientAuthenticationMethodBasic + ClientAuthenticationMethodBody ClientAuthenticationMethod = original.ClientAuthenticationMethodBody ) type Confirmation = original.Confirmation const ( - Invite Confirmation = original.Invite - Signup Confirmation = original.Signup + ConfirmationInvite Confirmation = original.ConfirmationInvite + ConfirmationSignup Confirmation = original.ConfirmationSignup ) type ConnectivityStatusType = original.ConnectivityStatusType const ( - Failure ConnectivityStatusType = original.Failure - Initializing ConnectivityStatusType = original.Initializing - Success ConnectivityStatusType = original.Success + ConnectivityStatusTypeFailure ConnectivityStatusType = original.ConnectivityStatusTypeFailure + ConnectivityStatusTypeInitializing ConnectivityStatusType = original.ConnectivityStatusTypeInitializing + ConnectivityStatusTypeSuccess ConnectivityStatusType = original.ConnectivityStatusTypeSuccess ) type ContentFormat = original.ContentFormat const ( - Openapi ContentFormat = original.Openapi - Openapijson ContentFormat = original.Openapijson - OpenapijsonLink ContentFormat = original.OpenapijsonLink - OpenapiLink ContentFormat = original.OpenapiLink - SwaggerJSON ContentFormat = original.SwaggerJSON - SwaggerLinkJSON ContentFormat = original.SwaggerLinkJSON - WadlLinkJSON ContentFormat = original.WadlLinkJSON - WadlXML ContentFormat = original.WadlXML - Wsdl ContentFormat = original.Wsdl - WsdlLink ContentFormat = original.WsdlLink + ContentFormatOpenapi ContentFormat = original.ContentFormatOpenapi + ContentFormatOpenapijson ContentFormat = original.ContentFormatOpenapijson + ContentFormatOpenapijsonLink ContentFormat = original.ContentFormatOpenapijsonLink + ContentFormatOpenapiLink ContentFormat = original.ContentFormatOpenapiLink + ContentFormatSwaggerJSON ContentFormat = original.ContentFormatSwaggerJSON + ContentFormatSwaggerLinkJSON ContentFormat = original.ContentFormatSwaggerLinkJSON + ContentFormatWadlLinkJSON ContentFormat = original.ContentFormatWadlLinkJSON + ContentFormatWadlXML ContentFormat = original.ContentFormatWadlXML + ContentFormatWsdl ContentFormat = original.ContentFormatWsdl + ContentFormatWsdlLink ContentFormat = original.ContentFormatWsdlLink +) + +type DataMaskingMode = original.DataMaskingMode + +const ( + DataMaskingModeHide DataMaskingMode = original.DataMaskingModeHide + DataMaskingModeMask DataMaskingMode = original.DataMaskingModeMask ) type ExportFormat = original.ExportFormat @@ -148,18 +181,18 @@ const ( type GrantType = original.GrantType const ( - AuthorizationCode GrantType = original.AuthorizationCode - ClientCredentials GrantType = original.ClientCredentials - Implicit GrantType = original.Implicit - ResourceOwnerPassword GrantType = original.ResourceOwnerPassword + GrantTypeAuthorizationCode GrantType = original.GrantTypeAuthorizationCode + GrantTypeClientCredentials GrantType = original.GrantTypeClientCredentials + GrantTypeImplicit GrantType = original.GrantTypeImplicit + GrantTypeResourceOwnerPassword GrantType = original.GrantTypeResourceOwnerPassword ) type GroupType = original.GroupType const ( - Custom GroupType = original.Custom - External GroupType = original.External - System GroupType = original.System + GroupTypeCustom GroupType = original.GroupTypeCustom + GroupTypeExternal GroupType = original.GroupTypeExternal + GroupTypeSystem GroupType = original.GroupTypeSystem ) type HTTPCorrelationProtocol = original.HTTPCorrelationProtocol @@ -183,55 +216,63 @@ const ( type IdentityProviderType = original.IdentityProviderType const ( - Aad IdentityProviderType = original.Aad - AadB2C IdentityProviderType = original.AadB2C - Facebook IdentityProviderType = original.Facebook - Google IdentityProviderType = original.Google - Microsoft IdentityProviderType = original.Microsoft - Twitter IdentityProviderType = original.Twitter + IdentityProviderTypeAad IdentityProviderType = original.IdentityProviderTypeAad + IdentityProviderTypeAadB2C IdentityProviderType = original.IdentityProviderTypeAadB2C + IdentityProviderTypeFacebook IdentityProviderType = original.IdentityProviderTypeFacebook + IdentityProviderTypeGoogle IdentityProviderType = original.IdentityProviderTypeGoogle + IdentityProviderTypeMicrosoft IdentityProviderType = original.IdentityProviderTypeMicrosoft + IdentityProviderTypeTwitter IdentityProviderType = original.IdentityProviderTypeTwitter ) type KeyType = original.KeyType const ( - Primary KeyType = original.Primary - Secondary KeyType = original.Secondary + KeyTypePrimary KeyType = original.KeyTypePrimary + KeyTypeSecondary KeyType = original.KeyTypeSecondary ) type LoggerType = original.LoggerType const ( - ApplicationInsights LoggerType = original.ApplicationInsights - AzureEventHub LoggerType = original.AzureEventHub + LoggerTypeApplicationInsights LoggerType = original.LoggerTypeApplicationInsights + LoggerTypeAzureEventHub LoggerType = original.LoggerTypeAzureEventHub + LoggerTypeAzureMonitor LoggerType = original.LoggerTypeAzureMonitor ) type NameAvailabilityReason = original.NameAvailabilityReason const ( - AlreadyExists NameAvailabilityReason = original.AlreadyExists - Invalid NameAvailabilityReason = original.Invalid - Valid NameAvailabilityReason = original.Valid + NameAvailabilityReasonAlreadyExists NameAvailabilityReason = original.NameAvailabilityReasonAlreadyExists + NameAvailabilityReasonInvalid NameAvailabilityReason = original.NameAvailabilityReasonInvalid + NameAvailabilityReasonValid NameAvailabilityReason = original.NameAvailabilityReasonValid ) type NotificationName = original.NotificationName const ( - AccountClosedPublisher NotificationName = original.AccountClosedPublisher - BCC NotificationName = original.BCC - NewApplicationNotificationMessage NotificationName = original.NewApplicationNotificationMessage - NewIssuePublisherNotificationMessage NotificationName = original.NewIssuePublisherNotificationMessage - PurchasePublisherNotificationMessage NotificationName = original.PurchasePublisherNotificationMessage - QuotaLimitApproachingPublisherNotificationMessage NotificationName = original.QuotaLimitApproachingPublisherNotificationMessage - RequestPublisherNotificationMessage NotificationName = original.RequestPublisherNotificationMessage + NotificationNameAccountClosedPublisher NotificationName = original.NotificationNameAccountClosedPublisher + NotificationNameBCC NotificationName = original.NotificationNameBCC + NotificationNameNewApplicationNotificationMessage NotificationName = original.NotificationNameNewApplicationNotificationMessage + NotificationNameNewIssuePublisherNotificationMessage NotificationName = original.NotificationNameNewIssuePublisherNotificationMessage + NotificationNamePurchasePublisherNotificationMessage NotificationName = original.NotificationNamePurchasePublisherNotificationMessage + NotificationNameQuotaLimitApproachingPublisherNotificationMessage NotificationName = original.NotificationNameQuotaLimitApproachingPublisherNotificationMessage + NotificationNameRequestPublisherNotificationMessage NotificationName = original.NotificationNameRequestPublisherNotificationMessage +) + +type OperationNameFormat = original.OperationNameFormat + +const ( + OperationNameFormatName OperationNameFormat = original.OperationNameFormatName + OperationNameFormatURL OperationNameFormat = original.OperationNameFormatURL ) type PolicyContentFormat = original.PolicyContentFormat const ( - Rawxml PolicyContentFormat = original.Rawxml - RawxmlLink PolicyContentFormat = original.RawxmlLink - XML PolicyContentFormat = original.XML - XMLLink PolicyContentFormat = original.XMLLink + PolicyContentFormatRawxml PolicyContentFormat = original.PolicyContentFormatRawxml + PolicyContentFormatRawxmlLink PolicyContentFormat = original.PolicyContentFormatRawxmlLink + PolicyContentFormatXML PolicyContentFormat = original.PolicyContentFormatXML + PolicyContentFormatXMLLink PolicyContentFormat = original.PolicyContentFormatXMLLink ) type PolicyExportFormat = original.PolicyExportFormat @@ -251,11 +292,20 @@ const ( PolicyScopeContractTenant PolicyScopeContract = original.PolicyScopeContractTenant ) +type PortalRevisionStatus = original.PortalRevisionStatus + +const ( + PortalRevisionStatusCompleted PortalRevisionStatus = original.PortalRevisionStatusCompleted + PortalRevisionStatusFailed PortalRevisionStatus = original.PortalRevisionStatusFailed + PortalRevisionStatusPending PortalRevisionStatus = original.PortalRevisionStatusPending + PortalRevisionStatusPublishing PortalRevisionStatus = original.PortalRevisionStatusPublishing +) + type ProductState = original.ProductState const ( - NotPublished ProductState = original.NotPublished - Published ProductState = original.Published + ProductStateNotPublished ProductState = original.ProductStateNotPublished + ProductStatePublished ProductState = original.ProductStatePublished ) type Protocol = original.Protocol @@ -263,12 +313,14 @@ type Protocol = original.Protocol const ( ProtocolHTTP Protocol = original.ProtocolHTTP ProtocolHTTPS Protocol = original.ProtocolHTTPS + ProtocolWs Protocol = original.ProtocolWs + ProtocolWss Protocol = original.ProtocolWss ) type ProvisioningState = original.ProvisioningState const ( - Created ProvisioningState = original.Created + ProvisioningStateCreated ProvisioningState = original.ProvisioningStateCreated ) type ResourceSkuCapacityScaleType = original.ResourceSkuCapacityScaleType @@ -282,7 +334,29 @@ const ( type SamplingType = original.SamplingType const ( - Fixed SamplingType = original.Fixed + SamplingTypeFixed SamplingType = original.SamplingTypeFixed +) + +type SkuCapacityScaleType = original.SkuCapacityScaleType + +const ( + SkuCapacityScaleTypeAutomatic SkuCapacityScaleType = original.SkuCapacityScaleTypeAutomatic + SkuCapacityScaleTypeManual SkuCapacityScaleType = original.SkuCapacityScaleTypeManual + SkuCapacityScaleTypeNone SkuCapacityScaleType = original.SkuCapacityScaleTypeNone +) + +type SkuRestrictionsReasonCode = original.SkuRestrictionsReasonCode + +const ( + SkuRestrictionsReasonCodeNotAvailableForSubscription SkuRestrictionsReasonCode = original.SkuRestrictionsReasonCodeNotAvailableForSubscription + SkuRestrictionsReasonCodeQuotaID SkuRestrictionsReasonCode = original.SkuRestrictionsReasonCodeQuotaID +) + +type SkuRestrictionsType = original.SkuRestrictionsType + +const ( + SkuRestrictionsTypeLocation SkuRestrictionsType = original.SkuRestrictionsTypeLocation + SkuRestrictionsTypeZone SkuRestrictionsType = original.SkuRestrictionsTypeZone ) type SkuType = original.SkuType @@ -291,6 +365,7 @@ const ( SkuTypeBasic SkuType = original.SkuTypeBasic SkuTypeConsumption SkuType = original.SkuTypeConsumption SkuTypeDeveloper SkuType = original.SkuTypeDeveloper + SkuTypeIsolated SkuType = original.SkuTypeIsolated SkuTypePremium SkuType = original.SkuTypePremium SkuTypeStandard SkuType = original.SkuTypeStandard ) @@ -298,55 +373,56 @@ const ( type SoapAPIType = original.SoapAPIType const ( - SoapPassThrough SoapAPIType = original.SoapPassThrough - SoapToRest SoapAPIType = original.SoapToRest + SoapAPITypeSoapPassThrough SoapAPIType = original.SoapAPITypeSoapPassThrough + SoapAPITypeSoapToRest SoapAPIType = original.SoapAPITypeSoapToRest + SoapAPITypeWebSocket SoapAPIType = original.SoapAPITypeWebSocket ) type State = original.State const ( - Closed State = original.Closed - Open State = original.Open - Proposed State = original.Proposed - Removed State = original.Removed - Resolved State = original.Resolved + StateClosed State = original.StateClosed + StateOpen State = original.StateOpen + StateProposed State = original.StateProposed + StateRemoved State = original.StateRemoved + StateResolved State = original.StateResolved ) type StoreName = original.StoreName const ( - CertificateAuthority StoreName = original.CertificateAuthority - Root StoreName = original.Root + StoreNameCertificateAuthority StoreName = original.StoreNameCertificateAuthority + StoreNameRoot StoreName = original.StoreNameRoot ) type SubscriptionState = original.SubscriptionState const ( - Active SubscriptionState = original.Active - Cancelled SubscriptionState = original.Cancelled - Expired SubscriptionState = original.Expired - Rejected SubscriptionState = original.Rejected - Submitted SubscriptionState = original.Submitted - Suspended SubscriptionState = original.Suspended + SubscriptionStateActive SubscriptionState = original.SubscriptionStateActive + SubscriptionStateCancelled SubscriptionState = original.SubscriptionStateCancelled + SubscriptionStateExpired SubscriptionState = original.SubscriptionStateExpired + SubscriptionStateRejected SubscriptionState = original.SubscriptionStateRejected + SubscriptionStateSubmitted SubscriptionState = original.SubscriptionStateSubmitted + SubscriptionStateSuspended SubscriptionState = original.SubscriptionStateSuspended ) type TemplateName = original.TemplateName const ( - AccountClosedDeveloper TemplateName = original.AccountClosedDeveloper - ApplicationApprovedNotificationMessage TemplateName = original.ApplicationApprovedNotificationMessage - ConfirmSignUpIdentityDefault TemplateName = original.ConfirmSignUpIdentityDefault - EmailChangeIdentityDefault TemplateName = original.EmailChangeIdentityDefault - InviteUserNotificationMessage TemplateName = original.InviteUserNotificationMessage - NewCommentNotificationMessage TemplateName = original.NewCommentNotificationMessage - NewDeveloperNotificationMessage TemplateName = original.NewDeveloperNotificationMessage - NewIssueNotificationMessage TemplateName = original.NewIssueNotificationMessage - PasswordResetByAdminNotificationMessage TemplateName = original.PasswordResetByAdminNotificationMessage - PasswordResetIdentityDefault TemplateName = original.PasswordResetIdentityDefault - PurchaseDeveloperNotificationMessage TemplateName = original.PurchaseDeveloperNotificationMessage - QuotaLimitApproachingDeveloperNotificationMessage TemplateName = original.QuotaLimitApproachingDeveloperNotificationMessage - RejectDeveloperNotificationMessage TemplateName = original.RejectDeveloperNotificationMessage - RequestDeveloperNotificationMessage TemplateName = original.RequestDeveloperNotificationMessage + TemplateNameAccountClosedDeveloper TemplateName = original.TemplateNameAccountClosedDeveloper + TemplateNameApplicationApprovedNotificationMessage TemplateName = original.TemplateNameApplicationApprovedNotificationMessage + TemplateNameConfirmSignUpIdentityDefault TemplateName = original.TemplateNameConfirmSignUpIdentityDefault + TemplateNameEmailChangeIdentityDefault TemplateName = original.TemplateNameEmailChangeIdentityDefault + TemplateNameInviteUserNotificationMessage TemplateName = original.TemplateNameInviteUserNotificationMessage + TemplateNameNewCommentNotificationMessage TemplateName = original.TemplateNameNewCommentNotificationMessage + TemplateNameNewDeveloperNotificationMessage TemplateName = original.TemplateNameNewDeveloperNotificationMessage + TemplateNameNewIssueNotificationMessage TemplateName = original.TemplateNameNewIssueNotificationMessage + TemplateNamePasswordResetByAdminNotificationMessage TemplateName = original.TemplateNamePasswordResetByAdminNotificationMessage + TemplateNamePasswordResetIdentityDefault TemplateName = original.TemplateNamePasswordResetIdentityDefault + TemplateNamePurchaseDeveloperNotificationMessage TemplateName = original.TemplateNamePurchaseDeveloperNotificationMessage + TemplateNameQuotaLimitApproachingDeveloperNotificationMessage TemplateName = original.TemplateNameQuotaLimitApproachingDeveloperNotificationMessage + TemplateNameRejectDeveloperNotificationMessage TemplateName = original.TemplateNameRejectDeveloperNotificationMessage + TemplateNameRequestDeveloperNotificationMessage TemplateName = original.TemplateNameRequestDeveloperNotificationMessage ) type UserState = original.UserState @@ -361,9 +437,9 @@ const ( type Verbosity = original.Verbosity const ( - Error Verbosity = original.Error - Information Verbosity = original.Information - Verbose Verbosity = original.Verbose + VerbosityError Verbosity = original.VerbosityError + VerbosityInformation Verbosity = original.VerbosityInformation + VerbosityVerbose Verbosity = original.VerbosityVerbose ) type VersioningScheme = original.VersioningScheme @@ -394,6 +470,7 @@ type APIClient = original.APIClient type APICollection = original.APICollection type APICollectionIterator = original.APICollectionIterator type APICollectionPage = original.APICollectionPage +type APIContactInformation = original.APIContactInformation type APIContract = original.APIContract type APIContractProperties = original.APIContractProperties type APIContractUpdateProperties = original.APIContractUpdateProperties @@ -409,6 +486,7 @@ type APIExportResultValue = original.APIExportResultValue type APIIssueAttachmentClient = original.APIIssueAttachmentClient type APIIssueClient = original.APIIssueClient type APIIssueCommentClient = original.APIIssueCommentClient +type APILicenseInformation = original.APILicenseInformation type APIOperationClient = original.APIOperationClient type APIOperationPolicyClient = original.APIOperationPolicyClient type APIPolicyClient = original.APIPolicyClient @@ -441,7 +519,14 @@ type APIVersionSetContractProperties = original.APIVersionSetContractProperties type APIVersionSetEntityBase = original.APIVersionSetEntityBase type APIVersionSetUpdateParameters = original.APIVersionSetUpdateParameters type APIVersionSetUpdateParametersProperties = original.APIVersionSetUpdateParametersProperties +type AccessInformationCollection = original.AccessInformationCollection +type AccessInformationCollectionIterator = original.AccessInformationCollectionIterator +type AccessInformationCollectionPage = original.AccessInformationCollectionPage type AccessInformationContract = original.AccessInformationContract +type AccessInformationContractProperties = original.AccessInformationContractProperties +type AccessInformationCreateParameterProperties = original.AccessInformationCreateParameterProperties +type AccessInformationCreateParameters = original.AccessInformationCreateParameters +type AccessInformationSecretsContract = original.AccessInformationSecretsContract type AccessInformationUpdateParameterProperties = original.AccessInformationUpdateParameterProperties type AccessInformationUpdateParameters = original.AccessInformationUpdateParameters type AdditionalLocation = original.AdditionalLocation @@ -456,6 +541,7 @@ type AuthorizationServerCollectionPage = original.AuthorizationServerCollectionP type AuthorizationServerContract = original.AuthorizationServerContract type AuthorizationServerContractBaseProperties = original.AuthorizationServerContractBaseProperties type AuthorizationServerContractProperties = original.AuthorizationServerContractProperties +type AuthorizationServerSecretsContract = original.AuthorizationServerSecretsContract type AuthorizationServerUpdateContract = original.AuthorizationServerUpdateContract type AuthorizationServerUpdateContractProperties = original.AuthorizationServerUpdateContractProperties type BackendAuthorizationHeaderCredentials = original.BackendAuthorizationHeaderCredentials @@ -497,7 +583,27 @@ type CertificateCreateOrUpdateProperties = original.CertificateCreateOrUpdatePro type CertificateInformation = original.CertificateInformation type ClientSecretContract = original.ClientSecretContract type ConnectivityStatusContract = original.ConnectivityStatusContract +type ContentItemClient = original.ContentItemClient +type ContentItemCollection = original.ContentItemCollection +type ContentItemCollectionIterator = original.ContentItemCollectionIterator +type ContentItemCollectionPage = original.ContentItemCollectionPage +type ContentItemContract = original.ContentItemContract +type ContentTypeClient = original.ContentTypeClient +type ContentTypeCollection = original.ContentTypeCollection +type ContentTypeCollectionIterator = original.ContentTypeCollectionIterator +type ContentTypeCollectionPage = original.ContentTypeCollectionPage +type ContentTypeContract = original.ContentTypeContract +type ContentTypeContractProperties = original.ContentTypeContractProperties +type DataMasking = original.DataMasking +type DataMaskingEntity = original.DataMaskingEntity type DelegationSettingsClient = original.DelegationSettingsClient +type DeletedServiceContract = original.DeletedServiceContract +type DeletedServiceContractProperties = original.DeletedServiceContractProperties +type DeletedServicesClient = original.DeletedServicesClient +type DeletedServicesCollection = original.DeletedServicesCollection +type DeletedServicesCollectionIterator = original.DeletedServicesCollectionIterator +type DeletedServicesCollectionPage = original.DeletedServicesCollectionPage +type DeletedServicesPurgeFuture = original.DeletedServicesPurgeFuture type DeployConfigurationParameterProperties = original.DeployConfigurationParameterProperties type DeployConfigurationParameters = original.DeployConfigurationParameters type DiagnosticClient = original.DiagnosticClient @@ -519,6 +625,12 @@ type ErrorFieldContract = original.ErrorFieldContract type ErrorResponse = original.ErrorResponse type ErrorResponseBody = original.ErrorResponseBody type GatewayAPIClient = original.GatewayAPIClient +type GatewayCertificateAuthorityClient = original.GatewayCertificateAuthorityClient +type GatewayCertificateAuthorityCollection = original.GatewayCertificateAuthorityCollection +type GatewayCertificateAuthorityCollectionIterator = original.GatewayCertificateAuthorityCollectionIterator +type GatewayCertificateAuthorityCollectionPage = original.GatewayCertificateAuthorityCollectionPage +type GatewayCertificateAuthorityContract = original.GatewayCertificateAuthorityContract +type GatewayCertificateAuthorityContractProperties = original.GatewayCertificateAuthorityContractProperties type GatewayClient = original.GatewayClient type GatewayCollection = original.GatewayCollection type GatewayCollectionIterator = original.GatewayCollectionIterator @@ -579,6 +691,9 @@ type IssueContractBaseProperties = original.IssueContractBaseProperties type IssueContractProperties = original.IssueContractProperties type IssueUpdateContract = original.IssueUpdateContract type IssueUpdateContractProperties = original.IssueUpdateContractProperties +type KeyVaultContractCreateProperties = original.KeyVaultContractCreateProperties +type KeyVaultContractProperties = original.KeyVaultContractProperties +type KeyVaultLastAccessStatusContractProperties = original.KeyVaultLastAccessStatusContractProperties type ListNetworkStatusContractByLocation = original.ListNetworkStatusContractByLocation type LoggerClient = original.LoggerClient type LoggerCollection = original.LoggerCollection @@ -598,6 +713,8 @@ type NamedValueCreateContract = original.NamedValueCreateContract type NamedValueCreateContractProperties = original.NamedValueCreateContractProperties type NamedValueCreateOrUpdateFuture = original.NamedValueCreateOrUpdateFuture type NamedValueEntityBaseParameters = original.NamedValueEntityBaseParameters +type NamedValueRefreshSecretFuture = original.NamedValueRefreshSecretFuture +type NamedValueSecretContract = original.NamedValueSecretContract type NamedValueUpdateFuture = original.NamedValueUpdateFuture type NamedValueUpdateParameterProperties = original.NamedValueUpdateParameterProperties type NamedValueUpdateParameters = original.NamedValueUpdateParameters @@ -635,6 +752,7 @@ type OperationListResult = original.OperationListResult type OperationListResultIterator = original.OperationListResultIterator type OperationListResultPage = original.OperationListResultPage type OperationResultContract = original.OperationResultContract +type OperationResultContractProperties = original.OperationResultContractProperties type OperationResultLogItemContract = original.OperationResultLogItemContract type OperationTagResourceContractProperties = original.OperationTagResourceContractProperties type OperationUpdateContract = original.OperationUpdateContract @@ -652,7 +770,19 @@ type PolicyDescriptionContract = original.PolicyDescriptionContract type PolicyDescriptionContractProperties = original.PolicyDescriptionContractProperties type PortalDelegationSettings = original.PortalDelegationSettings type PortalDelegationSettingsProperties = original.PortalDelegationSettingsProperties +type PortalRevisionClient = original.PortalRevisionClient +type PortalRevisionCollection = original.PortalRevisionCollection +type PortalRevisionCollectionIterator = original.PortalRevisionCollectionIterator +type PortalRevisionCollectionPage = original.PortalRevisionCollectionPage +type PortalRevisionContract = original.PortalRevisionContract +type PortalRevisionContractProperties = original.PortalRevisionContractProperties +type PortalRevisionCreateOrUpdateFuture = original.PortalRevisionCreateOrUpdateFuture +type PortalRevisionUpdateFuture = original.PortalRevisionUpdateFuture type PortalSettingValidationKeyContract = original.PortalSettingValidationKeyContract +type PortalSettingsClient = original.PortalSettingsClient +type PortalSettingsCollection = original.PortalSettingsCollection +type PortalSettingsContract = original.PortalSettingsContract +type PortalSettingsContractProperties = original.PortalSettingsContractProperties type PortalSigninSettingProperties = original.PortalSigninSettingProperties type PortalSigninSettings = original.PortalSigninSettings type PortalSignupSettings = original.PortalSignupSettings @@ -671,13 +801,13 @@ type ProductSubscriptionsClient = original.ProductSubscriptionsClient type ProductTagResourceContractProperties = original.ProductTagResourceContractProperties type ProductUpdateParameters = original.ProductUpdateParameters type ProductUpdateProperties = original.ProductUpdateProperties -type PropertyValueContract = original.PropertyValueContract type QuotaByCounterKeysClient = original.QuotaByCounterKeysClient type QuotaByPeriodKeysClient = original.QuotaByPeriodKeysClient type QuotaCounterCollection = original.QuotaCounterCollection type QuotaCounterContract = original.QuotaCounterContract type QuotaCounterValueContract = original.QuotaCounterValueContract type QuotaCounterValueContractProperties = original.QuotaCounterValueContractProperties +type QuotaCounterValueUpdateContract = original.QuotaCounterValueUpdateContract type RecipientEmailCollection = original.RecipientEmailCollection type RecipientEmailContract = original.RecipientEmailContract type RecipientEmailContractProperties = original.RecipientEmailContractProperties @@ -717,7 +847,6 @@ type SchemaCollectionIterator = original.SchemaCollectionIterator type SchemaCollectionPage = original.SchemaCollectionPage type SchemaContract = original.SchemaContract type SchemaContractProperties = original.SchemaContractProperties -type SchemaDocumentProperties = original.SchemaDocumentProperties type ServiceApplyNetworkConfigurationParameters = original.ServiceApplyNetworkConfigurationParameters type ServiceApplyNetworkConfigurationUpdatesFuture = original.ServiceApplyNetworkConfigurationUpdatesFuture type ServiceBackupFuture = original.ServiceBackupFuture @@ -727,6 +856,7 @@ type ServiceCheckNameAvailabilityParameters = original.ServiceCheckNameAvailabil type ServiceClient = original.ServiceClient type ServiceCreateOrUpdateFuture = original.ServiceCreateOrUpdateFuture type ServiceDeleteFuture = original.ServiceDeleteFuture +type ServiceGetDomainOwnershipIdentifierResult = original.ServiceGetDomainOwnershipIdentifierResult type ServiceGetSsoTokenResult = original.ServiceGetSsoTokenResult type ServiceIdentity = original.ServiceIdentity type ServiceListResult = original.ServiceListResult @@ -743,6 +873,18 @@ type ServiceUpdateParameters = original.ServiceUpdateParameters type ServiceUpdateProperties = original.ServiceUpdateProperties type SignInSettingsClient = original.SignInSettingsClient type SignUpSettingsClient = original.SignUpSettingsClient +type Sku = original.Sku +type SkuCapabilities = original.SkuCapabilities +type SkuCapacity = original.SkuCapacity +type SkuCosts = original.SkuCosts +type SkuLocationInfo = original.SkuLocationInfo +type SkuRestrictionInfo = original.SkuRestrictionInfo +type SkuRestrictions = original.SkuRestrictions +type SkuZoneDetails = original.SkuZoneDetails +type SkusClient = original.SkusClient +type SkusResult = original.SkusResult +type SkusResultIterator = original.SkusResultIterator +type SkusResultPage = original.SkusResultPage type SubscriptionClient = original.SubscriptionClient type SubscriptionCollection = original.SubscriptionCollection type SubscriptionCollectionIterator = original.SubscriptionCollectionIterator @@ -782,7 +924,14 @@ type TenantConfigurationClient = original.TenantConfigurationClient type TenantConfigurationDeployFuture = original.TenantConfigurationDeployFuture type TenantConfigurationSaveFuture = original.TenantConfigurationSaveFuture type TenantConfigurationSyncStateContract = original.TenantConfigurationSyncStateContract +type TenantConfigurationSyncStateContractProperties = original.TenantConfigurationSyncStateContractProperties type TenantConfigurationValidateFuture = original.TenantConfigurationValidateFuture +type TenantSettingsClient = original.TenantSettingsClient +type TenantSettingsCollection = original.TenantSettingsCollection +type TenantSettingsCollectionIterator = original.TenantSettingsCollectionIterator +type TenantSettingsCollectionPage = original.TenantSettingsCollectionPage +type TenantSettingsContract = original.TenantSettingsContract +type TenantSettingsContractProperties = original.TenantSettingsContractProperties type TermsOfServiceProperties = original.TermsOfServiceProperties type TokenBodyParameterContract = original.TokenBodyParameterContract type UserClient = original.UserClient @@ -928,6 +1077,12 @@ func NewAPIVersionSetCollectionIterator(page APIVersionSetCollectionPage) APIVer func NewAPIVersionSetCollectionPage(cur APIVersionSetCollection, getNextPage func(context.Context, APIVersionSetCollection) (APIVersionSetCollection, error)) APIVersionSetCollectionPage { return original.NewAPIVersionSetCollectionPage(cur, getNextPage) } +func NewAccessInformationCollectionIterator(page AccessInformationCollectionPage) AccessInformationCollectionIterator { + return original.NewAccessInformationCollectionIterator(page) +} +func NewAccessInformationCollectionPage(cur AccessInformationCollection, getNextPage func(context.Context, AccessInformationCollection) (AccessInformationCollection, error)) AccessInformationCollectionPage { + return original.NewAccessInformationCollectionPage(cur, getNextPage) +} func NewAuthorizationServerClient(subscriptionID string) AuthorizationServerClient { return original.NewAuthorizationServerClient(subscriptionID) } @@ -976,12 +1131,48 @@ func NewCertificateCollectionIterator(page CertificateCollectionPage) Certificat func NewCertificateCollectionPage(cur CertificateCollection, getNextPage func(context.Context, CertificateCollection) (CertificateCollection, error)) CertificateCollectionPage { return original.NewCertificateCollectionPage(cur, getNextPage) } +func NewContentItemClient(subscriptionID string) ContentItemClient { + return original.NewContentItemClient(subscriptionID) +} +func NewContentItemClientWithBaseURI(baseURI string, subscriptionID string) ContentItemClient { + return original.NewContentItemClientWithBaseURI(baseURI, subscriptionID) +} +func NewContentItemCollectionIterator(page ContentItemCollectionPage) ContentItemCollectionIterator { + return original.NewContentItemCollectionIterator(page) +} +func NewContentItemCollectionPage(cur ContentItemCollection, getNextPage func(context.Context, ContentItemCollection) (ContentItemCollection, error)) ContentItemCollectionPage { + return original.NewContentItemCollectionPage(cur, getNextPage) +} +func NewContentTypeClient(subscriptionID string) ContentTypeClient { + return original.NewContentTypeClient(subscriptionID) +} +func NewContentTypeClientWithBaseURI(baseURI string, subscriptionID string) ContentTypeClient { + return original.NewContentTypeClientWithBaseURI(baseURI, subscriptionID) +} +func NewContentTypeCollectionIterator(page ContentTypeCollectionPage) ContentTypeCollectionIterator { + return original.NewContentTypeCollectionIterator(page) +} +func NewContentTypeCollectionPage(cur ContentTypeCollection, getNextPage func(context.Context, ContentTypeCollection) (ContentTypeCollection, error)) ContentTypeCollectionPage { + return original.NewContentTypeCollectionPage(cur, getNextPage) +} func NewDelegationSettingsClient(subscriptionID string) DelegationSettingsClient { return original.NewDelegationSettingsClient(subscriptionID) } func NewDelegationSettingsClientWithBaseURI(baseURI string, subscriptionID string) DelegationSettingsClient { return original.NewDelegationSettingsClientWithBaseURI(baseURI, subscriptionID) } +func NewDeletedServicesClient(subscriptionID string) DeletedServicesClient { + return original.NewDeletedServicesClient(subscriptionID) +} +func NewDeletedServicesClientWithBaseURI(baseURI string, subscriptionID string) DeletedServicesClient { + return original.NewDeletedServicesClientWithBaseURI(baseURI, subscriptionID) +} +func NewDeletedServicesCollectionIterator(page DeletedServicesCollectionPage) DeletedServicesCollectionIterator { + return original.NewDeletedServicesCollectionIterator(page) +} +func NewDeletedServicesCollectionPage(cur DeletedServicesCollection, getNextPage func(context.Context, DeletedServicesCollection) (DeletedServicesCollection, error)) DeletedServicesCollectionPage { + return original.NewDeletedServicesCollectionPage(cur, getNextPage) +} func NewDiagnosticClient(subscriptionID string) DiagnosticClient { return original.NewDiagnosticClient(subscriptionID) } @@ -1012,6 +1203,18 @@ func NewGatewayAPIClient(subscriptionID string) GatewayAPIClient { func NewGatewayAPIClientWithBaseURI(baseURI string, subscriptionID string) GatewayAPIClient { return original.NewGatewayAPIClientWithBaseURI(baseURI, subscriptionID) } +func NewGatewayCertificateAuthorityClient(subscriptionID string) GatewayCertificateAuthorityClient { + return original.NewGatewayCertificateAuthorityClient(subscriptionID) +} +func NewGatewayCertificateAuthorityClientWithBaseURI(baseURI string, subscriptionID string) GatewayCertificateAuthorityClient { + return original.NewGatewayCertificateAuthorityClientWithBaseURI(baseURI, subscriptionID) +} +func NewGatewayCertificateAuthorityCollectionIterator(page GatewayCertificateAuthorityCollectionPage) GatewayCertificateAuthorityCollectionIterator { + return original.NewGatewayCertificateAuthorityCollectionIterator(page) +} +func NewGatewayCertificateAuthorityCollectionPage(cur GatewayCertificateAuthorityCollection, getNextPage func(context.Context, GatewayCertificateAuthorityCollection) (GatewayCertificateAuthorityCollection, error)) GatewayCertificateAuthorityCollectionPage { + return original.NewGatewayCertificateAuthorityCollectionPage(cur, getNextPage) +} func NewGatewayClient(subscriptionID string) GatewayClient { return original.NewGatewayClient(subscriptionID) } @@ -1192,6 +1395,24 @@ func NewPolicyDescriptionClient(subscriptionID string) PolicyDescriptionClient { func NewPolicyDescriptionClientWithBaseURI(baseURI string, subscriptionID string) PolicyDescriptionClient { return original.NewPolicyDescriptionClientWithBaseURI(baseURI, subscriptionID) } +func NewPortalRevisionClient(subscriptionID string) PortalRevisionClient { + return original.NewPortalRevisionClient(subscriptionID) +} +func NewPortalRevisionClientWithBaseURI(baseURI string, subscriptionID string) PortalRevisionClient { + return original.NewPortalRevisionClientWithBaseURI(baseURI, subscriptionID) +} +func NewPortalRevisionCollectionIterator(page PortalRevisionCollectionPage) PortalRevisionCollectionIterator { + return original.NewPortalRevisionCollectionIterator(page) +} +func NewPortalRevisionCollectionPage(cur PortalRevisionCollection, getNextPage func(context.Context, PortalRevisionCollection) (PortalRevisionCollection, error)) PortalRevisionCollectionPage { + return original.NewPortalRevisionCollectionPage(cur, getNextPage) +} +func NewPortalSettingsClient(subscriptionID string) PortalSettingsClient { + return original.NewPortalSettingsClient(subscriptionID) +} +func NewPortalSettingsClientWithBaseURI(baseURI string, subscriptionID string) PortalSettingsClient { + return original.NewPortalSettingsClientWithBaseURI(baseURI, subscriptionID) +} func NewProductAPIClient(subscriptionID string) ProductAPIClient { return original.NewProductAPIClient(subscriptionID) } @@ -1306,6 +1527,18 @@ func NewSignUpSettingsClient(subscriptionID string) SignUpSettingsClient { func NewSignUpSettingsClientWithBaseURI(baseURI string, subscriptionID string) SignUpSettingsClient { return original.NewSignUpSettingsClientWithBaseURI(baseURI, subscriptionID) } +func NewSkusClient(subscriptionID string) SkusClient { + return original.NewSkusClient(subscriptionID) +} +func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient { + return original.NewSkusClientWithBaseURI(baseURI, subscriptionID) +} +func NewSkusResultIterator(page SkusResultPage) SkusResultIterator { + return original.NewSkusResultIterator(page) +} +func NewSkusResultPage(cur SkusResult, getNextPage func(context.Context, SkusResult) (SkusResult, error)) SkusResultPage { + return original.NewSkusResultPage(cur, getNextPage) +} func NewSubscriptionClient(subscriptionID string) SubscriptionClient { return original.NewSubscriptionClient(subscriptionID) } @@ -1366,6 +1599,18 @@ func NewTenantConfigurationClient(subscriptionID string) TenantConfigurationClie func NewTenantConfigurationClientWithBaseURI(baseURI string, subscriptionID string) TenantConfigurationClient { return original.NewTenantConfigurationClientWithBaseURI(baseURI, subscriptionID) } +func NewTenantSettingsClient(subscriptionID string) TenantSettingsClient { + return original.NewTenantSettingsClient(subscriptionID) +} +func NewTenantSettingsClientWithBaseURI(baseURI string, subscriptionID string) TenantSettingsClient { + return original.NewTenantSettingsClientWithBaseURI(baseURI, subscriptionID) +} +func NewTenantSettingsCollectionIterator(page TenantSettingsCollectionPage) TenantSettingsCollectionIterator { + return original.NewTenantSettingsCollectionIterator(page) +} +func NewTenantSettingsCollectionPage(cur TenantSettingsCollection, getNextPage func(context.Context, TenantSettingsCollection) (TenantSettingsCollection, error)) TenantSettingsCollectionPage { + return original.NewTenantSettingsCollectionPage(cur, getNextPage) +} func NewUserClient(subscriptionID string) UserClient { return original.NewUserClient(subscriptionID) } @@ -1414,6 +1659,9 @@ func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { func PossibleAPITypeValues() []APIType { return original.PossibleAPITypeValues() } +func PossibleAccessIDNameValues() []AccessIDName { + return original.PossibleAccessIDNameValues() +} func PossibleAlwaysLogValues() []AlwaysLog { return original.PossibleAlwaysLogValues() } @@ -1438,6 +1686,12 @@ func PossibleBearerTokenSendingMethodValues() []BearerTokenSendingMethod { func PossibleBearerTokenSendingMethodsValues() []BearerTokenSendingMethods { return original.PossibleBearerTokenSendingMethodsValues() } +func PossibleCertificateSourceValues() []CertificateSource { + return original.PossibleCertificateSourceValues() +} +func PossibleCertificateStatusValues() []CertificateStatus { + return original.PossibleCertificateStatusValues() +} func PossibleClientAuthenticationMethodValues() []ClientAuthenticationMethod { return original.PossibleClientAuthenticationMethodValues() } @@ -1450,6 +1704,9 @@ func PossibleConnectivityStatusTypeValues() []ConnectivityStatusType { func PossibleContentFormatValues() []ContentFormat { return original.PossibleContentFormatValues() } +func PossibleDataMaskingModeValues() []DataMaskingMode { + return original.PossibleDataMaskingModeValues() +} func PossibleExportFormatValues() []ExportFormat { return original.PossibleExportFormatValues() } @@ -1483,6 +1740,9 @@ func PossibleNameAvailabilityReasonValues() []NameAvailabilityReason { func PossibleNotificationNameValues() []NotificationName { return original.PossibleNotificationNameValues() } +func PossibleOperationNameFormatValues() []OperationNameFormat { + return original.PossibleOperationNameFormatValues() +} func PossiblePolicyContentFormatValues() []PolicyContentFormat { return original.PossiblePolicyContentFormatValues() } @@ -1492,6 +1752,9 @@ func PossiblePolicyExportFormatValues() []PolicyExportFormat { func PossiblePolicyScopeContractValues() []PolicyScopeContract { return original.PossiblePolicyScopeContractValues() } +func PossiblePortalRevisionStatusValues() []PortalRevisionStatus { + return original.PossiblePortalRevisionStatusValues() +} func PossibleProductStateValues() []ProductState { return original.PossibleProductStateValues() } @@ -1507,6 +1770,15 @@ func PossibleResourceSkuCapacityScaleTypeValues() []ResourceSkuCapacityScaleType func PossibleSamplingTypeValues() []SamplingType { return original.PossibleSamplingTypeValues() } +func PossibleSkuCapacityScaleTypeValues() []SkuCapacityScaleType { + return original.PossibleSkuCapacityScaleTypeValues() +} +func PossibleSkuRestrictionsReasonCodeValues() []SkuRestrictionsReasonCode { + return original.PossibleSkuRestrictionsReasonCodeValues() +} +func PossibleSkuRestrictionsTypeValues() []SkuRestrictionsType { + return original.PossibleSkuRestrictionsTypeValues() +} func PossibleSkuTypeValues() []SkuType { return original.PossibleSkuTypeValues() } diff --git a/profiles/preview/preview/appinsights/mgmt/insights/insightsapi/models.go b/profiles/preview/preview/appinsights/mgmt/insights/insightsapi/models.go new file mode 100644 index 000000000000..9909ab142154 --- /dev/null +++ b/profiles/preview/preview/appinsights/mgmt/insights/insightsapi/models.go @@ -0,0 +1,30 @@ +// +build go1.9 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package insightsapi + +import original "github.com/Azure/azure-sdk-for-go/services/preview/appinsights/mgmt/2020-02-02-preview/insights/insightsapi" + +type APIKeysClientAPI = original.APIKeysClientAPI +type AnalyticsItemsClientAPI = original.AnalyticsItemsClientAPI +type AnnotationsClientAPI = original.AnnotationsClientAPI +type ComponentAvailableFeaturesClientAPI = original.ComponentAvailableFeaturesClientAPI +type ComponentCurrentBillingFeaturesClientAPI = original.ComponentCurrentBillingFeaturesClientAPI +type ComponentFeatureCapabilitiesClientAPI = original.ComponentFeatureCapabilitiesClientAPI +type ComponentLinkedStorageAccountsClientAPI = original.ComponentLinkedStorageAccountsClientAPI +type ComponentQuotaStatusClientAPI = original.ComponentQuotaStatusClientAPI +type ComponentsClientAPI = original.ComponentsClientAPI +type ExportConfigurationsClientAPI = original.ExportConfigurationsClientAPI +type FavoritesClientAPI = original.FavoritesClientAPI +type MyWorkbooksClientAPI = original.MyWorkbooksClientAPI +type OperationsClientAPI = original.OperationsClientAPI +type ProactiveDetectionConfigurationsClientAPI = original.ProactiveDetectionConfigurationsClientAPI +type WebTestLocationsClientAPI = original.WebTestLocationsClientAPI +type WebTestsClientAPI = original.WebTestsClientAPI +type WorkItemConfigurationsClientAPI = original.WorkItemConfigurationsClientAPI +type WorkbooksClientAPI = original.WorkbooksClientAPI diff --git a/profiles/preview/preview/appinsights/mgmt/insights/models.go b/profiles/preview/preview/appinsights/mgmt/insights/models.go new file mode 100644 index 000000000000..0b997caef5ee --- /dev/null +++ b/profiles/preview/preview/appinsights/mgmt/insights/models.go @@ -0,0 +1,421 @@ +// +build go1.9 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package insights + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/preview/appinsights/mgmt/2020-02-02-preview/insights" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type ApplicationType = original.ApplicationType + +const ( + ApplicationTypeOther ApplicationType = original.ApplicationTypeOther + ApplicationTypeWeb ApplicationType = original.ApplicationTypeWeb +) + +type CategoryType = original.CategoryType + +const ( + CategoryTypePerformance CategoryType = original.CategoryTypePerformance + CategoryTypeRetention CategoryType = original.CategoryTypeRetention + CategoryTypeTSG CategoryType = original.CategoryTypeTSG + CategoryTypeWorkbook CategoryType = original.CategoryTypeWorkbook +) + +type FavoriteSourceType = original.FavoriteSourceType + +const ( + FavoriteSourceTypeEvents FavoriteSourceType = original.FavoriteSourceTypeEvents + FavoriteSourceTypeFunnel FavoriteSourceType = original.FavoriteSourceTypeFunnel + FavoriteSourceTypeImpact FavoriteSourceType = original.FavoriteSourceTypeImpact + FavoriteSourceTypeNotebook FavoriteSourceType = original.FavoriteSourceTypeNotebook + FavoriteSourceTypeRetention FavoriteSourceType = original.FavoriteSourceTypeRetention + FavoriteSourceTypeSegmentation FavoriteSourceType = original.FavoriteSourceTypeSegmentation + FavoriteSourceTypeSessions FavoriteSourceType = original.FavoriteSourceTypeSessions + FavoriteSourceTypeUserflows FavoriteSourceType = original.FavoriteSourceTypeUserflows +) + +type FavoriteType = original.FavoriteType + +const ( + FavoriteTypeShared FavoriteType = original.FavoriteTypeShared + FavoriteTypeUser FavoriteType = original.FavoriteTypeUser +) + +type FlowType = original.FlowType + +const ( + FlowTypeBluefield FlowType = original.FlowTypeBluefield +) + +type IngestionMode = original.IngestionMode + +const ( + IngestionModeApplicationInsights IngestionMode = original.IngestionModeApplicationInsights + IngestionModeApplicationInsightsWithDiagnosticSettings IngestionMode = original.IngestionModeApplicationInsightsWithDiagnosticSettings + IngestionModeLogAnalytics IngestionMode = original.IngestionModeLogAnalytics +) + +type ItemScope = original.ItemScope + +const ( + ItemScopeShared ItemScope = original.ItemScopeShared + ItemScopeUser ItemScope = original.ItemScopeUser +) + +type ItemScopePath = original.ItemScopePath + +const ( + ItemScopePathAnalyticsItems ItemScopePath = original.ItemScopePathAnalyticsItems + ItemScopePathMyanalyticsItems ItemScopePath = original.ItemScopePathMyanalyticsItems +) + +type ItemType = original.ItemType + +const ( + ItemTypeFolder ItemType = original.ItemTypeFolder + ItemTypeFunction ItemType = original.ItemTypeFunction + ItemTypeQuery ItemType = original.ItemTypeQuery + ItemTypeRecent ItemType = original.ItemTypeRecent +) + +type ItemTypeParameter = original.ItemTypeParameter + +const ( + ItemTypeParameterFolder ItemTypeParameter = original.ItemTypeParameterFolder + ItemTypeParameterFunction ItemTypeParameter = original.ItemTypeParameterFunction + ItemTypeParameterNone ItemTypeParameter = original.ItemTypeParameterNone + ItemTypeParameterQuery ItemTypeParameter = original.ItemTypeParameterQuery + ItemTypeParameterRecent ItemTypeParameter = original.ItemTypeParameterRecent +) + +type PublicNetworkAccessType = original.PublicNetworkAccessType + +const ( + PublicNetworkAccessTypeDisabled PublicNetworkAccessType = original.PublicNetworkAccessTypeDisabled + PublicNetworkAccessTypeEnabled PublicNetworkAccessType = original.PublicNetworkAccessTypeEnabled +) + +type PurgeState = original.PurgeState + +const ( + PurgeStateCompleted PurgeState = original.PurgeStateCompleted + PurgeStatePending PurgeState = original.PurgeStatePending +) + +type RequestSource = original.RequestSource + +const ( + RequestSourceRest RequestSource = original.RequestSourceRest +) + +type SharedTypeKind = original.SharedTypeKind + +const ( + SharedTypeKindShared SharedTypeKind = original.SharedTypeKindShared + SharedTypeKindUser SharedTypeKind = original.SharedTypeKindUser +) + +type WebTestKind = original.WebTestKind + +const ( + WebTestKindMultistep WebTestKind = original.WebTestKindMultistep + WebTestKindPing WebTestKind = original.WebTestKindPing +) + +type APIKeyRequest = original.APIKeyRequest +type APIKeysClient = original.APIKeysClient +type AnalyticsItemsClient = original.AnalyticsItemsClient +type Annotation = original.Annotation +type AnnotationError = original.AnnotationError +type AnnotationsClient = original.AnnotationsClient +type AnnotationsListResult = original.AnnotationsListResult +type ApplicationInsightsComponent = original.ApplicationInsightsComponent +type ApplicationInsightsComponentAPIKey = original.ApplicationInsightsComponentAPIKey +type ApplicationInsightsComponentAPIKeyListResult = original.ApplicationInsightsComponentAPIKeyListResult +type ApplicationInsightsComponentAnalyticsItem = original.ApplicationInsightsComponentAnalyticsItem +type ApplicationInsightsComponentAnalyticsItemProperties = original.ApplicationInsightsComponentAnalyticsItemProperties +type ApplicationInsightsComponentAvailableFeatures = original.ApplicationInsightsComponentAvailableFeatures +type ApplicationInsightsComponentBillingFeatures = original.ApplicationInsightsComponentBillingFeatures +type ApplicationInsightsComponentDataVolumeCap = original.ApplicationInsightsComponentDataVolumeCap +type ApplicationInsightsComponentExportConfiguration = original.ApplicationInsightsComponentExportConfiguration +type ApplicationInsightsComponentExportRequest = original.ApplicationInsightsComponentExportRequest +type ApplicationInsightsComponentFavorite = original.ApplicationInsightsComponentFavorite +type ApplicationInsightsComponentFeature = original.ApplicationInsightsComponentFeature +type ApplicationInsightsComponentFeatureCapabilities = original.ApplicationInsightsComponentFeatureCapabilities +type ApplicationInsightsComponentFeatureCapability = original.ApplicationInsightsComponentFeatureCapability +type ApplicationInsightsComponentListResult = original.ApplicationInsightsComponentListResult +type ApplicationInsightsComponentListResultIterator = original.ApplicationInsightsComponentListResultIterator +type ApplicationInsightsComponentListResultPage = original.ApplicationInsightsComponentListResultPage +type ApplicationInsightsComponentProactiveDetectionConfiguration = original.ApplicationInsightsComponentProactiveDetectionConfiguration +type ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions = original.ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions +type ApplicationInsightsComponentProperties = original.ApplicationInsightsComponentProperties +type ApplicationInsightsComponentQuotaStatus = original.ApplicationInsightsComponentQuotaStatus +type ApplicationInsightsComponentWebTestLocation = original.ApplicationInsightsComponentWebTestLocation +type ApplicationInsightsWebTestLocationsListResult = original.ApplicationInsightsWebTestLocationsListResult +type AzureEntityResource = original.AzureEntityResource +type BaseClient = original.BaseClient +type ComponentAvailableFeaturesClient = original.ComponentAvailableFeaturesClient +type ComponentCurrentBillingFeaturesClient = original.ComponentCurrentBillingFeaturesClient +type ComponentFeatureCapabilitiesClient = original.ComponentFeatureCapabilitiesClient +type ComponentLinkedStorageAccounts = original.ComponentLinkedStorageAccounts +type ComponentLinkedStorageAccountsClient = original.ComponentLinkedStorageAccountsClient +type ComponentLinkedStorageAccountsPatch = original.ComponentLinkedStorageAccountsPatch +type ComponentPurgeBody = original.ComponentPurgeBody +type ComponentPurgeBodyFilters = original.ComponentPurgeBodyFilters +type ComponentPurgeResponse = original.ComponentPurgeResponse +type ComponentPurgeStatusResponse = original.ComponentPurgeStatusResponse +type ComponentQuotaStatusClient = original.ComponentQuotaStatusClient +type ComponentsClient = original.ComponentsClient +type ComponentsResource = original.ComponentsResource +type ErrorFieldContract = original.ErrorFieldContract +type ErrorResponse = original.ErrorResponse +type ErrorResponseComponents = original.ErrorResponseComponents +type ErrorResponseComponentsError = original.ErrorResponseComponentsError +type ErrorResponseLinkedStorage = original.ErrorResponseLinkedStorage +type ErrorResponseLinkedStorageError = original.ErrorResponseLinkedStorageError +type ExportConfigurationsClient = original.ExportConfigurationsClient +type FavoritesClient = original.FavoritesClient +type InnerError = original.InnerError +type LinkProperties = original.LinkProperties +type LinkedStorageAccountsProperties = original.LinkedStorageAccountsProperties +type ListAnnotation = original.ListAnnotation +type ListApplicationInsightsComponentAnalyticsItem = original.ListApplicationInsightsComponentAnalyticsItem +type ListApplicationInsightsComponentExportConfiguration = original.ListApplicationInsightsComponentExportConfiguration +type ListApplicationInsightsComponentFavorite = original.ListApplicationInsightsComponentFavorite +type ListApplicationInsightsComponentProactiveDetectionConfiguration = original.ListApplicationInsightsComponentProactiveDetectionConfiguration +type MyWorkbook = original.MyWorkbook +type MyWorkbookError = original.MyWorkbookError +type MyWorkbookProperties = original.MyWorkbookProperties +type MyWorkbookResource = original.MyWorkbookResource +type MyWorkbooksClient = original.MyWorkbooksClient +type MyWorkbooksListResult = original.MyWorkbooksListResult +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationListResultIterator = original.OperationListResultIterator +type OperationListResultPage = original.OperationListResultPage +type OperationsClient = original.OperationsClient +type PrivateLinkScopedResource = original.PrivateLinkScopedResource +type ProactiveDetectionConfigurationsClient = original.ProactiveDetectionConfigurationsClient +type ProxyResource = original.ProxyResource +type Resource = original.Resource +type TagsResource = original.TagsResource +type TrackedResource = original.TrackedResource +type WebTest = original.WebTest +type WebTestGeolocation = original.WebTestGeolocation +type WebTestListResult = original.WebTestListResult +type WebTestListResultIterator = original.WebTestListResultIterator +type WebTestListResultPage = original.WebTestListResultPage +type WebTestLocationsClient = original.WebTestLocationsClient +type WebTestProperties = original.WebTestProperties +type WebTestPropertiesConfiguration = original.WebTestPropertiesConfiguration +type WebTestsClient = original.WebTestsClient +type WebtestsResource = original.WebtestsResource +type WorkItemConfiguration = original.WorkItemConfiguration +type WorkItemConfigurationError = original.WorkItemConfigurationError +type WorkItemConfigurationsClient = original.WorkItemConfigurationsClient +type WorkItemConfigurationsListResult = original.WorkItemConfigurationsListResult +type WorkItemCreateConfiguration = original.WorkItemCreateConfiguration +type Workbook = original.Workbook +type WorkbookError = original.WorkbookError +type WorkbookProperties = original.WorkbookProperties +type WorkbookResource = original.WorkbookResource +type WorkbooksClient = original.WorkbooksClient +type WorkbooksListResult = original.WorkbooksListResult + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewAPIKeysClient(subscriptionID string) APIKeysClient { + return original.NewAPIKeysClient(subscriptionID) +} +func NewAPIKeysClientWithBaseURI(baseURI string, subscriptionID string) APIKeysClient { + return original.NewAPIKeysClientWithBaseURI(baseURI, subscriptionID) +} +func NewAnalyticsItemsClient(subscriptionID string) AnalyticsItemsClient { + return original.NewAnalyticsItemsClient(subscriptionID) +} +func NewAnalyticsItemsClientWithBaseURI(baseURI string, subscriptionID string) AnalyticsItemsClient { + return original.NewAnalyticsItemsClientWithBaseURI(baseURI, subscriptionID) +} +func NewAnnotationsClient(subscriptionID string) AnnotationsClient { + return original.NewAnnotationsClient(subscriptionID) +} +func NewAnnotationsClientWithBaseURI(baseURI string, subscriptionID string) AnnotationsClient { + return original.NewAnnotationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewApplicationInsightsComponentListResultIterator(page ApplicationInsightsComponentListResultPage) ApplicationInsightsComponentListResultIterator { + return original.NewApplicationInsightsComponentListResultIterator(page) +} +func NewApplicationInsightsComponentListResultPage(cur ApplicationInsightsComponentListResult, getNextPage func(context.Context, ApplicationInsightsComponentListResult) (ApplicationInsightsComponentListResult, error)) ApplicationInsightsComponentListResultPage { + return original.NewApplicationInsightsComponentListResultPage(cur, getNextPage) +} +func NewComponentAvailableFeaturesClient(subscriptionID string) ComponentAvailableFeaturesClient { + return original.NewComponentAvailableFeaturesClient(subscriptionID) +} +func NewComponentAvailableFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentAvailableFeaturesClient { + return original.NewComponentAvailableFeaturesClientWithBaseURI(baseURI, subscriptionID) +} +func NewComponentCurrentBillingFeaturesClient(subscriptionID string) ComponentCurrentBillingFeaturesClient { + return original.NewComponentCurrentBillingFeaturesClient(subscriptionID) +} +func NewComponentCurrentBillingFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentCurrentBillingFeaturesClient { + return original.NewComponentCurrentBillingFeaturesClientWithBaseURI(baseURI, subscriptionID) +} +func NewComponentFeatureCapabilitiesClient(subscriptionID string) ComponentFeatureCapabilitiesClient { + return original.NewComponentFeatureCapabilitiesClient(subscriptionID) +} +func NewComponentFeatureCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) ComponentFeatureCapabilitiesClient { + return original.NewComponentFeatureCapabilitiesClientWithBaseURI(baseURI, subscriptionID) +} +func NewComponentLinkedStorageAccountsClient(subscriptionID string) ComponentLinkedStorageAccountsClient { + return original.NewComponentLinkedStorageAccountsClient(subscriptionID) +} +func NewComponentLinkedStorageAccountsClientWithBaseURI(baseURI string, subscriptionID string) ComponentLinkedStorageAccountsClient { + return original.NewComponentLinkedStorageAccountsClientWithBaseURI(baseURI, subscriptionID) +} +func NewComponentQuotaStatusClient(subscriptionID string) ComponentQuotaStatusClient { + return original.NewComponentQuotaStatusClient(subscriptionID) +} +func NewComponentQuotaStatusClientWithBaseURI(baseURI string, subscriptionID string) ComponentQuotaStatusClient { + return original.NewComponentQuotaStatusClientWithBaseURI(baseURI, subscriptionID) +} +func NewComponentsClient(subscriptionID string) ComponentsClient { + return original.NewComponentsClient(subscriptionID) +} +func NewComponentsClientWithBaseURI(baseURI string, subscriptionID string) ComponentsClient { + return original.NewComponentsClientWithBaseURI(baseURI, subscriptionID) +} +func NewExportConfigurationsClient(subscriptionID string) ExportConfigurationsClient { + return original.NewExportConfigurationsClient(subscriptionID) +} +func NewExportConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ExportConfigurationsClient { + return original.NewExportConfigurationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewFavoritesClient(subscriptionID string) FavoritesClient { + return original.NewFavoritesClient(subscriptionID) +} +func NewFavoritesClientWithBaseURI(baseURI string, subscriptionID string) FavoritesClient { + return original.NewFavoritesClientWithBaseURI(baseURI, subscriptionID) +} +func NewMyWorkbooksClient(subscriptionID string) MyWorkbooksClient { + return original.NewMyWorkbooksClient(subscriptionID) +} +func NewMyWorkbooksClientWithBaseURI(baseURI string, subscriptionID string) MyWorkbooksClient { + return original.NewMyWorkbooksClientWithBaseURI(baseURI, subscriptionID) +} +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return original.NewOperationListResultIterator(page) +} +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return original.NewOperationListResultPage(cur, getNextPage) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewProactiveDetectionConfigurationsClient(subscriptionID string) ProactiveDetectionConfigurationsClient { + return original.NewProactiveDetectionConfigurationsClient(subscriptionID) +} +func NewProactiveDetectionConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ProactiveDetectionConfigurationsClient { + return original.NewProactiveDetectionConfigurationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewWebTestListResultIterator(page WebTestListResultPage) WebTestListResultIterator { + return original.NewWebTestListResultIterator(page) +} +func NewWebTestListResultPage(cur WebTestListResult, getNextPage func(context.Context, WebTestListResult) (WebTestListResult, error)) WebTestListResultPage { + return original.NewWebTestListResultPage(cur, getNextPage) +} +func NewWebTestLocationsClient(subscriptionID string) WebTestLocationsClient { + return original.NewWebTestLocationsClient(subscriptionID) +} +func NewWebTestLocationsClientWithBaseURI(baseURI string, subscriptionID string) WebTestLocationsClient { + return original.NewWebTestLocationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewWebTestsClient(subscriptionID string) WebTestsClient { + return original.NewWebTestsClient(subscriptionID) +} +func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string) WebTestsClient { + return original.NewWebTestsClientWithBaseURI(baseURI, subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func NewWorkItemConfigurationsClient(subscriptionID string) WorkItemConfigurationsClient { + return original.NewWorkItemConfigurationsClient(subscriptionID) +} +func NewWorkItemConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) WorkItemConfigurationsClient { + return original.NewWorkItemConfigurationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewWorkbooksClient(subscriptionID string) WorkbooksClient { + return original.NewWorkbooksClient(subscriptionID) +} +func NewWorkbooksClientWithBaseURI(baseURI string, subscriptionID string) WorkbooksClient { + return original.NewWorkbooksClientWithBaseURI(baseURI, subscriptionID) +} +func PossibleApplicationTypeValues() []ApplicationType { + return original.PossibleApplicationTypeValues() +} +func PossibleCategoryTypeValues() []CategoryType { + return original.PossibleCategoryTypeValues() +} +func PossibleFavoriteSourceTypeValues() []FavoriteSourceType { + return original.PossibleFavoriteSourceTypeValues() +} +func PossibleFavoriteTypeValues() []FavoriteType { + return original.PossibleFavoriteTypeValues() +} +func PossibleFlowTypeValues() []FlowType { + return original.PossibleFlowTypeValues() +} +func PossibleIngestionModeValues() []IngestionMode { + return original.PossibleIngestionModeValues() +} +func PossibleItemScopePathValues() []ItemScopePath { + return original.PossibleItemScopePathValues() +} +func PossibleItemScopeValues() []ItemScope { + return original.PossibleItemScopeValues() +} +func PossibleItemTypeParameterValues() []ItemTypeParameter { + return original.PossibleItemTypeParameterValues() +} +func PossibleItemTypeValues() []ItemType { + return original.PossibleItemTypeValues() +} +func PossiblePublicNetworkAccessTypeValues() []PublicNetworkAccessType { + return original.PossiblePublicNetworkAccessTypeValues() +} +func PossiblePurgeStateValues() []PurgeState { + return original.PossiblePurgeStateValues() +} +func PossibleRequestSourceValues() []RequestSource { + return original.PossibleRequestSourceValues() +} +func PossibleSharedTypeKindValues() []SharedTypeKind { + return original.PossibleSharedTypeKindValues() +} +func PossibleWebTestKindValues() []WebTestKind { + return original.PossibleWebTestKindValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/profiles/preview/preview/signalr/mgmt/signalr/models.go b/profiles/preview/preview/signalr/mgmt/signalr/models.go index da485d0b414b..17fd349aa540 100644 --- a/profiles/preview/preview/signalr/mgmt/signalr/models.go +++ b/profiles/preview/preview/signalr/mgmt/signalr/models.go @@ -11,7 +11,7 @@ package signalr import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/preview/signalr/mgmt/2021-04-01-preview/signalr" + original "github.com/Azure/azure-sdk-for-go/services/preview/signalr/mgmt/2021-06-01-preview/signalr" ) const ( diff --git a/profiles/preview/preview/signalr/mgmt/signalr/signalrapi/models.go b/profiles/preview/preview/signalr/mgmt/signalr/signalrapi/models.go index 2fafc5e22184..5cf1639a6228 100644 --- a/profiles/preview/preview/signalr/mgmt/signalr/signalrapi/models.go +++ b/profiles/preview/preview/signalr/mgmt/signalr/signalrapi/models.go @@ -8,7 +8,7 @@ package signalrapi -import original "github.com/Azure/azure-sdk-for-go/services/preview/signalr/mgmt/2021-04-01-preview/signalr/signalrapi" +import original "github.com/Azure/azure-sdk-for-go/services/preview/signalr/mgmt/2021-06-01-preview/signalr/signalrapi" type ClientAPI = original.ClientAPI type OperationsClientAPI = original.OperationsClientAPI diff --git a/profiles/preview/preview/webpubsub/mgmt/webpubsub/models.go b/profiles/preview/preview/webpubsub/mgmt/webpubsub/models.go index 4f262b7a7648..953d2212a645 100644 --- a/profiles/preview/preview/webpubsub/mgmt/webpubsub/models.go +++ b/profiles/preview/preview/webpubsub/mgmt/webpubsub/models.go @@ -11,7 +11,7 @@ package webpubsub import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/preview/webpubsub/mgmt/2021-04-01-preview/webpubsub" + original "github.com/Azure/azure-sdk-for-go/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub" ) const ( @@ -34,14 +34,6 @@ const ( CreatedByTypeUser CreatedByType = original.CreatedByTypeUser ) -type FeatureFlags = original.FeatureFlags - -const ( - FeatureFlagsEnableConnectivityLogs FeatureFlags = original.FeatureFlagsEnableConnectivityLogs - FeatureFlagsEnableLiveTrace FeatureFlags = original.FeatureFlagsEnableLiveTrace - FeatureFlagsEnableMessagingLogs FeatureFlags = original.FeatureFlagsEnableMessagingLogs -) - type KeyType = original.KeyType const ( @@ -119,13 +111,13 @@ type BaseClient = original.BaseClient type Client = original.Client type CreateOrUpdateFuture = original.CreateOrUpdateFuture type DeleteFuture = original.DeleteFuture +type DiagnosticConfiguration = original.DiagnosticConfiguration type Dimension = original.Dimension type ErrorAdditionalInfo = original.ErrorAdditionalInfo type ErrorDetail = original.ErrorDetail type ErrorResponse = original.ErrorResponse type EventHandlerSettings = original.EventHandlerSettings type EventHandlerTemplate = original.EventHandlerTemplate -type Feature = original.Feature type Keys = original.Keys type LogSpecification = original.LogSpecification type ManagedIdentity = original.ManagedIdentity @@ -277,9 +269,6 @@ func PossibleACLActionValues() []ACLAction { func PossibleCreatedByTypeValues() []CreatedByType { return original.PossibleCreatedByTypeValues() } -func PossibleFeatureFlagsValues() []FeatureFlags { - return original.PossibleFeatureFlagsValues() -} func PossibleKeyTypeValues() []KeyType { return original.PossibleKeyTypeValues() } diff --git a/profiles/preview/preview/webpubsub/mgmt/webpubsub/webpubsubapi/models.go b/profiles/preview/preview/webpubsub/mgmt/webpubsub/webpubsubapi/models.go index d6217fcacda5..cf99b29cdcce 100644 --- a/profiles/preview/preview/webpubsub/mgmt/webpubsub/webpubsubapi/models.go +++ b/profiles/preview/preview/webpubsub/mgmt/webpubsub/webpubsubapi/models.go @@ -8,7 +8,7 @@ package webpubsubapi -import original "github.com/Azure/azure-sdk-for-go/services/preview/webpubsub/mgmt/2021-04-01-preview/webpubsub/webpubsubapi" +import original "github.com/Azure/azure-sdk-for-go/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/webpubsubapi" type ClientAPI = original.ClientAPI type OperationsClientAPI = original.OperationsClientAPI diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/CHANGELOG.md b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/_meta.json b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/_meta.json new file mode 100644 index 000000000000..c4bd5c46a006 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "b548283ea6f4b3d797e85432fcc6e3ff2a2ac224", + "readme": "/_/azure-rest-api-specs/specification/apimanagement/resource-manager/readme.md", + "tag": "package-preview-2021-01", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-preview-2021-01 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/apimanagement/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/api.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/api.go new file mode 100644 index 000000000000..1b742115fc94 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/api.go @@ -0,0 +1,821 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIClient is the apiManagement Client +type APIClient struct { + BaseClient +} + +// NewAPIClient creates an instance of the APIClient client. +func NewAPIClient(subscriptionID string) APIClient { + return NewAPIClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIClientWithBaseURI creates an instance of the APIClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIClientWithBaseURI(baseURI string, subscriptionID string) APIClient { + return APIClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates new or updates existing specified API of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// parameters - create or update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters APICreateOrUpdateParameter, ifMatch string) (result APICreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters APICreateOrUpdateParameter, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIClient) CreateOrUpdateSender(req *http.Request) (future APICreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIClient) CreateOrUpdateResponder(resp *http.Response) (result APIContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified API of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// deleteRevisions - delete all revisions of the Api. +func (client APIClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string, deleteRevisions *bool) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, ifMatch, deleteRevisions) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string, deleteRevisions *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if deleteRevisions != nil { + queryParameters["deleteRevisions"] = autorest.Encode("query", *deleteRevisions) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client APIClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result APIContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIClient) GetResponder(resp *http.Response) (result APIContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client APIClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists all APIs of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 | |
+// top - number of records to return. +// skip - number of records to skip. +// tags - include tags in the response. +// expandAPIVersionSet - include full ApiVersionSet resource in response +func (client APIClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, tags string, expandAPIVersionSet *bool) (result APICollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIClient.ListByService") + defer func() { + sc := -1 + if result.ac.Response.Response != nil { + sc = result.ac.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip, tags, expandAPIVersionSet) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.ac.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "ListByService", resp, "Failure sending request") + return + } + + result.ac, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "ListByService", resp, "Failure responding to request") + return + } + if result.ac.hasNextLink() && result.ac.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client APIClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, tags string, expandAPIVersionSet *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if len(tags) > 0 { + queryParameters["tags"] = autorest.Encode("query", tags) + } + if expandAPIVersionSet != nil { + queryParameters["expandApiVersionSet"] = autorest.Encode("query", *expandAPIVersionSet) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client APIClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client APIClient) ListByServiceResponder(resp *http.Response) (result APICollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client APIClient) listByServiceNextResults(ctx context.Context, lastResults APICollection) (result APICollection, err error) { + req, err := lastResults.aPICollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, tags string, expandAPIVersionSet *bool) (result APICollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip, tags, expandAPIVersionSet) + return +} + +// ListByTags lists a collection of apis associated with tags. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 |
| apiRevision | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
| path | 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 |
| isCurrent | filter | eq | |
+// top - number of records to return. +// skip - number of records to skip. +// includeNotTaggedApis - include not tagged APIs. +func (client APIClient) ListByTags(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedApis *bool) (result TagResourceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIClient.ListByTags") + defer func() { + sc := -1 + if result.trc.Response.Response != nil { + sc = result.trc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIClient", "ListByTags", err.Error()) + } + + result.fn = client.listByTagsNextResults + req, err := client.ListByTagsPreparer(ctx, resourceGroupName, serviceName, filter, top, skip, includeNotTaggedApis) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "ListByTags", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTagsSender(req) + if err != nil { + result.trc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "ListByTags", resp, "Failure sending request") + return + } + + result.trc, err = client.ListByTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "ListByTags", resp, "Failure responding to request") + return + } + if result.trc.hasNextLink() && result.trc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByTagsPreparer prepares the ListByTags request. +func (client APIClient) ListByTagsPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedApis *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if includeNotTaggedApis != nil { + queryParameters["includeNotTaggedApis"] = autorest.Encode("query", *includeNotTaggedApis) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTagsSender sends the ListByTags request. The method will close the +// http.Response Body if it receives an error. +func (client APIClient) ListByTagsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTagsResponder handles the response to the ListByTags request. The method always +// closes the http.Response Body. +func (client APIClient) ListByTagsResponder(resp *http.Response) (result TagResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByTagsNextResults retrieves the next set of results, if any. +func (client APIClient) listByTagsNextResults(ctx context.Context, lastResults TagResourceCollection) (result TagResourceCollection, err error) { + req, err := lastResults.tagResourceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIClient", "listByTagsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByTagsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIClient", "listByTagsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "listByTagsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByTagsComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIClient) ListByTagsComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedApis *bool) (result TagResourceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIClient.ListByTags") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByTags(ctx, resourceGroupName, serviceName, filter, top, skip, includeNotTaggedApis) + return +} + +// Update updates the specified API of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// parameters - API Update Contract parameters. +// 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. +func (client APIClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters APIUpdateContract, ifMatch string) (result APIContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, apiid, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client APIClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters APIUpdateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client APIClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client APIClient) UpdateResponder(resp *http.Response) (result APIContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apidiagnostic.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apidiagnostic.go new file mode 100644 index 000000000000..90aca5fbe192 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apidiagnostic.go @@ -0,0 +1,711 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIDiagnosticClient is the apiManagement Client +type APIDiagnosticClient struct { + BaseClient +} + +// NewAPIDiagnosticClient creates an instance of the APIDiagnosticClient client. +func NewAPIDiagnosticClient(subscriptionID string) APIDiagnosticClient { + return NewAPIDiagnosticClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIDiagnosticClientWithBaseURI creates an instance of the APIDiagnosticClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIDiagnosticClientWithBaseURI(baseURI string, subscriptionID string) APIDiagnosticClient { + return APIDiagnosticClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Diagnostic for an API or updates an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIDiagnosticClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string, parameters DiagnosticContract, ifMatch string) (result DiagnosticContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIDiagnosticClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.LoggerID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DiagnosticContractProperties.Sampling", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Sampling.Percentage", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Sampling.Percentage", Name: validation.InclusiveMaximum, Rule: float64(100), Chain: nil}, + {Target: "parameters.DiagnosticContractProperties.Sampling.Percentage", Name: validation.InclusiveMinimum, Rule: float64(0), Chain: nil}, + }}, + }}, + {Target: "parameters.DiagnosticContractProperties.Frontend", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Request", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Request.Body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Request.Body.Bytes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Request.Body.Bytes", Name: validation.InclusiveMaximum, Rule: int64(8192), Chain: nil}}}, + }}, + }}, + {Target: "parameters.DiagnosticContractProperties.Frontend.Response", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Response.Body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Response.Body.Bytes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Response.Body.Bytes", Name: validation.InclusiveMaximum, Rule: int64(8192), Chain: nil}}}, + }}, + }}, + }}, + {Target: "parameters.DiagnosticContractProperties.Backend", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Request", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Request.Body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Request.Body.Bytes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Request.Body.Bytes", Name: validation.InclusiveMaximum, Rule: int64(8192), Chain: nil}}}, + }}, + }}, + {Target: "parameters.DiagnosticContractProperties.Backend.Response", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Response.Body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Response.Body.Bytes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Response.Body.Bytes", Name: validation.InclusiveMaximum, Rule: int64(8192), Chain: nil}}}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.APIDiagnosticClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, diagnosticID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIDiagnosticClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string, parameters DiagnosticContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIDiagnosticClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIDiagnosticClient) CreateOrUpdateResponder(resp *http.Response) (result DiagnosticContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified Diagnostic from an API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client APIDiagnosticClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIDiagnosticClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIDiagnosticClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, diagnosticID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIDiagnosticClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIDiagnosticClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIDiagnosticClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the Diagnostic for an API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client APIDiagnosticClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string) (result DiagnosticContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIDiagnosticClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIDiagnosticClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, diagnosticID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIDiagnosticClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIDiagnosticClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIDiagnosticClient) GetResponder(resp *http.Response) (result DiagnosticContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the Diagnostic for an API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client APIDiagnosticClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIDiagnosticClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIDiagnosticClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, diagnosticID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIDiagnosticClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIDiagnosticClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIDiagnosticClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists all diagnostics of an API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client APIDiagnosticClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result DiagnosticCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIDiagnosticClient.ListByService") + defer func() { + sc := -1 + if result.dc.Response.Response != nil { + sc = result.dc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIDiagnosticClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.dc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "ListByService", resp, "Failure sending request") + return + } + + result.dc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "ListByService", resp, "Failure responding to request") + return + } + if result.dc.hasNextLink() && result.dc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client APIDiagnosticClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client APIDiagnosticClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client APIDiagnosticClient) ListByServiceResponder(resp *http.Response) (result DiagnosticCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client APIDiagnosticClient) listByServiceNextResults(ctx context.Context, lastResults DiagnosticCollection) (result DiagnosticCollection, err error) { + req, err := lastResults.diagnosticCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIDiagnosticClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result DiagnosticCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIDiagnosticClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + return +} + +// Update updates the details of the Diagnostic for an API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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 - diagnostic Update parameters. +// 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. +func (client APIDiagnosticClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string, parameters DiagnosticContract, ifMatch string) (result DiagnosticContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIDiagnosticClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIDiagnosticClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, apiid, diagnosticID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIDiagnosticClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client APIDiagnosticClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string, parameters DiagnosticContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client APIDiagnosticClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client APIDiagnosticClient) UpdateResponder(resp *http.Response) (result DiagnosticContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiexport.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiexport.go new file mode 100644 index 000000000000..7b0b0db2fa48 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiexport.go @@ -0,0 +1,128 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIExportClient is the apiManagement Client +type APIExportClient struct { + BaseClient +} + +// NewAPIExportClient creates an instance of the APIExportClient client. +func NewAPIExportClient(subscriptionID string) APIExportClient { + return NewAPIExportClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIExportClientWithBaseURI creates an instance of the APIExportClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIExportClientWithBaseURI(baseURI string, subscriptionID string) APIExportClient { + return APIExportClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// 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. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// formatParameter - format in which to export the Api Details to the Storage Blob with Sas Key valid for 5 +// minutes. +func (client APIExportClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, formatParameter ExportFormat) (result APIExportResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIExportClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIExportClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, formatParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIExportClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIExportClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIExportClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIExportClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, formatParameter ExportFormat) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "export": autorest.Encode("query", "true"), + "format": autorest.Encode("query", formatParameter), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIExportClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIExportClient) GetResponder(resp *http.Response) (result APIExportResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiissue.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiissue.go new file mode 100644 index 000000000000..a70090485adf --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiissue.go @@ -0,0 +1,688 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIIssueClient is the apiManagement Client +type APIIssueClient struct { + BaseClient +} + +// NewAPIIssueClient creates an instance of the APIIssueClient client. +func NewAPIIssueClient(subscriptionID string) APIIssueClient { + return NewAPIIssueClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIIssueClientWithBaseURI creates an instance of the APIIssueClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIIssueClientWithBaseURI(baseURI string, subscriptionID string) APIIssueClient { + return APIIssueClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Issue for an API or updates an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIIssueClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueContract, ifMatch string) (result IssueContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.IssueContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.IssueContractProperties.Title", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.IssueContractProperties.Description", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.IssueContractProperties.UserID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIIssueClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIIssueClient) CreateOrUpdateResponder(resp *http.Response) (result IssueContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified Issue from an API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue 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. +func (client APIIssueClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIIssueClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIIssueClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the Issue for an API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// expandCommentsAttachments - expand the comment attachments. +func (client APIIssueClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, expandCommentsAttachments *bool) (result IssueContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, expandCommentsAttachments) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIIssueClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, expandCommentsAttachments *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if expandCommentsAttachments != nil { + queryParameters["expandCommentsAttachments"] = autorest.Encode("query", *expandCommentsAttachments) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIIssueClient) GetResponder(resp *http.Response) (result IssueContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the Issue for an API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +func (client APIIssueClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, issueID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIIssueClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIIssueClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists all issues associated with the specified API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
| state | filter | eq | |
+// expandCommentsAttachments - expand the comment attachments. +// top - number of records to return. +// skip - number of records to skip. +func (client APIIssueClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, expandCommentsAttachments *bool, top *int32, skip *int32) (result IssueCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.ListByService") + defer func() { + sc := -1 + if result.ic.Response.Response != nil { + sc = result.ic.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, filter, expandCommentsAttachments, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.ic.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "ListByService", resp, "Failure sending request") + return + } + + result.ic, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "ListByService", resp, "Failure responding to request") + return + } + if result.ic.hasNextLink() && result.ic.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client APIIssueClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, expandCommentsAttachments *bool, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if expandCommentsAttachments != nil { + queryParameters["expandCommentsAttachments"] = autorest.Encode("query", *expandCommentsAttachments) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client APIIssueClient) ListByServiceResponder(resp *http.Response) (result IssueCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client APIIssueClient) listByServiceNextResults(ctx context.Context, lastResults IssueCollection) (result IssueCollection, err error) { + req, err := lastResults.issueCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIIssueClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, expandCommentsAttachments *bool, top *int32, skip *int32) (result IssueCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, expandCommentsAttachments, top, skip) + return +} + +// Update updates an existing issue for an API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// parameters - update parameters. +// 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. +func (client APIIssueClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueUpdateContract, ifMatch string) (result IssueContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client APIIssueClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueUpdateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client APIIssueClient) UpdateResponder(resp *http.Response) (result IssueContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiissueattachment.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiissueattachment.go new file mode 100644 index 000000000000..59d96378a5b6 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiissueattachment.go @@ -0,0 +1,610 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIIssueAttachmentClient is the apiManagement Client +type APIIssueAttachmentClient struct { + BaseClient +} + +// NewAPIIssueAttachmentClient creates an instance of the APIIssueAttachmentClient client. +func NewAPIIssueAttachmentClient(subscriptionID string) APIIssueAttachmentClient { + return NewAPIIssueAttachmentClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIIssueAttachmentClientWithBaseURI creates an instance of the APIIssueAttachmentClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAPIIssueAttachmentClientWithBaseURI(baseURI string, subscriptionID string) APIIssueAttachmentClient { + return APIIssueAttachmentClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Attachment for the Issue in an API or updates an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// attachmentID - attachment identifier within an Issue. Must be unique in the current Issue. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIIssueAttachmentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, parameters IssueAttachmentContract, ifMatch string) (result IssueAttachmentContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: attachmentID, + Constraints: []validation.Constraint{{Target: "attachmentID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "attachmentID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "attachmentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.IssueAttachmentContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.IssueAttachmentContractProperties.Title", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.IssueAttachmentContractProperties.ContentFormat", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.IssueAttachmentContractProperties.Content", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, attachmentID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIIssueAttachmentClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, parameters IssueAttachmentContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "attachmentId": autorest.Encode("path", attachmentID), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueAttachmentClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIIssueAttachmentClient) CreateOrUpdateResponder(resp *http.Response) (result IssueAttachmentContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified comment from an Issue. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// attachmentID - attachment identifier within an Issue. Must be unique in the current Issue. +// 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. +func (client APIIssueAttachmentClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: attachmentID, + Constraints: []validation.Constraint{{Target: "attachmentID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "attachmentID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "attachmentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, attachmentID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIIssueAttachmentClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "attachmentId": autorest.Encode("path", attachmentID), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueAttachmentClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIIssueAttachmentClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the issue Attachment for an API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// attachmentID - attachment identifier within an Issue. Must be unique in the current Issue. +func (client APIIssueAttachmentClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (result IssueAttachmentContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: attachmentID, + Constraints: []validation.Constraint{{Target: "attachmentID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "attachmentID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "attachmentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, attachmentID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIIssueAttachmentClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "attachmentId": autorest.Encode("path", attachmentID), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueAttachmentClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIIssueAttachmentClient) GetResponder(resp *http.Response) (result IssueAttachmentContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the issue Attachment for an API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// attachmentID - attachment identifier within an Issue. Must be unique in the current Issue. +func (client APIIssueAttachmentClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: attachmentID, + Constraints: []validation.Constraint{{Target: "attachmentID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "attachmentID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "attachmentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, attachmentID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIIssueAttachmentClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "attachmentId": autorest.Encode("path", attachmentID), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueAttachmentClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIIssueAttachmentClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists all attachments for the Issue associated with the specified API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client APIIssueAttachmentClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result IssueAttachmentCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.ListByService") + defer func() { + sc := -1 + if result.iac.Response.Response != nil { + sc = result.iac.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueAttachmentClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.iac.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "ListByService", resp, "Failure sending request") + return + } + + result.iac, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "ListByService", resp, "Failure responding to request") + return + } + if result.iac.hasNextLink() && result.iac.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client APIIssueAttachmentClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueAttachmentClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client APIIssueAttachmentClient) ListByServiceResponder(resp *http.Response) (result IssueAttachmentCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client APIIssueAttachmentClient) listByServiceNextResults(ctx context.Context, lastResults IssueAttachmentCollection) (result IssueAttachmentCollection, err error) { + req, err := lastResults.issueAttachmentCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueAttachmentClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIIssueAttachmentClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result IssueAttachmentCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueAttachmentClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, issueID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiissuecomment.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiissuecomment.go new file mode 100644 index 000000000000..1187a2a126cc --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiissuecomment.go @@ -0,0 +1,608 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIIssueCommentClient is the apiManagement Client +type APIIssueCommentClient struct { + BaseClient +} + +// NewAPIIssueCommentClient creates an instance of the APIIssueCommentClient client. +func NewAPIIssueCommentClient(subscriptionID string) APIIssueCommentClient { + return NewAPIIssueCommentClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIIssueCommentClientWithBaseURI creates an instance of the APIIssueCommentClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIIssueCommentClientWithBaseURI(baseURI string, subscriptionID string) APIIssueCommentClient { + return APIIssueCommentClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Comment for the Issue in an API or updates an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// commentID - comment identifier within an Issue. Must be unique in the current Issue. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIIssueCommentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string, parameters IssueCommentContract, ifMatch string) (result IssueCommentContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: commentID, + Constraints: []validation.Constraint{{Target: "commentID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "commentID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "commentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.IssueCommentContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.IssueCommentContractProperties.Text", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.IssueCommentContractProperties.UserID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueCommentClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, commentID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIIssueCommentClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string, parameters IssueCommentContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "commentId": autorest.Encode("path", commentID), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueCommentClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIIssueCommentClient) CreateOrUpdateResponder(resp *http.Response) (result IssueCommentContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified comment from an Issue. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// commentID - comment identifier within an Issue. Must be unique in the current Issue. +// 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. +func (client APIIssueCommentClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: commentID, + Constraints: []validation.Constraint{{Target: "commentID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "commentID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "commentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueCommentClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, commentID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIIssueCommentClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "commentId": autorest.Encode("path", commentID), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueCommentClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIIssueCommentClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the issue Comment for an API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// commentID - comment identifier within an Issue. Must be unique in the current Issue. +func (client APIIssueCommentClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (result IssueCommentContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: commentID, + Constraints: []validation.Constraint{{Target: "commentID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "commentID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "commentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueCommentClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, commentID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIIssueCommentClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "commentId": autorest.Encode("path", commentID), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueCommentClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIIssueCommentClient) GetResponder(resp *http.Response) (result IssueCommentContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the issue Comment for an API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// commentID - comment identifier within an Issue. Must be unique in the current Issue. +func (client APIIssueCommentClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: commentID, + Constraints: []validation.Constraint{{Target: "commentID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "commentID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "commentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueCommentClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, commentID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIIssueCommentClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "commentId": autorest.Encode("path", commentID), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueCommentClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIIssueCommentClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists all comments for the Issue associated with the specified API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client APIIssueCommentClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result IssueCommentCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.ListByService") + defer func() { + sc := -1 + if result.icc.Response.Response != nil { + sc = result.icc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueCommentClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.icc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "ListByService", resp, "Failure sending request") + return + } + + result.icc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "ListByService", resp, "Failure responding to request") + return + } + if result.icc.hasNextLink() && result.icc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client APIIssueCommentClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client APIIssueCommentClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client APIIssueCommentClient) ListByServiceResponder(resp *http.Response) (result IssueCommentCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client APIIssueCommentClient) listByServiceNextResults(ctx context.Context, lastResults IssueCommentCollection) (result IssueCommentCollection, err error) { + req, err := lastResults.issueCommentCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueCommentClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIIssueCommentClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result IssueCommentCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueCommentClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, issueID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apimanagementapi/interfaces.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apimanagementapi/interfaces.go new file mode 100644 index 000000000000..d773cb003e03 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apimanagementapi/interfaces.go @@ -0,0 +1,842 @@ +package apimanagementapi + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement" + "github.com/Azure/go-autorest/autorest" +) + +// APIClientAPI contains the set of methods on the APIClient type. +type APIClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters apimanagement.APICreateOrUpdateParameter, ifMatch string) (result apimanagement.APICreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string, deleteRevisions *bool) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result apimanagement.APIContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, tags string, expandAPIVersionSet *bool) (result apimanagement.APICollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, tags string, expandAPIVersionSet *bool) (result apimanagement.APICollectionIterator, err error) + ListByTags(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedApis *bool) (result apimanagement.TagResourceCollectionPage, err error) + ListByTagsComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedApis *bool) (result apimanagement.TagResourceCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters apimanagement.APIUpdateContract, ifMatch string) (result apimanagement.APIContract, err error) +} + +var _ APIClientAPI = (*apimanagement.APIClient)(nil) + +// APIRevisionClientAPI contains the set of methods on the APIRevisionClient type. +type APIRevisionClientAPI interface { + ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.APIRevisionCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.APIRevisionCollectionIterator, err error) +} + +var _ APIRevisionClientAPI = (*apimanagement.APIRevisionClient)(nil) + +// APIReleaseClientAPI contains the set of methods on the APIReleaseClient type. +type APIReleaseClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters apimanagement.APIReleaseContract, ifMatch string) (result apimanagement.APIReleaseContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (result apimanagement.APIReleaseContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.APIReleaseCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.APIReleaseCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters apimanagement.APIReleaseContract, ifMatch string) (result apimanagement.APIReleaseContract, err error) +} + +var _ APIReleaseClientAPI = (*apimanagement.APIReleaseClient)(nil) + +// APIOperationClientAPI contains the set of methods on the APIOperationClient type. +type APIOperationClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, parameters apimanagement.OperationContract, ifMatch string) (result apimanagement.OperationContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (result apimanagement.OperationContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (result autorest.Response, err error) + ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, tags string) (result apimanagement.OperationCollectionPage, err error) + ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, tags string) (result apimanagement.OperationCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, parameters apimanagement.OperationUpdateContract, ifMatch string) (result apimanagement.OperationContract, err error) +} + +var _ APIOperationClientAPI = (*apimanagement.APIOperationClient)(nil) + +// APIOperationPolicyClientAPI contains the set of methods on the APIOperationPolicyClient type. +type APIOperationPolicyClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, parameters apimanagement.PolicyContract, ifMatch string) (result apimanagement.PolicyContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, formatParameter apimanagement.PolicyExportFormat) (result apimanagement.PolicyContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (result autorest.Response, err error) + ListByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (result apimanagement.PolicyCollection, err error) +} + +var _ APIOperationPolicyClientAPI = (*apimanagement.APIOperationPolicyClient)(nil) + +// TagClientAPI contains the set of methods on the TagClient type. +type TagClientAPI interface { + AssignToAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result apimanagement.TagContract, err error) + AssignToOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result apimanagement.TagContract, err error) + AssignToProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result apimanagement.TagContract, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters apimanagement.TagCreateUpdateParameters, ifMatch string) (result apimanagement.TagContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string) (result autorest.Response, err error) + DetachFromAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result autorest.Response, err error) + DetachFromOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result autorest.Response, err error) + DetachFromProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (result apimanagement.TagContract, err error) + GetByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result apimanagement.TagContract, err error) + GetByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result apimanagement.TagContract, err error) + GetByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result apimanagement.TagContract, err error) + GetEntityState(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (result autorest.Response, err error) + GetEntityStateByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result autorest.Response, err error) + GetEntityStateByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result autorest.Response, err error) + GetEntityStateByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result autorest.Response, err error) + ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.TagCollectionPage, err error) + ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.TagCollectionIterator, err error) + ListByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, filter string, top *int32, skip *int32) (result apimanagement.TagCollectionPage, err error) + ListByOperationComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, filter string, top *int32, skip *int32) (result apimanagement.TagCollectionIterator, err error) + ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result apimanagement.TagCollectionPage, err error) + ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result apimanagement.TagCollectionIterator, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, scope string) (result apimanagement.TagCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, scope string) (result apimanagement.TagCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters apimanagement.TagCreateUpdateParameters, ifMatch string) (result apimanagement.TagContract, err error) +} + +var _ TagClientAPI = (*apimanagement.TagClient)(nil) + +// APIProductClientAPI contains the set of methods on the APIProductClient type. +type APIProductClientAPI interface { + ListByApis(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.ProductCollectionPage, err error) + ListByApisComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.ProductCollectionIterator, err error) +} + +var _ APIProductClientAPI = (*apimanagement.APIProductClient)(nil) + +// APIPolicyClientAPI contains the set of methods on the APIPolicyClient type. +type APIPolicyClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters apimanagement.PolicyContract, ifMatch string) (result apimanagement.PolicyContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, formatParameter apimanagement.PolicyExportFormat) (result apimanagement.PolicyContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result autorest.Response, err error) + ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result apimanagement.PolicyCollection, err error) +} + +var _ APIPolicyClientAPI = (*apimanagement.APIPolicyClient)(nil) + +// APISchemaClientAPI contains the set of methods on the APISchemaClient type. +type APISchemaClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string, parameters apimanagement.SchemaContract, ifMatch string) (result apimanagement.APISchemaCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string, ifMatch string, force *bool) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string) (result apimanagement.SchemaContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string) (result autorest.Response, err error) + ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.SchemaCollectionPage, err error) + ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.SchemaCollectionIterator, err error) +} + +var _ APISchemaClientAPI = (*apimanagement.APISchemaClient)(nil) + +// APIDiagnosticClientAPI contains the set of methods on the APIDiagnosticClient type. +type APIDiagnosticClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string, parameters apimanagement.DiagnosticContract, ifMatch string) (result apimanagement.DiagnosticContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string) (result apimanagement.DiagnosticContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.DiagnosticCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.DiagnosticCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, diagnosticID string, parameters apimanagement.DiagnosticContract, ifMatch string) (result apimanagement.DiagnosticContract, err error) +} + +var _ APIDiagnosticClientAPI = (*apimanagement.APIDiagnosticClient)(nil) + +// APIIssueClientAPI contains the set of methods on the APIIssueClient type. +type APIIssueClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters apimanagement.IssueContract, ifMatch string) (result apimanagement.IssueContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, expandCommentsAttachments *bool) (result apimanagement.IssueContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, expandCommentsAttachments *bool, top *int32, skip *int32) (result apimanagement.IssueCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, expandCommentsAttachments *bool, top *int32, skip *int32) (result apimanagement.IssueCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters apimanagement.IssueUpdateContract, ifMatch string) (result apimanagement.IssueContract, err error) +} + +var _ APIIssueClientAPI = (*apimanagement.APIIssueClient)(nil) + +// APIIssueCommentClientAPI contains the set of methods on the APIIssueCommentClient type. +type APIIssueCommentClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string, parameters apimanagement.IssueCommentContract, ifMatch string) (result apimanagement.IssueCommentContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (result apimanagement.IssueCommentContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result apimanagement.IssueCommentCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result apimanagement.IssueCommentCollectionIterator, err error) +} + +var _ APIIssueCommentClientAPI = (*apimanagement.APIIssueCommentClient)(nil) + +// APIIssueAttachmentClientAPI contains the set of methods on the APIIssueAttachmentClient type. +type APIIssueAttachmentClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, parameters apimanagement.IssueAttachmentContract, ifMatch string) (result apimanagement.IssueAttachmentContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (result apimanagement.IssueAttachmentContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, attachmentID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result apimanagement.IssueAttachmentCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, filter string, top *int32, skip *int32) (result apimanagement.IssueAttachmentCollectionIterator, err error) +} + +var _ APIIssueAttachmentClientAPI = (*apimanagement.APIIssueAttachmentClient)(nil) + +// APITagDescriptionClientAPI contains the set of methods on the APITagDescriptionClient type. +type APITagDescriptionClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string, parameters apimanagement.TagDescriptionCreateParameters, ifMatch string) (result apimanagement.TagDescriptionContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string) (result apimanagement.TagDescriptionContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.TagDescriptionCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.TagDescriptionCollectionIterator, err error) +} + +var _ APITagDescriptionClientAPI = (*apimanagement.APITagDescriptionClient)(nil) + +// OperationClientAPI contains the set of methods on the OperationClient type. +type OperationClientAPI interface { + ListByTags(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, includeNotTaggedOperations *bool) (result apimanagement.TagResourceCollectionPage, err error) + ListByTagsComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, includeNotTaggedOperations *bool) (result apimanagement.TagResourceCollectionIterator, err error) +} + +var _ OperationClientAPI = (*apimanagement.OperationClient)(nil) + +// APIVersionSetClientAPI contains the set of methods on the APIVersionSetClient type. +type APIVersionSetClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, parameters apimanagement.APIVersionSetContract, ifMatch string) (result apimanagement.APIVersionSetContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string) (result apimanagement.APIVersionSetContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.APIVersionSetCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.APIVersionSetCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, parameters apimanagement.APIVersionSetUpdateParameters, ifMatch string) (result apimanagement.APIVersionSetContract, err error) +} + +var _ APIVersionSetClientAPI = (*apimanagement.APIVersionSetClient)(nil) + +// AuthorizationServerClientAPI contains the set of methods on the AuthorizationServerClient type. +type AuthorizationServerClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters apimanagement.AuthorizationServerContract, ifMatch string) (result apimanagement.AuthorizationServerContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (result apimanagement.AuthorizationServerContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.AuthorizationServerCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.AuthorizationServerCollectionIterator, err error) + ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (result apimanagement.AuthorizationServerSecretsContract, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters apimanagement.AuthorizationServerUpdateContract, ifMatch string) (result apimanagement.AuthorizationServerContract, err error) +} + +var _ AuthorizationServerClientAPI = (*apimanagement.AuthorizationServerClient)(nil) + +// BackendClientAPI contains the set of methods on the BackendClient type. +type BackendClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters apimanagement.BackendContract, ifMatch string) (result apimanagement.BackendContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, backendID string) (result apimanagement.BackendContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, backendID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.BackendCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.BackendCollectionIterator, err error) + Reconnect(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters *apimanagement.BackendReconnectContract) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters apimanagement.BackendUpdateParameters, ifMatch string) (result apimanagement.BackendContract, err error) +} + +var _ BackendClientAPI = (*apimanagement.BackendClient)(nil) + +// CacheClientAPI contains the set of methods on the CacheClient type. +type CacheClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, parameters apimanagement.CacheContract, ifMatch string) (result apimanagement.CacheContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, cacheID string) (result apimanagement.CacheContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, cacheID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (result apimanagement.CacheCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (result apimanagement.CacheCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, parameters apimanagement.CacheUpdateParameters, ifMatch string) (result apimanagement.CacheContract, err error) +} + +var _ CacheClientAPI = (*apimanagement.CacheClient)(nil) + +// CertificateClientAPI contains the set of methods on the CertificateClient type. +type CertificateClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, parameters apimanagement.CertificateCreateOrUpdateParameters, ifMatch string) (result apimanagement.CertificateContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, certificateID string) (result apimanagement.CertificateContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, certificateID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (result apimanagement.CertificateCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (result apimanagement.CertificateCollectionIterator, err error) + RefreshSecret(ctx context.Context, resourceGroupName string, serviceName string, certificateID string) (result apimanagement.CertificateContract, err error) +} + +var _ CertificateClientAPI = (*apimanagement.CertificateClient)(nil) + +// ContentTypeClientAPI contains the set of methods on the ContentTypeClient type. +type ContentTypeClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string) (result apimanagement.ContentTypeContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string) (result apimanagement.ContentTypeContract, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.ContentTypeCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.ContentTypeCollectionIterator, err error) +} + +var _ ContentTypeClientAPI = (*apimanagement.ContentTypeClient)(nil) + +// ContentItemClientAPI contains the set of methods on the ContentItemClient type. +type ContentItemClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string) (result apimanagement.ContentItemContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string) (result apimanagement.ContentItemContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string) (result apimanagement.ContentItemCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string) (result apimanagement.ContentItemCollectionIterator, err error) +} + +var _ ContentItemClientAPI = (*apimanagement.ContentItemClient)(nil) + +// DeletedServicesClientAPI contains the set of methods on the DeletedServicesClient type. +type DeletedServicesClientAPI interface { + GetByName(ctx context.Context, serviceName string, location string) (result apimanagement.DeletedServiceContract, err error) + ListBySubscription(ctx context.Context) (result apimanagement.DeletedServicesCollectionPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result apimanagement.DeletedServicesCollectionIterator, err error) + Purge(ctx context.Context, serviceName string, location string) (result apimanagement.DeletedServicesPurgeFuture, err error) +} + +var _ DeletedServicesClientAPI = (*apimanagement.DeletedServicesClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result apimanagement.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result apimanagement.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*apimanagement.OperationsClient)(nil) + +// ServiceSkusClientAPI contains the set of methods on the ServiceSkusClient type. +type ServiceSkusClientAPI interface { + ListAvailableServiceSkus(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.ResourceSkuResultsPage, err error) + ListAvailableServiceSkusComplete(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.ResourceSkuResultsIterator, err error) +} + +var _ ServiceSkusClientAPI = (*apimanagement.ServiceSkusClient)(nil) + +// ServiceClientAPI contains the set of methods on the ServiceClient type. +type ServiceClientAPI interface { + ApplyNetworkConfigurationUpdates(ctx context.Context, resourceGroupName string, serviceName string, parameters *apimanagement.ServiceApplyNetworkConfigurationParameters) (result apimanagement.ServiceApplyNetworkConfigurationUpdatesFuture, err error) + Backup(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.ServiceBackupRestoreParameters) (result apimanagement.ServiceBackupFuture, err error) + CheckNameAvailability(ctx context.Context, parameters apimanagement.ServiceCheckNameAvailabilityParameters) (result apimanagement.ServiceNameAvailabilityResult, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.ServiceResource) (result apimanagement.ServiceCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.ServiceDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.ServiceResource, err error) + GetDomainOwnershipIdentifier(ctx context.Context) (result apimanagement.ServiceGetDomainOwnershipIdentifierResult, err error) + GetSsoToken(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.ServiceGetSsoTokenResult, err error) + List(ctx context.Context) (result apimanagement.ServiceListResultPage, err error) + ListComplete(ctx context.Context) (result apimanagement.ServiceListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result apimanagement.ServiceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result apimanagement.ServiceListResultIterator, err error) + Restore(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.ServiceBackupRestoreParameters) (result apimanagement.ServiceRestoreFuture, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.ServiceUpdateParameters) (result apimanagement.ServiceUpdateFuture, err error) +} + +var _ ServiceClientAPI = (*apimanagement.ServiceClient)(nil) + +// DiagnosticClientAPI contains the set of methods on the DiagnosticClient type. +type DiagnosticClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, parameters apimanagement.DiagnosticContract, ifMatch string) (result apimanagement.DiagnosticContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string) (result apimanagement.DiagnosticContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.DiagnosticCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.DiagnosticCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, parameters apimanagement.DiagnosticContract, ifMatch string) (result apimanagement.DiagnosticContract, err error) +} + +var _ DiagnosticClientAPI = (*apimanagement.DiagnosticClient)(nil) + +// EmailTemplateClientAPI contains the set of methods on the EmailTemplateClient type. +type EmailTemplateClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, templateName apimanagement.TemplateName, parameters apimanagement.EmailTemplateUpdateParameters, ifMatch string) (result apimanagement.EmailTemplateContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, templateName apimanagement.TemplateName, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, templateName apimanagement.TemplateName) (result apimanagement.EmailTemplateContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, templateName apimanagement.TemplateName) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.EmailTemplateCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.EmailTemplateCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, templateName apimanagement.TemplateName, ifMatch string, parameters apimanagement.EmailTemplateUpdateParameters) (result apimanagement.EmailTemplateContract, err error) +} + +var _ EmailTemplateClientAPI = (*apimanagement.EmailTemplateClient)(nil) + +// GatewayClientAPI contains the set of methods on the GatewayClient type. +type GatewayClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters apimanagement.GatewayContract, ifMatch string) (result apimanagement.GatewayContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string) (result autorest.Response, err error) + GenerateToken(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters apimanagement.GatewayTokenRequestContract) (result apimanagement.GatewayTokenContract, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string) (result apimanagement.GatewayContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.GatewayCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.GatewayCollectionIterator, err error) + ListKeys(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string) (result apimanagement.GatewayKeysContract, err error) + RegenerateKey(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters apimanagement.GatewayKeyRegenerationRequestContract) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters apimanagement.GatewayContract, ifMatch string) (result apimanagement.GatewayContract, err error) +} + +var _ GatewayClientAPI = (*apimanagement.GatewayClient)(nil) + +// GatewayHostnameConfigurationClientAPI contains the set of methods on the GatewayHostnameConfigurationClient type. +type GatewayHostnameConfigurationClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, parameters apimanagement.GatewayHostnameConfigurationContract, ifMatch string) (result apimanagement.GatewayHostnameConfigurationContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string) (result apimanagement.GatewayHostnameConfigurationContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result apimanagement.GatewayHostnameConfigurationCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result apimanagement.GatewayHostnameConfigurationCollectionIterator, err error) +} + +var _ GatewayHostnameConfigurationClientAPI = (*apimanagement.GatewayHostnameConfigurationClient)(nil) + +// GatewayAPIClientAPI contains the set of methods on the GatewayAPIClient type. +type GatewayAPIClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiid string, parameters *apimanagement.AssociationContract) (result apimanagement.APIContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiid string) (result autorest.Response, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiid string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result apimanagement.APICollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result apimanagement.APICollectionIterator, err error) +} + +var _ GatewayAPIClientAPI = (*apimanagement.GatewayAPIClient)(nil) + +// GatewayCertificateAuthorityClientAPI contains the set of methods on the GatewayCertificateAuthorityClient type. +type GatewayCertificateAuthorityClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, parameters apimanagement.GatewayCertificateAuthorityContract, ifMatch string) (result apimanagement.GatewayCertificateAuthorityContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (result apimanagement.GatewayCertificateAuthorityContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result apimanagement.GatewayCertificateAuthorityCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result apimanagement.GatewayCertificateAuthorityCollectionIterator, err error) +} + +var _ GatewayCertificateAuthorityClientAPI = (*apimanagement.GatewayCertificateAuthorityClient)(nil) + +// GroupClientAPI contains the set of methods on the GroupClient type. +type GroupClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters apimanagement.GroupCreateParameters, ifMatch string) (result apimanagement.GroupContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, groupID string) (result apimanagement.GroupContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, groupID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.GroupCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.GroupCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters apimanagement.GroupUpdateParameters, ifMatch string) (result apimanagement.GroupContract, err error) +} + +var _ GroupClientAPI = (*apimanagement.GroupClient)(nil) + +// GroupUserClientAPI contains the set of methods on the GroupUserClient type. +type GroupUserClientAPI interface { + CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string) (result autorest.Response, err error) + Create(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string) (result apimanagement.UserContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string) (result autorest.Response, err error) + List(ctx context.Context, resourceGroupName string, serviceName string, groupID string, filter string, top *int32, skip *int32) (result apimanagement.UserCollectionPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, serviceName string, groupID string, filter string, top *int32, skip *int32) (result apimanagement.UserCollectionIterator, err error) +} + +var _ GroupUserClientAPI = (*apimanagement.GroupUserClient)(nil) + +// IdentityProviderClientAPI contains the set of methods on the IdentityProviderClient type. +type IdentityProviderClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName apimanagement.IdentityProviderType, parameters apimanagement.IdentityProviderCreateContract, ifMatch string) (result apimanagement.IdentityProviderContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName apimanagement.IdentityProviderType, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName apimanagement.IdentityProviderType) (result apimanagement.IdentityProviderContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName apimanagement.IdentityProviderType) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.IdentityProviderListPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.IdentityProviderListIterator, err error) + ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName apimanagement.IdentityProviderType) (result apimanagement.ClientSecretContract, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName apimanagement.IdentityProviderType, parameters apimanagement.IdentityProviderUpdateParameters, ifMatch string) (result apimanagement.IdentityProviderContract, err error) +} + +var _ IdentityProviderClientAPI = (*apimanagement.IdentityProviderClient)(nil) + +// IssueClientAPI contains the set of methods on the IssueClient type. +type IssueClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serviceName string, issueID string) (result apimanagement.IssueContract, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.IssueCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.IssueCollectionIterator, err error) +} + +var _ IssueClientAPI = (*apimanagement.IssueClient)(nil) + +// LoggerClientAPI contains the set of methods on the LoggerClient type. +type LoggerClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, parameters apimanagement.LoggerContract, ifMatch string) (result apimanagement.LoggerContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, loggerID string) (result apimanagement.LoggerContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, loggerID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.LoggerCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.LoggerCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, parameters apimanagement.LoggerUpdateContract, ifMatch string) (result apimanagement.LoggerContract, err error) +} + +var _ LoggerClientAPI = (*apimanagement.LoggerClient)(nil) + +// NamedValueClientAPI contains the set of methods on the NamedValueClient type. +type NamedValueClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters apimanagement.NamedValueCreateContract, ifMatch string) (result apimanagement.NamedValueCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (result apimanagement.NamedValueContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (result apimanagement.NamedValueCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (result apimanagement.NamedValueCollectionIterator, err error) + ListValue(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (result apimanagement.NamedValueSecretContract, err error) + RefreshSecret(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (result apimanagement.NamedValueRefreshSecretFuture, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters apimanagement.NamedValueUpdateParameters, ifMatch string) (result apimanagement.NamedValueUpdateFuture, err error) +} + +var _ NamedValueClientAPI = (*apimanagement.NamedValueClient)(nil) + +// NetworkStatusClientAPI contains the set of methods on the NetworkStatusClient type. +type NetworkStatusClientAPI interface { + ListByLocation(ctx context.Context, resourceGroupName string, serviceName string, locationName string) (result apimanagement.NetworkStatusContract, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.ListNetworkStatusContractByLocation, err error) +} + +var _ NetworkStatusClientAPI = (*apimanagement.NetworkStatusClient)(nil) + +// NotificationClientAPI contains the set of methods on the NotificationClient type. +type NotificationClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName, ifMatch string) (result apimanagement.NotificationContract, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName) (result apimanagement.NotificationContract, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (result apimanagement.NotificationCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (result apimanagement.NotificationCollectionIterator, err error) +} + +var _ NotificationClientAPI = (*apimanagement.NotificationClient)(nil) + +// NotificationRecipientUserClientAPI contains the set of methods on the NotificationRecipientUserClient type. +type NotificationRecipientUserClientAPI interface { + CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName, userID string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName, userID string) (result apimanagement.RecipientUserContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName, userID string) (result autorest.Response, err error) + ListByNotification(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName) (result apimanagement.RecipientUserCollection, err error) +} + +var _ NotificationRecipientUserClientAPI = (*apimanagement.NotificationRecipientUserClient)(nil) + +// NotificationRecipientEmailClientAPI contains the set of methods on the NotificationRecipientEmailClient type. +type NotificationRecipientEmailClientAPI interface { + CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName, email string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName, email string) (result apimanagement.RecipientEmailContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName, email string) (result autorest.Response, err error) + ListByNotification(ctx context.Context, resourceGroupName string, serviceName string, notificationName apimanagement.NotificationName) (result apimanagement.RecipientEmailCollection, err error) +} + +var _ NotificationRecipientEmailClientAPI = (*apimanagement.NotificationRecipientEmailClient)(nil) + +// OpenIDConnectProviderClientAPI contains the set of methods on the OpenIDConnectProviderClient type. +type OpenIDConnectProviderClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters apimanagement.OpenidConnectProviderContract, ifMatch string) (result apimanagement.OpenidConnectProviderContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, opid string) (result apimanagement.OpenidConnectProviderContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, opid string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.OpenIDConnectProviderCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.OpenIDConnectProviderCollectionIterator, err error) + ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, opid string) (result apimanagement.ClientSecretContract, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters apimanagement.OpenidConnectProviderUpdateContract, ifMatch string) (result apimanagement.OpenidConnectProviderContract, err error) +} + +var _ OpenIDConnectProviderClientAPI = (*apimanagement.OpenIDConnectProviderClient)(nil) + +// PolicyClientAPI contains the set of methods on the PolicyClient type. +type PolicyClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.PolicyContract, ifMatch string) (result apimanagement.PolicyContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, formatParameter apimanagement.PolicyExportFormat) (result apimanagement.PolicyContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.PolicyCollection, err error) +} + +var _ PolicyClientAPI = (*apimanagement.PolicyClient)(nil) + +// PolicyDescriptionClientAPI contains the set of methods on the PolicyDescriptionClient type. +type PolicyDescriptionClientAPI interface { + ListByService(ctx context.Context, resourceGroupName string, serviceName string, scope apimanagement.PolicyScopeContract) (result apimanagement.PolicyDescriptionCollection, err error) +} + +var _ PolicyDescriptionClientAPI = (*apimanagement.PolicyDescriptionClient)(nil) + +// PortalRevisionClientAPI contains the set of methods on the PortalRevisionClient type. +type PortalRevisionClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters apimanagement.PortalRevisionContract) (result apimanagement.PortalRevisionCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (result apimanagement.PortalRevisionContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.PortalRevisionCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.PortalRevisionCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters apimanagement.PortalRevisionContract, ifMatch string) (result apimanagement.PortalRevisionUpdateFuture, err error) +} + +var _ PortalRevisionClientAPI = (*apimanagement.PortalRevisionClient)(nil) + +// PortalSettingsClientAPI contains the set of methods on the PortalSettingsClient type. +type PortalSettingsClientAPI interface { + ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.PortalSettingsCollection, err error) +} + +var _ PortalSettingsClientAPI = (*apimanagement.PortalSettingsClient)(nil) + +// SignInSettingsClientAPI contains the set of methods on the SignInSettingsClient type. +type SignInSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.PortalSigninSettings, ifMatch string) (result apimanagement.PortalSigninSettings, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.PortalSigninSettings, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.PortalSigninSettings, ifMatch string) (result autorest.Response, err error) +} + +var _ SignInSettingsClientAPI = (*apimanagement.SignInSettingsClient)(nil) + +// SignUpSettingsClientAPI contains the set of methods on the SignUpSettingsClient type. +type SignUpSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.PortalSignupSettings, ifMatch string) (result apimanagement.PortalSignupSettings, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.PortalSignupSettings, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.PortalSignupSettings, ifMatch string) (result autorest.Response, err error) +} + +var _ SignUpSettingsClientAPI = (*apimanagement.SignUpSettingsClient)(nil) + +// DelegationSettingsClientAPI contains the set of methods on the DelegationSettingsClient type. +type DelegationSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.PortalDelegationSettings, ifMatch string) (result apimanagement.PortalDelegationSettings, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.PortalDelegationSettings, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) + ListSecrets(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.PortalSettingValidationKeyContract, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.PortalDelegationSettings, ifMatch string) (result autorest.Response, err error) +} + +var _ DelegationSettingsClientAPI = (*apimanagement.DelegationSettingsClient)(nil) + +// ProductClientAPI contains the set of methods on the ProductClient type. +type ProductClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters apimanagement.ProductContract, ifMatch string) (result apimanagement.ProductContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, deleteSubscriptions *bool) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, productID string) (result apimanagement.ProductContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, productID string) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool, tags string) (result apimanagement.ProductCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool, tags string) (result apimanagement.ProductCollectionIterator, err error) + ListByTags(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedProducts *bool) (result apimanagement.TagResourceCollectionPage, err error) + ListByTagsComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedProducts *bool) (result apimanagement.TagResourceCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters apimanagement.ProductUpdateParameters, ifMatch string) (result apimanagement.ProductContract, err error) +} + +var _ ProductClientAPI = (*apimanagement.ProductClient)(nil) + +// ProductAPIClientAPI contains the set of methods on the ProductAPIClient type. +type ProductAPIClientAPI interface { + CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiid string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiid string) (result apimanagement.APIContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiid string) (result autorest.Response, err error) + ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result apimanagement.APICollectionPage, err error) + ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result apimanagement.APICollectionIterator, err error) +} + +var _ ProductAPIClientAPI = (*apimanagement.ProductAPIClient)(nil) + +// ProductGroupClientAPI contains the set of methods on the ProductGroupClient type. +type ProductGroupClientAPI interface { + CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string) (result apimanagement.GroupContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string) (result autorest.Response, err error) + ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result apimanagement.GroupCollectionPage, err error) + ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result apimanagement.GroupCollectionIterator, err error) +} + +var _ ProductGroupClientAPI = (*apimanagement.ProductGroupClient)(nil) + +// ProductSubscriptionsClientAPI contains the set of methods on the ProductSubscriptionsClient type. +type ProductSubscriptionsClientAPI interface { + List(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result apimanagement.SubscriptionCollectionPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result apimanagement.SubscriptionCollectionIterator, err error) +} + +var _ ProductSubscriptionsClientAPI = (*apimanagement.ProductSubscriptionsClient)(nil) + +// ProductPolicyClientAPI contains the set of methods on the ProductPolicyClient type. +type ProductPolicyClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters apimanagement.PolicyContract, ifMatch string) (result apimanagement.PolicyContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, productID string, formatParameter apimanagement.PolicyExportFormat) (result apimanagement.PolicyContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, productID string) (result autorest.Response, err error) + ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string) (result apimanagement.PolicyCollection, err error) +} + +var _ ProductPolicyClientAPI = (*apimanagement.ProductPolicyClient)(nil) + +// QuotaByCounterKeysClientAPI contains the set of methods on the QuotaByCounterKeysClient type. +type QuotaByCounterKeysClientAPI interface { + ListByService(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string) (result apimanagement.QuotaCounterCollection, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, parameters apimanagement.QuotaCounterValueUpdateContract) (result apimanagement.QuotaCounterCollection, err error) +} + +var _ QuotaByCounterKeysClientAPI = (*apimanagement.QuotaByCounterKeysClient)(nil) + +// QuotaByPeriodKeysClientAPI contains the set of methods on the QuotaByPeriodKeysClient type. +type QuotaByPeriodKeysClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string) (result apimanagement.QuotaCounterContract, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, parameters apimanagement.QuotaCounterValueUpdateContract) (result apimanagement.QuotaCounterContract, err error) +} + +var _ QuotaByPeriodKeysClientAPI = (*apimanagement.QuotaByPeriodKeysClient)(nil) + +// RegionClientAPI contains the set of methods on the RegionClient type. +type RegionClientAPI interface { + ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.RegionListResultPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.RegionListResultIterator, err error) +} + +var _ RegionClientAPI = (*apimanagement.RegionClient)(nil) + +// ReportsClientAPI contains the set of methods on the ReportsClient type. +type ReportsClientAPI interface { + ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionPage, err error) + ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionIterator, err error) + ListByGeo(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.ReportCollectionPage, err error) + ListByGeoComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.ReportCollectionIterator, err error) + ListByOperation(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionPage, err error) + ListByOperationComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionIterator, err error) + ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionPage, err error) + ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionIterator, err error) + ListByRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.RequestReportCollection, err error) + ListBySubscription(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionPage, err error) + ListBySubscriptionComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionIterator, err error) + ListByTime(ctx context.Context, resourceGroupName string, serviceName string, filter string, interval string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionPage, err error) + ListByTimeComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, interval string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionIterator, err error) + ListByUser(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionPage, err error) + ListByUserComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result apimanagement.ReportCollectionIterator, err error) +} + +var _ ReportsClientAPI = (*apimanagement.ReportsClient)(nil) + +// TenantSettingsClientAPI contains the set of methods on the TenantSettingsClient type. +type TenantSettingsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.TenantSettingsContract, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result apimanagement.TenantSettingsCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result apimanagement.TenantSettingsCollectionIterator, err error) +} + +var _ TenantSettingsClientAPI = (*apimanagement.TenantSettingsClient)(nil) + +// SkusClientAPI contains the set of methods on the SkusClient type. +type SkusClientAPI interface { + List(ctx context.Context) (result apimanagement.SkusResultPage, err error) + ListComplete(ctx context.Context) (result apimanagement.SkusResultIterator, err error) +} + +var _ SkusClientAPI = (*apimanagement.SkusClient)(nil) + +// SubscriptionClientAPI contains the set of methods on the SubscriptionClient type. +type SubscriptionClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, sid string, parameters apimanagement.SubscriptionCreateParameters, notify *bool, ifMatch string, appType apimanagement.AppType) (result apimanagement.SubscriptionContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result apimanagement.SubscriptionContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result autorest.Response, err error) + List(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.SubscriptionCollectionPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.SubscriptionCollectionIterator, err error) + ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result apimanagement.SubscriptionKeysContract, err error) + RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result autorest.Response, err error) + RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, sid string, parameters apimanagement.SubscriptionUpdateParameters, ifMatch string, notify *bool, appType apimanagement.AppType) (result apimanagement.SubscriptionContract, err error) +} + +var _ SubscriptionClientAPI = (*apimanagement.SubscriptionClient)(nil) + +// TagResourceClientAPI contains the set of methods on the TagResourceClient type. +type TagResourceClientAPI interface { + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.TagResourceCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.TagResourceCollectionIterator, err error) +} + +var _ TagResourceClientAPI = (*apimanagement.TagResourceClient)(nil) + +// TenantAccessClientAPI contains the set of methods on the TenantAccessClient type. +type TenantAccessClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.AccessInformationCreateParameters, accessName apimanagement.AccessIDName, ifMatch string) (result apimanagement.AccessInformationContract, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, accessName apimanagement.AccessIDName) (result apimanagement.AccessInformationContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, accessName apimanagement.AccessIDName) (result autorest.Response, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result apimanagement.AccessInformationCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result apimanagement.AccessInformationCollectionIterator, err error) + ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, accessName apimanagement.AccessIDName) (result apimanagement.AccessInformationSecretsContract, err error) + RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName apimanagement.AccessIDName) (result autorest.Response, err error) + RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName apimanagement.AccessIDName) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.AccessInformationUpdateParameters, accessName apimanagement.AccessIDName, ifMatch string) (result apimanagement.AccessInformationContract, err error) +} + +var _ TenantAccessClientAPI = (*apimanagement.TenantAccessClient)(nil) + +// TenantAccessGitClientAPI contains the set of methods on the TenantAccessGitClient type. +type TenantAccessGitClientAPI interface { + RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName apimanagement.AccessIDName) (result autorest.Response, err error) + RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName apimanagement.AccessIDName) (result autorest.Response, err error) +} + +var _ TenantAccessGitClientAPI = (*apimanagement.TenantAccessGitClient)(nil) + +// TenantConfigurationClientAPI contains the set of methods on the TenantConfigurationClient type. +type TenantConfigurationClientAPI interface { + Deploy(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.DeployConfigurationParameters) (result apimanagement.TenantConfigurationDeployFuture, err error) + GetSyncState(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.TenantConfigurationSyncStateContract, err error) + Save(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.SaveConfigurationParameter) (result apimanagement.TenantConfigurationSaveFuture, err error) + Validate(ctx context.Context, resourceGroupName string, serviceName string, parameters apimanagement.DeployConfigurationParameters) (result apimanagement.TenantConfigurationValidateFuture, err error) +} + +var _ TenantConfigurationClientAPI = (*apimanagement.TenantConfigurationClient)(nil) + +// UserClientAPI contains the set of methods on the UserClient type. +type UserClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters apimanagement.UserCreateParameters, notify *bool, ifMatch string) (result apimanagement.UserContract, err error) + Delete(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, deleteSubscriptions *bool, notify *bool, appType apimanagement.AppType) (result autorest.Response, err error) + GenerateSsoURL(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result apimanagement.GenerateSsoURLResult, err error) + Get(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result apimanagement.UserContract, err error) + GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result autorest.Response, err error) + GetSharedAccessToken(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters apimanagement.UserTokenParameters) (result apimanagement.UserTokenResult, err error) + ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool) (result apimanagement.UserCollectionPage, err error) + ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool) (result apimanagement.UserCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters apimanagement.UserUpdateParameters, ifMatch string) (result apimanagement.UserContract, err error) +} + +var _ UserClientAPI = (*apimanagement.UserClient)(nil) + +// UserGroupClientAPI contains the set of methods on the UserGroupClient type. +type UserGroupClientAPI interface { + List(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (result apimanagement.GroupCollectionPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (result apimanagement.GroupCollectionIterator, err error) +} + +var _ UserGroupClientAPI = (*apimanagement.UserGroupClient)(nil) + +// UserSubscriptionClientAPI contains the set of methods on the UserSubscriptionClient type. +type UserSubscriptionClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serviceName string, userID string, sid string) (result apimanagement.SubscriptionContract, err error) + List(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (result apimanagement.SubscriptionCollectionPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (result apimanagement.SubscriptionCollectionIterator, err error) +} + +var _ UserSubscriptionClientAPI = (*apimanagement.UserSubscriptionClient)(nil) + +// UserIdentitiesClientAPI contains the set of methods on the UserIdentitiesClient type. +type UserIdentitiesClientAPI interface { + List(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result apimanagement.UserIdentityCollectionPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result apimanagement.UserIdentityCollectionIterator, err error) +} + +var _ UserIdentitiesClientAPI = (*apimanagement.UserIdentitiesClient)(nil) + +// UserConfirmationPasswordClientAPI contains the set of methods on the UserConfirmationPasswordClient type. +type UserConfirmationPasswordClientAPI interface { + SendMethod(ctx context.Context, resourceGroupName string, serviceName string, userID string, appType apimanagement.AppType) (result autorest.Response, err error) +} + +var _ UserConfirmationPasswordClientAPI = (*apimanagement.UserConfirmationPasswordClient)(nil) + +// APIExportClientAPI contains the set of methods on the APIExportClient type. +type APIExportClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, formatParameter apimanagement.ExportFormat) (result apimanagement.APIExportResult, err error) +} + +var _ APIExportClientAPI = (*apimanagement.APIExportClient)(nil) diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apioperation.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apioperation.go new file mode 100644 index 000000000000..73a597ab6952 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apioperation.go @@ -0,0 +1,705 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIOperationClient is the apiManagement Client +type APIOperationClient struct { + BaseClient +} + +// NewAPIOperationClient creates an instance of the APIOperationClient client. +func NewAPIOperationClient(subscriptionID string) APIOperationClient { + return NewAPIOperationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIOperationClientWithBaseURI creates an instance of the APIOperationClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIOperationClientWithBaseURI(baseURI string, subscriptionID string) APIOperationClient { + return APIOperationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new operation in the API or updates an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIOperationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, parameters OperationContract, ifMatch string) (result OperationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.OperationContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.OperationContractProperties.DisplayName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.OperationContractProperties.DisplayName", Name: validation.MaxLength, Rule: 300, Chain: nil}, + {Target: "parameters.OperationContractProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + {Target: "parameters.OperationContractProperties.Method", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.OperationContractProperties.URLTemplate", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.OperationContractProperties.URLTemplate", Name: validation.MaxLength, Rule: 1000, Chain: nil}, + {Target: "parameters.OperationContractProperties.URLTemplate", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, operationID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIOperationClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, parameters OperationContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIOperationClient) CreateOrUpdateResponder(resp *http.Response) (result OperationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified operation in the API. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// 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. +func (client APIOperationClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, operationID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIOperationClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIOperationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the API Operation specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +func (client APIOperationClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (result OperationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIOperationClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIOperationClient) GetResponder(resp *http.Response) (result OperationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the API operation specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +func (client APIOperationClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIOperationClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIOperationClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByAPI lists a collection of the operations for the specified API. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +// tags - include tags in the response. +func (client APIOperationClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, tags string) (result OperationCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationClient.ListByAPI") + defer func() { + sc := -1 + if result.oc.Response.Response != nil { + sc = result.oc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationClient", "ListByAPI", err.Error()) + } + + result.fn = client.listByAPINextResults + req, err := client.ListByAPIPreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip, tags) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "ListByAPI", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAPISender(req) + if err != nil { + result.oc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "ListByAPI", resp, "Failure sending request") + return + } + + result.oc, err = client.ListByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "ListByAPI", resp, "Failure responding to request") + return + } + if result.oc.hasNextLink() && result.oc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAPIPreparer prepares the ListByAPI request. +func (client APIOperationClient) ListByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, tags string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if len(tags) > 0 { + queryParameters["tags"] = autorest.Encode("query", tags) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAPISender sends the ListByAPI request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationClient) ListByAPISender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAPIResponder handles the response to the ListByAPI request. The method always +// closes the http.Response Body. +func (client APIOperationClient) ListByAPIResponder(resp *http.Response) (result OperationCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAPINextResults retrieves the next set of results, if any. +func (client APIOperationClient) listByAPINextResults(ctx context.Context, lastResults OperationCollection) (result OperationCollection, err error) { + req, err := lastResults.operationCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "listByAPINextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAPISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "listByAPINextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "listByAPINextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAPIComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIOperationClient) ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, tags string) (result OperationCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationClient.ListByAPI") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAPI(ctx, resourceGroupName, serviceName, apiid, filter, top, skip, tags) + return +} + +// Update updates the details of the operation in the API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +// parameters - API Operation Update parameters. +// 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. +func (client APIOperationClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, parameters OperationUpdateContract, ifMatch string) (result OperationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, apiid, operationID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client APIOperationClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, parameters OperationUpdateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client APIOperationClient) UpdateResponder(resp *http.Response) (result OperationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apioperationpolicy.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apioperationpolicy.go new file mode 100644 index 000000000000..0c004c7e4b2a --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apioperationpolicy.go @@ -0,0 +1,540 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIOperationPolicyClient is the apiManagement Client +type APIOperationPolicyClient struct { + BaseClient +} + +// NewAPIOperationPolicyClient creates an instance of the APIOperationPolicyClient client. +func NewAPIOperationPolicyClient(subscriptionID string) APIOperationPolicyClient { + return NewAPIOperationPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIOperationPolicyClientWithBaseURI creates an instance of the APIOperationPolicyClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAPIOperationPolicyClientWithBaseURI(baseURI string, subscriptionID string) APIOperationPolicyClient { + return APIOperationPolicyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates policy configuration for the API Operation level. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +// parameters - the policy contents to apply. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIOperationPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, parameters PolicyContract, ifMatch string) (result PolicyContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationPolicyClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PolicyContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PolicyContractProperties.Value", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationPolicyClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, operationID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIOperationPolicyClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, parameters PolicyContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationPolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIOperationPolicyClient) CreateOrUpdateResponder(resp *http.Response) (result PolicyContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the policy configuration at the Api Operation. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// 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. +func (client APIOperationPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationPolicyClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationPolicyClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, operationID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIOperationPolicyClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationPolicyClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIOperationPolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the policy configuration at the API Operation level. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +// formatParameter - policy Export Format. +func (client APIOperationPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, formatParameter PolicyExportFormat) (result PolicyContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationPolicyClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationPolicyClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, formatParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIOperationPolicyClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, formatParameter PolicyExportFormat) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(formatParameter)) > 0 { + queryParameters["format"] = autorest.Encode("query", formatParameter) + } else { + queryParameters["format"] = autorest.Encode("query", "xml") + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationPolicyClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIOperationPolicyClient) GetResponder(resp *http.Response) (result PolicyContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the API operation policy specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +func (client APIOperationPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationPolicyClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationPolicyClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIOperationPolicyClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationPolicyClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIOperationPolicyClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByOperation get the list of policy configuration at the API Operation level. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +func (client APIOperationPolicyClient) ListByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (result PolicyCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationPolicyClient.ListByOperation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIOperationPolicyClient", "ListByOperation", err.Error()) + } + + req, err := client.ListByOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "ListByOperation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByOperationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "ListByOperation", resp, "Failure sending request") + return + } + + result, err = client.ListByOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIOperationPolicyClient", "ListByOperation", resp, "Failure responding to request") + return + } + + return +} + +// ListByOperationPreparer prepares the ListByOperation request. +func (client APIOperationPolicyClient) ListByOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByOperationSender sends the ListByOperation request. The method will close the +// http.Response Body if it receives an error. +func (client APIOperationPolicyClient) ListByOperationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByOperationResponder handles the response to the ListByOperation request. The method always +// closes the http.Response Body. +func (client APIOperationPolicyClient) ListByOperationResponder(resp *http.Response) (result PolicyCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apipolicy.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apipolicy.go new file mode 100644 index 000000000000..1a401d1199e8 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apipolicy.go @@ -0,0 +1,509 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIPolicyClient is the apiManagement Client +type APIPolicyClient struct { + BaseClient +} + +// NewAPIPolicyClient creates an instance of the APIPolicyClient client. +func NewAPIPolicyClient(subscriptionID string) APIPolicyClient { + return NewAPIPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIPolicyClientWithBaseURI creates an instance of the APIPolicyClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIPolicyClientWithBaseURI(baseURI string, subscriptionID string) APIPolicyClient { + return APIPolicyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates policy configuration for the API. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// parameters - the policy contents to apply. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters PolicyContract, ifMatch string) (result PolicyContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PolicyContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PolicyContractProperties.Value", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIPolicyClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIPolicyClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, parameters PolicyContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIPolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIPolicyClient) CreateOrUpdateResponder(resp *http.Response) (result PolicyContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the policy configuration at the Api. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client APIPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIPolicyClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIPolicyClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIPolicyClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIPolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the policy configuration at the API level. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// formatParameter - policy Export Format. +func (client APIPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, formatParameter PolicyExportFormat) (result PolicyContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIPolicyClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, formatParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIPolicyClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, formatParameter PolicyExportFormat) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(formatParameter)) > 0 { + queryParameters["format"] = autorest.Encode("query", formatParameter) + } else { + queryParameters["format"] = autorest.Encode("query", "xml") + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIPolicyClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIPolicyClient) GetResponder(resp *http.Response) (result PolicyContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the API policy specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client APIPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIPolicyClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIPolicyClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIPolicyClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIPolicyClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByAPI get the policy configuration at the API level. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client APIPolicyClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result PolicyCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIPolicyClient.ListByAPI") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIPolicyClient", "ListByAPI", err.Error()) + } + + req, err := client.ListByAPIPreparer(ctx, resourceGroupName, serviceName, apiid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "ListByAPI", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAPISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "ListByAPI", resp, "Failure sending request") + return + } + + result, err = client.ListByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIPolicyClient", "ListByAPI", resp, "Failure responding to request") + return + } + + return +} + +// ListByAPIPreparer prepares the ListByAPI request. +func (client APIPolicyClient) ListByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAPISender sends the ListByAPI request. The method will close the +// http.Response Body if it receives an error. +func (client APIPolicyClient) ListByAPISender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAPIResponder handles the response to the ListByAPI request. The method always +// closes the http.Response Body. +func (client APIPolicyClient) ListByAPIResponder(resp *http.Response) (result PolicyCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiproduct.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiproduct.go new file mode 100644 index 000000000000..e9d69535f407 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiproduct.go @@ -0,0 +1,183 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIProductClient is the apiManagement Client +type APIProductClient struct { + BaseClient +} + +// NewAPIProductClient creates an instance of the APIProductClient client. +func NewAPIProductClient(subscriptionID string) APIProductClient { + return NewAPIProductClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIProductClientWithBaseURI creates an instance of the APIProductClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIProductClientWithBaseURI(baseURI string, subscriptionID string) APIProductClient { + return APIProductClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByApis lists all Products, which the API is part of. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, +// gt, lt | substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client APIProductClient) ListByApis(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result ProductCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIProductClient.ListByApis") + defer func() { + sc := -1 + if result.pc.Response.Response != nil { + sc = result.pc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIProductClient", "ListByApis", err.Error()) + } + + result.fn = client.listByApisNextResults + req, err := client.ListByApisPreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIProductClient", "ListByApis", nil, "Failure preparing request") + return + } + + resp, err := client.ListByApisSender(req) + if err != nil { + result.pc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIProductClient", "ListByApis", resp, "Failure sending request") + return + } + + result.pc, err = client.ListByApisResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIProductClient", "ListByApis", resp, "Failure responding to request") + return + } + if result.pc.hasNextLink() && result.pc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByApisPreparer prepares the ListByApis request. +func (client APIProductClient) ListByApisPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByApisSender sends the ListByApis request. The method will close the +// http.Response Body if it receives an error. +func (client APIProductClient) ListByApisSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByApisResponder handles the response to the ListByApis request. The method always +// closes the http.Response Body. +func (client APIProductClient) ListByApisResponder(resp *http.Response) (result ProductCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByApisNextResults retrieves the next set of results, if any. +func (client APIProductClient) listByApisNextResults(ctx context.Context, lastResults ProductCollection) (result ProductCollection, err error) { + req, err := lastResults.productCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIProductClient", "listByApisNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByApisSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIProductClient", "listByApisNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByApisResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIProductClient", "listByApisNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByApisComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIProductClient) ListByApisComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result ProductCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIProductClient.ListByApis") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByApis(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apirelease.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apirelease.go new file mode 100644 index 000000000000..a18ab2e4429a --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apirelease.go @@ -0,0 +1,675 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIReleaseClient is the apiManagement Client +type APIReleaseClient struct { + BaseClient +} + +// NewAPIReleaseClient creates an instance of the APIReleaseClient client. +func NewAPIReleaseClient(subscriptionID string) APIReleaseClient { + return NewAPIReleaseClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIReleaseClientWithBaseURI creates an instance of the APIReleaseClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIReleaseClientWithBaseURI(baseURI string, subscriptionID string) APIReleaseClient { + return APIReleaseClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Release for the API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIReleaseClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters APIReleaseContract, ifMatch string) (result APIReleaseContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: releaseID, + Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIReleaseClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, releaseID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIReleaseClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters APIReleaseContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "releaseId": autorest.Encode("path", releaseID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIReleaseClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIReleaseClient) CreateOrUpdateResponder(resp *http.Response) (result APIReleaseContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified release in the API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client APIReleaseClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: releaseID, + Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIReleaseClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, releaseID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIReleaseClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "releaseId": autorest.Encode("path", releaseID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIReleaseClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIReleaseClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns the details of an API release. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client APIReleaseClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (result APIReleaseContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: releaseID, + Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIReleaseClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, releaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIReleaseClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "releaseId": autorest.Encode("path", releaseID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIReleaseClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIReleaseClient) GetResponder(resp *http.Response) (result APIReleaseContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag returns the etag of an API release. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client APIReleaseClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: releaseID, + Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIReleaseClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, releaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIReleaseClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "releaseId": autorest.Encode("path", releaseID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIReleaseClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIReleaseClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService 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. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| notes | filter | ge, le, eq, ne, gt, +// lt | substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client APIReleaseClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result APIReleaseCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.ListByService") + defer func() { + sc := -1 + if result.arc.Response.Response != nil { + sc = result.arc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIReleaseClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.arc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "ListByService", resp, "Failure sending request") + return + } + + result.arc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "ListByService", resp, "Failure responding to request") + return + } + if result.arc.hasNextLink() && result.arc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client APIReleaseClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client APIReleaseClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client APIReleaseClient) ListByServiceResponder(resp *http.Response) (result APIReleaseCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client APIReleaseClient) listByServiceNextResults(ctx context.Context, lastResults APIReleaseCollection) (result APIReleaseCollection, err error) { + req, err := lastResults.aPIReleaseCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIReleaseClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result APIReleaseCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + return +} + +// Update updates the details of the release of the API specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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 - API Release Update parameters. +// 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. +func (client APIReleaseClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters APIReleaseContract, ifMatch string) (result APIReleaseContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: releaseID, + Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIReleaseClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, apiid, releaseID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client APIReleaseClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters APIReleaseContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "releaseId": autorest.Encode("path", releaseID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client APIReleaseClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client APIReleaseClient) UpdateResponder(resp *http.Response) (result APIReleaseContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apirevision.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apirevision.go new file mode 100644 index 000000000000..4432de062143 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apirevision.go @@ -0,0 +1,183 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIRevisionClient is the apiManagement Client +type APIRevisionClient struct { + BaseClient +} + +// NewAPIRevisionClient creates an instance of the APIRevisionClient client. +func NewAPIRevisionClient(subscriptionID string) APIRevisionClient { + return NewAPIRevisionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIRevisionClientWithBaseURI creates an instance of the APIRevisionClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIRevisionClientWithBaseURI(baseURI string, subscriptionID string) APIRevisionClient { + return APIRevisionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByService lists all revisions of an API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| apiRevision | filter | ge, le, eq, ne, +// gt, lt | substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client APIRevisionClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result APIRevisionCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIRevisionClient.ListByService") + defer func() { + sc := -1 + if result.arc.Response.Response != nil { + sc = result.arc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIRevisionClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIRevisionClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.arc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIRevisionClient", "ListByService", resp, "Failure sending request") + return + } + + result.arc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIRevisionClient", "ListByService", resp, "Failure responding to request") + return + } + if result.arc.hasNextLink() && result.arc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client APIRevisionClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client APIRevisionClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client APIRevisionClient) ListByServiceResponder(resp *http.Response) (result APIRevisionCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client APIRevisionClient) listByServiceNextResults(ctx context.Context, lastResults APIRevisionCollection) (result APIRevisionCollection, err error) { + req, err := lastResults.aPIRevisionCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIRevisionClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIRevisionClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIRevisionClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIRevisionClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result APIRevisionCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIRevisionClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apischema.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apischema.go new file mode 100644 index 000000000000..1c27f1d83d67 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apischema.go @@ -0,0 +1,591 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APISchemaClient is the apiManagement Client +type APISchemaClient struct { + BaseClient +} + +// NewAPISchemaClient creates an instance of the APISchemaClient client. +func NewAPISchemaClient(subscriptionID string) APISchemaClient { + return NewAPISchemaClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPISchemaClientWithBaseURI creates an instance of the APISchemaClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPISchemaClientWithBaseURI(baseURI string, subscriptionID string) APISchemaClient { + return APISchemaClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates schema configuration for the API. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// schemaID - schema identifier within an API. Must be unique in the current API Management service instance. +// parameters - the schema contents to apply. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APISchemaClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string, parameters SchemaContract, ifMatch string) (result APISchemaCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APISchemaClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: schemaID, + Constraints: []validation.Constraint{{Target: "schemaID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "schemaID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "schemaID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SchemaContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SchemaContractProperties.ContentType", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APISchemaClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, schemaID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APISchemaClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string, parameters SchemaContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaId": autorest.Encode("path", schemaID), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APISchemaClient) CreateOrUpdateSender(req *http.Request) (future APISchemaCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APISchemaClient) CreateOrUpdateResponder(resp *http.Response) (result SchemaContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the schema configuration at the Api. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// schemaID - schema 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. +// force - if true removes all references to the schema before deleting it. +func (client APISchemaClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string, ifMatch string, force *bool) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APISchemaClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: schemaID, + Constraints: []validation.Constraint{{Target: "schemaID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "schemaID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "schemaID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APISchemaClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, schemaID, ifMatch, force) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APISchemaClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string, ifMatch string, force *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaId": autorest.Encode("path", schemaID), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if force != nil { + queryParameters["force"] = autorest.Encode("query", *force) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APISchemaClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APISchemaClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the schema configuration at the API level. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// schemaID - schema identifier within an API. Must be unique in the current API Management service instance. +func (client APISchemaClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string) (result SchemaContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APISchemaClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: schemaID, + Constraints: []validation.Constraint{{Target: "schemaID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "schemaID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "schemaID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APISchemaClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, schemaID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APISchemaClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaId": autorest.Encode("path", schemaID), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APISchemaClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APISchemaClient) GetResponder(resp *http.Response) (result SchemaContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the schema specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// schemaID - schema identifier within an API. Must be unique in the current API Management service instance. +func (client APISchemaClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APISchemaClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: schemaID, + Constraints: []validation.Constraint{{Target: "schemaID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "schemaID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "schemaID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APISchemaClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, schemaID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APISchemaClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, schemaID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaId": autorest.Encode("path", schemaID), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APISchemaClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APISchemaClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByAPI get the schema configuration at the API level. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| contentType | filter | ge, le, eq, ne, +// gt, lt | substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client APISchemaClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result SchemaCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APISchemaClient.ListByAPI") + defer func() { + sc := -1 + if result.sc.Response.Response != nil { + sc = result.sc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APISchemaClient", "ListByAPI", err.Error()) + } + + result.fn = client.listByAPINextResults + req, err := client.ListByAPIPreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "ListByAPI", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAPISender(req) + if err != nil { + result.sc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "ListByAPI", resp, "Failure sending request") + return + } + + result.sc, err = client.ListByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "ListByAPI", resp, "Failure responding to request") + return + } + if result.sc.hasNextLink() && result.sc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAPIPreparer prepares the ListByAPI request. +func (client APISchemaClient) ListByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAPISender sends the ListByAPI request. The method will close the +// http.Response Body if it receives an error. +func (client APISchemaClient) ListByAPISender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAPIResponder handles the response to the ListByAPI request. The method always +// closes the http.Response Body. +func (client APISchemaClient) ListByAPIResponder(resp *http.Response) (result SchemaCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAPINextResults retrieves the next set of results, if any. +func (client APISchemaClient) listByAPINextResults(ctx context.Context, lastResults SchemaCollection) (result SchemaCollection, err error) { + req, err := lastResults.schemaCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "listByAPINextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAPISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "listByAPINextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaClient", "listByAPINextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAPIComplete enumerates all values, automatically crossing page boundaries as required. +func (client APISchemaClient) ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result SchemaCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APISchemaClient.ListByAPI") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAPI(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apitagdescription.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apitagdescription.go new file mode 100644 index 000000000000..e4fbc5ef9a82 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apitagdescription.go @@ -0,0 +1,594 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APITagDescriptionClient is the apiManagement Client +type APITagDescriptionClient struct { + BaseClient +} + +// NewAPITagDescriptionClient creates an instance of the APITagDescriptionClient client. +func NewAPITagDescriptionClient(subscriptionID string) APITagDescriptionClient { + return NewAPITagDescriptionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPITagDescriptionClientWithBaseURI creates an instance of the APITagDescriptionClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAPITagDescriptionClientWithBaseURI(baseURI string, subscriptionID string) APITagDescriptionClient { + return APITagDescriptionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create/Update tag description in scope of the Api. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// tagDescriptionID - tag description identifier. Used when creating tagDescription for API/Tag association. +// Based on API and Tag names. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APITagDescriptionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string, parameters TagDescriptionCreateParameters, ifMatch string) (result TagDescriptionContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: tagDescriptionID, + Constraints: []validation.Constraint{{Target: "tagDescriptionID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagDescriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagDescriptionID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TagDescriptionBaseProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TagDescriptionBaseProperties.ExternalDocsURL", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TagDescriptionBaseProperties.ExternalDocsURL", Name: validation.MaxLength, Rule: 2000, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.APITagDescriptionClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, tagDescriptionID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APITagDescriptionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string, parameters TagDescriptionCreateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagDescriptionId": autorest.Encode("path", tagDescriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APITagDescriptionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APITagDescriptionClient) CreateOrUpdateResponder(resp *http.Response) (result TagDescriptionContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete tag description for the Api. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// tagDescriptionID - tag description identifier. Used when creating tagDescription for API/Tag association. +// Based on API and Tag names. +// 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. +func (client APITagDescriptionClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: tagDescriptionID, + Constraints: []validation.Constraint{{Target: "tagDescriptionID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagDescriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagDescriptionID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APITagDescriptionClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, tagDescriptionID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APITagDescriptionClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagDescriptionId": autorest.Encode("path", tagDescriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APITagDescriptionClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APITagDescriptionClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get Tag description in scope of API +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// tagDescriptionID - tag description identifier. Used when creating tagDescription for API/Tag association. +// Based on API and Tag names. +func (client APITagDescriptionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string) (result TagDescriptionContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: tagDescriptionID, + Constraints: []validation.Constraint{{Target: "tagDescriptionID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagDescriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagDescriptionID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APITagDescriptionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, tagDescriptionID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APITagDescriptionClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagDescriptionId": autorest.Encode("path", tagDescriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APITagDescriptionClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APITagDescriptionClient) GetResponder(resp *http.Response) (result TagDescriptionContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state version of the tag specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// tagDescriptionID - tag description identifier. Used when creating tagDescription for API/Tag association. +// Based on API and Tag names. +func (client APITagDescriptionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: tagDescriptionID, + Constraints: []validation.Constraint{{Target: "tagDescriptionID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagDescriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagDescriptionID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APITagDescriptionClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, tagDescriptionID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APITagDescriptionClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagDescriptionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagDescriptionId": autorest.Encode("path", tagDescriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APITagDescriptionClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APITagDescriptionClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService 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 +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, +// gt, lt | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client APITagDescriptionClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result TagDescriptionCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.ListByService") + defer func() { + sc := -1 + if result.tdc.Response.Response != nil { + sc = result.tdc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APITagDescriptionClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.tdc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "ListByService", resp, "Failure sending request") + return + } + + result.tdc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "ListByService", resp, "Failure responding to request") + return + } + if result.tdc.hasNextLink() && result.tdc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client APITagDescriptionClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client APITagDescriptionClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client APITagDescriptionClient) ListByServiceResponder(resp *http.Response) (result TagDescriptionCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client APITagDescriptionClient) listByServiceNextResults(ctx context.Context, lastResults TagDescriptionCollection) (result TagDescriptionCollection, err error) { + req, err := lastResults.tagDescriptionCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APITagDescriptionClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client APITagDescriptionClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result TagDescriptionCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APITagDescriptionClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiversionset.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiversionset.go new file mode 100644 index 000000000000..c7ee5ff2eb0a --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/apiversionset.go @@ -0,0 +1,649 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIVersionSetClient is the apiManagement Client +type APIVersionSetClient struct { + BaseClient +} + +// NewAPIVersionSetClient creates an instance of the APIVersionSetClient client. +func NewAPIVersionSetClient(subscriptionID string) APIVersionSetClient { + return NewAPIVersionSetClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIVersionSetClientWithBaseURI creates an instance of the APIVersionSetClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIVersionSetClientWithBaseURI(baseURI string, subscriptionID string) APIVersionSetClient { + return APIVersionSetClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or Updates a Api Version Set. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// versionSetID - api Version Set identifier. Must be unique in the current API Management service instance. +// parameters - create or update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client APIVersionSetClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, parameters APIVersionSetContract, ifMatch string) (result APIVersionSetContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIVersionSetClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: versionSetID, + Constraints: []validation.Constraint{{Target: "versionSetID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "versionSetID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "versionSetID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.APIVersionSetContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.APIVersionSetContractProperties.DisplayName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.APIVersionSetContractProperties.DisplayName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "parameters.APIVersionSetContractProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.APIVersionSetClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, versionSetID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client APIVersionSetClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, parameters APIVersionSetContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "versionSetId": autorest.Encode("path", versionSetID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client APIVersionSetClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client APIVersionSetClient) CreateOrUpdateResponder(resp *http.Response) (result APIVersionSetContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific Api Version Set. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client APIVersionSetClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIVersionSetClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: versionSetID, + Constraints: []validation.Constraint{{Target: "versionSetID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "versionSetID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "versionSetID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIVersionSetClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, versionSetID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIVersionSetClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "versionSetId": autorest.Encode("path", versionSetID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIVersionSetClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIVersionSetClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the Api Version Set specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// versionSetID - api Version Set identifier. Must be unique in the current API Management service instance. +func (client APIVersionSetClient) Get(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string) (result APIVersionSetContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIVersionSetClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: versionSetID, + Constraints: []validation.Constraint{{Target: "versionSetID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "versionSetID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "versionSetID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIVersionSetClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, versionSetID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIVersionSetClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "versionSetId": autorest.Encode("path", versionSetID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIVersionSetClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIVersionSetClient) GetResponder(resp *http.Response) (result APIVersionSetContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the Api Version Set specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// versionSetID - api Version Set identifier. Must be unique in the current API Management service instance. +func (client APIVersionSetClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIVersionSetClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: versionSetID, + Constraints: []validation.Constraint{{Target: "versionSetID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "versionSetID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "versionSetID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIVersionSetClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, versionSetID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client APIVersionSetClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "versionSetId": autorest.Encode("path", versionSetID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client APIVersionSetClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client APIVersionSetClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of API Version Sets in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
+// top - number of records to return. +// skip - number of records to skip. +func (client APIVersionSetClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result APIVersionSetCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIVersionSetClient.ListByService") + defer func() { + sc := -1 + if result.avsc.Response.Response != nil { + sc = result.avsc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.APIVersionSetClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.avsc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "ListByService", resp, "Failure sending request") + return + } + + result.avsc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "ListByService", resp, "Failure responding to request") + return + } + if result.avsc.hasNextLink() && result.avsc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client APIVersionSetClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client APIVersionSetClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client APIVersionSetClient) ListByServiceResponder(resp *http.Response) (result APIVersionSetCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client APIVersionSetClient) listByServiceNextResults(ctx context.Context, lastResults APIVersionSetCollection) (result APIVersionSetCollection, err error) { + req, err := lastResults.aPIVersionSetCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIVersionSetClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result APIVersionSetCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIVersionSetClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// Update updates the details of the Api VersionSet specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// versionSetID - api Version Set identifier. Must be unique in the current API Management service instance. +// parameters - update parameters. +// 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. +func (client APIVersionSetClient) Update(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, parameters APIVersionSetUpdateParameters, ifMatch string) (result APIVersionSetContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIVersionSetClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: versionSetID, + Constraints: []validation.Constraint{{Target: "versionSetID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "versionSetID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "versionSetID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIVersionSetClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, versionSetID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIVersionSetClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client APIVersionSetClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, parameters APIVersionSetUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "versionSetId": autorest.Encode("path", versionSetID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client APIVersionSetClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client APIVersionSetClient) UpdateResponder(resp *http.Response) (result APIVersionSetContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/authorizationserver.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/authorizationserver.go new file mode 100644 index 000000000000..7db3dddf17cb --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/authorizationserver.go @@ -0,0 +1,746 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AuthorizationServerClient is the apiManagement Client +type AuthorizationServerClient struct { + BaseClient +} + +// NewAuthorizationServerClient creates an instance of the AuthorizationServerClient client. +func NewAuthorizationServerClient(subscriptionID string) AuthorizationServerClient { + return NewAuthorizationServerClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAuthorizationServerClientWithBaseURI creates an instance of the AuthorizationServerClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAuthorizationServerClientWithBaseURI(baseURI string, subscriptionID string) AuthorizationServerClient { + return AuthorizationServerClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates new authorization server or updates an existing authorization server. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// authsid - identifier of the authorization server. +// parameters - create or update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client AuthorizationServerClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerContract, ifMatch string) (result AuthorizationServerContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: authsid, + Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "authsid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AuthorizationServerContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.AuthorizationServerContractProperties.DisplayName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AuthorizationServerContractProperties.DisplayName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "parameters.AuthorizationServerContractProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + {Target: "parameters.AuthorizationServerContractProperties.ClientRegistrationEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AuthorizationServerContractProperties.AuthorizationEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AuthorizationServerContractProperties.GrantTypes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AuthorizationServerContractProperties.ClientID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.AuthorizationServerClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, authsid, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AuthorizationServerClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authsid": autorest.Encode("path", authsid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AuthorizationServerClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AuthorizationServerClient) CreateOrUpdateResponder(resp *http.Response) (result AuthorizationServerContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific authorization server instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// authsid - identifier of the authorization server. +// 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. +func (client AuthorizationServerClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: authsid, + Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "authsid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.AuthorizationServerClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, authsid, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AuthorizationServerClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authsid": autorest.Encode("path", authsid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AuthorizationServerClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AuthorizationServerClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the authorization server specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// authsid - identifier of the authorization server. +func (client AuthorizationServerClient) Get(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (result AuthorizationServerContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: authsid, + Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "authsid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.AuthorizationServerClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, authsid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AuthorizationServerClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authsid": autorest.Encode("path", authsid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AuthorizationServerClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AuthorizationServerClient) GetResponder(resp *http.Response) (result AuthorizationServerContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the authorizationServer specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// authsid - identifier of the authorization server. +func (client AuthorizationServerClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: authsid, + Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "authsid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.AuthorizationServerClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, authsid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client AuthorizationServerClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authsid": autorest.Encode("path", authsid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client AuthorizationServerClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client AuthorizationServerClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of authorization servers defined within a service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +func (client AuthorizationServerClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result AuthorizationServerCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.ListByService") + defer func() { + sc := -1 + if result.asc.Response.Response != nil { + sc = result.asc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.AuthorizationServerClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.asc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "ListByService", resp, "Failure sending request") + return + } + + result.asc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "ListByService", resp, "Failure responding to request") + return + } + if result.asc.hasNextLink() && result.asc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client AuthorizationServerClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client AuthorizationServerClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client AuthorizationServerClient) ListByServiceResponder(resp *http.Response) (result AuthorizationServerCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client AuthorizationServerClient) listByServiceNextResults(ctx context.Context, lastResults AuthorizationServerCollection) (result AuthorizationServerCollection, err error) { + req, err := lastResults.authorizationServerCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client AuthorizationServerClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result AuthorizationServerCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// ListSecrets gets the client secret details of the authorization server. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// authsid - identifier of the authorization server. +func (client AuthorizationServerClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (result AuthorizationServerSecretsContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.ListSecrets") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: authsid, + Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "authsid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.AuthorizationServerClient", "ListSecrets", err.Error()) + } + + req, err := client.ListSecretsPreparer(ctx, resourceGroupName, serviceName, authsid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "ListSecrets", nil, "Failure preparing request") + return + } + + resp, err := client.ListSecretsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "ListSecrets", resp, "Failure sending request") + return + } + + result, err = client.ListSecretsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "ListSecrets", resp, "Failure responding to request") + return + } + + return +} + +// ListSecretsPreparer prepares the ListSecrets request. +func (client AuthorizationServerClient) ListSecretsPreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authsid": autorest.Encode("path", authsid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSecretsSender sends the ListSecrets request. The method will close the +// http.Response Body if it receives an error. +func (client AuthorizationServerClient) ListSecretsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSecretsResponder handles the response to the ListSecrets request. The method always +// closes the http.Response Body. +func (client AuthorizationServerClient) ListSecretsResponder(resp *http.Response) (result AuthorizationServerSecretsContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the details of the authorization server specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// authsid - identifier of the authorization server. +// parameters - oAuth2 Server settings Update parameters. +// 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. +func (client AuthorizationServerClient) Update(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerUpdateContract, ifMatch string) (result AuthorizationServerContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: authsid, + Constraints: []validation.Constraint{{Target: "authsid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "authsid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "authsid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.AuthorizationServerClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, authsid, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.AuthorizationServerClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AuthorizationServerClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerUpdateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authsid": autorest.Encode("path", authsid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AuthorizationServerClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AuthorizationServerClient) UpdateResponder(resp *http.Response) (result AuthorizationServerContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/backend.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/backend.go new file mode 100644 index 000000000000..08ea39f865cb --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/backend.go @@ -0,0 +1,742 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// BackendClient is the apiManagement Client +type BackendClient struct { + BaseClient +} + +// NewBackendClient creates an instance of the BackendClient client. +func NewBackendClient(subscriptionID string) BackendClient { + return NewBackendClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackendClientWithBaseURI creates an instance of the BackendClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewBackendClientWithBaseURI(baseURI string, subscriptionID string) BackendClient { + return BackendClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or Updates a backend. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// backendID - identifier of the Backend entity. Must be unique in the current API Management service instance. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client BackendClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters BackendContract, ifMatch string) (result BackendContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: backendID, + Constraints: []validation.Constraint{{Target: "backendID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "backendID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.BackendContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.BackendContractProperties.URL", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.BackendContractProperties.URL", Name: validation.MaxLength, Rule: 2000, Chain: nil}, + {Target: "parameters.BackendContractProperties.URL", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.BackendClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, backendID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackendClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters BackendContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backendId": autorest.Encode("path", backendID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client BackendClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackendClient) CreateOrUpdateResponder(resp *http.Response) (result BackendContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified backend. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client BackendClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: backendID, + Constraints: []validation.Constraint{{Target: "backendID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "backendID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.BackendClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, backendID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client BackendClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backendId": autorest.Encode("path", backendID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client BackendClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client BackendClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the backend specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// backendID - identifier of the Backend entity. Must be unique in the current API Management service instance. +func (client BackendClient) Get(ctx context.Context, resourceGroupName string, serviceName string, backendID string) (result BackendContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: backendID, + Constraints: []validation.Constraint{{Target: "backendID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "backendID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.BackendClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, backendID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackendClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, backendID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backendId": autorest.Encode("path", backendID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client BackendClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackendClient) GetResponder(resp *http.Response) (result BackendContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the backend specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// backendID - identifier of the Backend entity. Must be unique in the current API Management service instance. +func (client BackendClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, backendID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: backendID, + Constraints: []validation.Constraint{{Target: "backendID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "backendID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.BackendClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, backendID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client BackendClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, backendID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backendId": autorest.Encode("path", backendID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client BackendClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client BackendClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of backends in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +func (client BackendClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result BackendCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendClient.ListByService") + defer func() { + sc := -1 + if result.bc.Response.Response != nil { + sc = result.bc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.BackendClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.bc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "ListByService", resp, "Failure sending request") + return + } + + result.bc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "ListByService", resp, "Failure responding to request") + return + } + if result.bc.hasNextLink() && result.bc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client BackendClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client BackendClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client BackendClient) ListByServiceResponder(resp *http.Response) (result BackendCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client BackendClient) listByServiceNextResults(ctx context.Context, lastResults BackendCollection) (result BackendCollection, err error) { + req, err := lastResults.backendCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.BackendClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.BackendClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client BackendClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result BackendCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// Reconnect notifies the APIM proxy to create a new connection to the backend after the specified timeout. If no +// timeout was specified, timeout of 2 minutes is used. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// backendID - identifier of the Backend entity. Must be unique in the current API Management service instance. +// parameters - reconnect request parameters. +func (client BackendClient) Reconnect(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters *BackendReconnectContract) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendClient.Reconnect") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: backendID, + Constraints: []validation.Constraint{{Target: "backendID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "backendID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.BackendClient", "Reconnect", err.Error()) + } + + req, err := client.ReconnectPreparer(ctx, resourceGroupName, serviceName, backendID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Reconnect", nil, "Failure preparing request") + return + } + + resp, err := client.ReconnectSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Reconnect", resp, "Failure sending request") + return + } + + result, err = client.ReconnectResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Reconnect", resp, "Failure responding to request") + return + } + + return +} + +// ReconnectPreparer prepares the Reconnect request. +func (client BackendClient) ReconnectPreparer(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters *BackendReconnectContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backendId": autorest.Encode("path", backendID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ReconnectSender sends the Reconnect request. The method will close the +// http.Response Body if it receives an error. +func (client BackendClient) ReconnectSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ReconnectResponder handles the response to the Reconnect request. The method always +// closes the http.Response Body. +func (client BackendClient) ReconnectResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing backend. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// backendID - identifier of the Backend entity. Must be unique in the current API Management service instance. +// parameters - update parameters. +// 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. +func (client BackendClient) Update(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters BackendUpdateParameters, ifMatch string) (result BackendContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: backendID, + Constraints: []validation.Constraint{{Target: "backendID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "backendID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.BackendClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, backendID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.BackendClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client BackendClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters BackendUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backendId": autorest.Encode("path", backendID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client BackendClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client BackendClient) UpdateResponder(resp *http.Response) (result BackendContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/cache.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/cache.go new file mode 100644 index 000000000000..e8c30a4e528d --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/cache.go @@ -0,0 +1,653 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CacheClient is the apiManagement Client +type CacheClient struct { + BaseClient +} + +// NewCacheClient creates an instance of the CacheClient client. +func NewCacheClient(subscriptionID string) CacheClient { + return NewCacheClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCacheClientWithBaseURI creates an instance of the CacheClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCacheClientWithBaseURI(baseURI string, subscriptionID string) CacheClient { + return CacheClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an External Cache to be used in Api Management instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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). +// parameters - create or Update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client CacheClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, parameters CacheContract, ifMatch string) (result CacheContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CacheClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: cacheID, + Constraints: []validation.Constraint{{Target: "cacheID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "cacheID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "cacheID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.CacheContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.CacheContractProperties.Description", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.CacheContractProperties.Description", Name: validation.MaxLength, Rule: 2000, Chain: nil}}}, + {Target: "parameters.CacheContractProperties.ConnectionString", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CacheContractProperties.ConnectionString", Name: validation.MaxLength, Rule: 300, Chain: nil}}}, + {Target: "parameters.CacheContractProperties.UseFromLocation", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.CacheContractProperties.UseFromLocation", Name: validation.MaxLength, Rule: 256, Chain: nil}}}, + {Target: "parameters.CacheContractProperties.ResourceID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.CacheContractProperties.ResourceID", Name: validation.MaxLength, Rule: 2000, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.CacheClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, cacheID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CacheClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, parameters CacheContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheId": autorest.Encode("path", cacheID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CacheClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CacheClient) CreateOrUpdateResponder(resp *http.Response) (result CacheContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific Cache. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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). +// 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. +func (client CacheClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CacheClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: cacheID, + Constraints: []validation.Constraint{{Target: "cacheID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "cacheID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "cacheID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.CacheClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, cacheID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CacheClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheId": autorest.Encode("path", cacheID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CacheClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CacheClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the Cache specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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). +func (client CacheClient) Get(ctx context.Context, resourceGroupName string, serviceName string, cacheID string) (result CacheContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CacheClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: cacheID, + Constraints: []validation.Constraint{{Target: "cacheID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "cacheID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "cacheID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.CacheClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, cacheID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client CacheClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, cacheID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheId": autorest.Encode("path", cacheID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CacheClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CacheClient) GetResponder(resp *http.Response) (result CacheContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the Cache specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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). +func (client CacheClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, cacheID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CacheClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: cacheID, + Constraints: []validation.Constraint{{Target: "cacheID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "cacheID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "cacheID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.CacheClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, cacheID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client CacheClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, cacheID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheId": autorest.Encode("path", cacheID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client CacheClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client CacheClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of all external Caches in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// top - number of records to return. +// skip - number of records to skip. +func (client CacheClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (result CacheCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CacheClient.ListByService") + defer func() { + sc := -1 + if result.cc.Response.Response != nil { + sc = result.cc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.CacheClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.cc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "ListByService", resp, "Failure sending request") + return + } + + result.cc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "ListByService", resp, "Failure responding to request") + return + } + if result.cc.hasNextLink() && result.cc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client CacheClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client CacheClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client CacheClient) ListByServiceResponder(resp *http.Response) (result CacheCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client CacheClient) listByServiceNextResults(ctx context.Context, lastResults CacheCollection) (result CacheCollection, err error) { + req, err := lastResults.cacheCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.CacheClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.CacheClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client CacheClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (result CacheCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CacheClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, top, skip) + return +} + +// Update updates the details of the cache specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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). +// parameters - update parameters. +// 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. +func (client CacheClient) Update(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, parameters CacheUpdateParameters, ifMatch string) (result CacheContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CacheClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: cacheID, + Constraints: []validation.Constraint{{Target: "cacheID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "cacheID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "cacheID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.CacheClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, cacheID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CacheClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CacheClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, parameters CacheUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheId": autorest.Encode("path", cacheID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client CacheClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CacheClient) UpdateResponder(resp *http.Response) (result CacheContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/certificate.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/certificate.go new file mode 100644 index 000000000000..ed180cfa787c --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/certificate.go @@ -0,0 +1,650 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CertificateClient is the apiManagement Client +type CertificateClient struct { + BaseClient +} + +// NewCertificateClient creates an instance of the CertificateClient client. +func NewCertificateClient(subscriptionID string) CertificateClient { + return NewCertificateClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCertificateClientWithBaseURI creates an instance of the CertificateClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCertificateClientWithBaseURI(baseURI string, subscriptionID string) CertificateClient { + return CertificateClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the certificate being used for authentication with the backend. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// certificateID - identifier of the certificate entity. Must be unique in the current API Management service +// instance. +// parameters - create or Update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client CertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, parameters CertificateCreateOrUpdateParameters, ifMatch string) (result CertificateContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.CertificateClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, certificateID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CertificateClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, parameters CertificateCreateOrUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateId": autorest.Encode("path", certificateID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CertificateClient) CreateOrUpdateResponder(resp *http.Response) (result CertificateContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific certificate. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client CertificateClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.CertificateClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, certificateID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CertificateClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateId": autorest.Encode("path", certificateID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client CertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the certificate specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// certificateID - identifier of the certificate entity. Must be unique in the current API Management service +// instance. +func (client CertificateClient) Get(ctx context.Context, resourceGroupName string, serviceName string, certificateID string) (result CertificateContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.CertificateClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, certificateID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client CertificateClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, certificateID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateId": autorest.Encode("path", certificateID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CertificateClient) GetResponder(resp *http.Response) (result CertificateContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the certificate specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// certificateID - identifier of the certificate entity. Must be unique in the current API Management service +// instance. +func (client CertificateClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, certificateID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.CertificateClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, certificateID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client CertificateClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, certificateID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateId": autorest.Encode("path", certificateID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client CertificateClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of all certificates in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 | +// |
+// top - number of records to return. +// skip - number of records to skip. +// isKeyVaultRefreshFailed - when set to true, the response contains only certificates entities which failed +// refresh. +func (client CertificateClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (result CertificateCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.ListByService") + defer func() { + sc := -1 + if result.cc.Response.Response != nil { + sc = result.cc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.CertificateClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip, isKeyVaultRefreshFailed) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.cc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "ListByService", resp, "Failure sending request") + return + } + + result.cc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "ListByService", resp, "Failure responding to request") + return + } + if result.cc.hasNextLink() && result.cc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client CertificateClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if isKeyVaultRefreshFailed != nil { + queryParameters["isKeyVaultRefreshFailed"] = autorest.Encode("query", *isKeyVaultRefreshFailed) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client CertificateClient) ListByServiceResponder(resp *http.Response) (result CertificateCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client CertificateClient) listByServiceNextResults(ctx context.Context, lastResults CertificateCollection) (result CertificateCollection, err error) { + req, err := lastResults.certificateCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client CertificateClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (result CertificateCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip, isKeyVaultRefreshFailed) + return +} + +// RefreshSecret from KeyVault, Refresh the certificate being used for authentication with the backend. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// certificateID - identifier of the certificate entity. Must be unique in the current API Management service +// instance. +func (client CertificateClient) RefreshSecret(ctx context.Context, resourceGroupName string, serviceName string, certificateID string) (result CertificateContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CertificateClient.RefreshSecret") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.CertificateClient", "RefreshSecret", err.Error()) + } + + req, err := client.RefreshSecretPreparer(ctx, resourceGroupName, serviceName, certificateID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "RefreshSecret", nil, "Failure preparing request") + return + } + + resp, err := client.RefreshSecretSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "RefreshSecret", resp, "Failure sending request") + return + } + + result, err = client.RefreshSecretResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.CertificateClient", "RefreshSecret", resp, "Failure responding to request") + return + } + + return +} + +// RefreshSecretPreparer prepares the RefreshSecret request. +func (client CertificateClient) RefreshSecretPreparer(ctx context.Context, resourceGroupName string, serviceName string, certificateID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateId": autorest.Encode("path", certificateID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RefreshSecretSender sends the RefreshSecret request. The method will close the +// http.Response Body if it receives an error. +func (client CertificateClient) RefreshSecretSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RefreshSecretResponder handles the response to the RefreshSecret request. The method always +// closes the http.Response Body. +func (client CertificateClient) RefreshSecretResponder(resp *http.Response) (result CertificateContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/client.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/client.go new file mode 100644 index 000000000000..cdb6f15e4601 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/client.go @@ -0,0 +1,41 @@ +// Package apimanagement implements the Azure ARM Apimanagement service API version 2021-01-01-preview. +// +// ApiManagement Client +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Apimanagement + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Apimanagement. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/contentitem.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/contentitem.go new file mode 100644 index 000000000000..c133181fb3c1 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/contentitem.go @@ -0,0 +1,546 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ContentItemClient is the apiManagement Client +type ContentItemClient struct { + BaseClient +} + +// NewContentItemClient creates an instance of the ContentItemClient client. +func NewContentItemClient(subscriptionID string) ContentItemClient { + return NewContentItemClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewContentItemClientWithBaseURI creates an instance of the ContentItemClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewContentItemClientWithBaseURI(baseURI string, subscriptionID string) ContentItemClient { + return ContentItemClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new developer portal's content item specified by the provided content type. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// contentTypeID - content type identifier. +// contentItemID - content item identifier. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client ContentItemClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string) (result ContentItemContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentItemClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: contentTypeID, + Constraints: []validation.Constraint{{Target: "contentTypeID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentTypeID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: contentItemID, + Constraints: []validation.Constraint{{Target: "contentItemID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentItemID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ContentItemClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, contentTypeID, contentItemID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ContentItemClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "contentItemId": autorest.Encode("path", contentItemID), + "contentTypeId": autorest.Encode("path", contentTypeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ContentItemClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ContentItemClient) CreateOrUpdateResponder(resp *http.Response) (result ContentItemContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the specified developer portal's content item. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// contentTypeID - content type identifier. +// contentItemID - content item 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. +func (client ContentItemClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentItemClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: contentTypeID, + Constraints: []validation.Constraint{{Target: "contentTypeID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentTypeID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: contentItemID, + Constraints: []validation.Constraint{{Target: "contentItemID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentItemID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ContentItemClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, contentTypeID, contentItemID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ContentItemClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "contentItemId": autorest.Encode("path", contentItemID), + "contentTypeId": autorest.Encode("path", contentTypeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ContentItemClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ContentItemClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns the developer portal's content item specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// contentTypeID - content type identifier. +// contentItemID - content item identifier. +func (client ContentItemClient) Get(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string) (result ContentItemContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentItemClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: contentTypeID, + Constraints: []validation.Constraint{{Target: "contentTypeID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentTypeID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: contentItemID, + Constraints: []validation.Constraint{{Target: "contentItemID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentItemID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ContentItemClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, contentTypeID, contentItemID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ContentItemClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "contentItemId": autorest.Encode("path", contentItemID), + "contentTypeId": autorest.Encode("path", contentTypeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ContentItemClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ContentItemClient) GetResponder(resp *http.Response) (result ContentItemContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag returns the entity state (ETag) version of the developer portal's content item specified by its +// identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// contentTypeID - content type identifier. +// contentItemID - content item identifier. +func (client ContentItemClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentItemClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: contentTypeID, + Constraints: []validation.Constraint{{Target: "contentTypeID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentTypeID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: contentItemID, + Constraints: []validation.Constraint{{Target: "contentItemID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentItemID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ContentItemClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, contentTypeID, contentItemID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client ContentItemClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "contentItemId": autorest.Encode("path", contentItemID), + "contentTypeId": autorest.Encode("path", contentTypeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client ContentItemClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client ContentItemClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists developer portal's content items specified by the provided content type. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// contentTypeID - content type identifier. +func (client ContentItemClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string) (result ContentItemCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentItemClient.ListByService") + defer func() { + sc := -1 + if result.cic.Response.Response != nil { + sc = result.cic.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: contentTypeID, + Constraints: []validation.Constraint{{Target: "contentTypeID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentTypeID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ContentItemClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, contentTypeID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.cic.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "ListByService", resp, "Failure sending request") + return + } + + result.cic, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "ListByService", resp, "Failure responding to request") + return + } + if result.cic.hasNextLink() && result.cic.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client ContentItemClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "contentTypeId": autorest.Encode("path", contentTypeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client ContentItemClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client ContentItemClient) ListByServiceResponder(resp *http.Response) (result ContentItemCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client ContentItemClient) listByServiceNextResults(ctx context.Context, lastResults ContentItemCollection) (result ContentItemCollection, err error) { + req, err := lastResults.contentItemCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentItemClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ContentItemClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string) (result ContentItemCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentItemClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, contentTypeID) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/contenttype.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/contenttype.go new file mode 100644 index 000000000000..ddb90a0bb0e8 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/contenttype.go @@ -0,0 +1,438 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ContentTypeClient is the apiManagement Client +type ContentTypeClient struct { + BaseClient +} + +// NewContentTypeClient creates an instance of the ContentTypeClient client. +func NewContentTypeClient(subscriptionID string) ContentTypeClient { + return NewContentTypeClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewContentTypeClientWithBaseURI creates an instance of the ContentTypeClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewContentTypeClientWithBaseURI(baseURI string, subscriptionID string) ContentTypeClient { + return ContentTypeClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the developer portal's content type. Content types describe content items' +// properties, validation rules, and constraints. Custom content types' identifiers need to start with the `c-` prefix. +// Built-in content types can't be modified. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// contentTypeID - content type identifier. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client ContentTypeClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string) (result ContentTypeContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentTypeClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: contentTypeID, + Constraints: []validation.Constraint{{Target: "contentTypeID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentTypeID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ContentTypeClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, contentTypeID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ContentTypeClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "contentTypeId": autorest.Encode("path", contentTypeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ContentTypeClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ContentTypeClient) CreateOrUpdateResponder(resp *http.Response) (result ContentTypeContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the specified developer portal's content type. Content types describe content items' properties, +// validation rules, and constraints. Built-in content types (with identifiers starting with the `c-` prefix) can't be +// removed. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// contentTypeID - content type 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. +func (client ContentTypeClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentTypeClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: contentTypeID, + Constraints: []validation.Constraint{{Target: "contentTypeID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentTypeID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ContentTypeClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, contentTypeID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ContentTypeClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "contentTypeId": autorest.Encode("path", contentTypeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ContentTypeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ContentTypeClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the developer portal's content type. Content types describe content items' properties, +// validation rules, and constraints. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// contentTypeID - content type identifier. +func (client ContentTypeClient) Get(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string) (result ContentTypeContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentTypeClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: contentTypeID, + Constraints: []validation.Constraint{{Target: "contentTypeID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "contentTypeID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ContentTypeClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, contentTypeID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ContentTypeClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "contentTypeId": autorest.Encode("path", contentTypeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ContentTypeClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ContentTypeClient) GetResponder(resp *http.Response) (result ContentTypeContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists the developer portal's content types. Content types describe content items' properties, +// validation rules, and constraints. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client ContentTypeClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result ContentTypeCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentTypeClient.ListByService") + defer func() { + sc := -1 + if result.ctc.Response.Response != nil { + sc = result.ctc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ContentTypeClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.ctc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "ListByService", resp, "Failure sending request") + return + } + + result.ctc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "ListByService", resp, "Failure responding to request") + return + } + if result.ctc.hasNextLink() && result.ctc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client ContentTypeClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client ContentTypeClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client ContentTypeClient) ListByServiceResponder(resp *http.Response) (result ContentTypeCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client ContentTypeClient) listByServiceNextResults(ctx context.Context, lastResults ContentTypeCollection) (result ContentTypeCollection, err error) { + req, err := lastResults.contentTypeCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ContentTypeClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ContentTypeClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string) (result ContentTypeCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentTypeClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/delegationsettings.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/delegationsettings.go new file mode 100644 index 000000000000..2af10e6f7640 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/delegationsettings.go @@ -0,0 +1,465 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DelegationSettingsClient is the apiManagement Client +type DelegationSettingsClient struct { + BaseClient +} + +// NewDelegationSettingsClient creates an instance of the DelegationSettingsClient client. +func NewDelegationSettingsClient(subscriptionID string) DelegationSettingsClient { + return NewDelegationSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDelegationSettingsClientWithBaseURI creates an instance of the DelegationSettingsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDelegationSettingsClientWithBaseURI(baseURI string, subscriptionID string) DelegationSettingsClient { + return DelegationSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or Update Delegation settings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - create or update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client DelegationSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalDelegationSettings, ifMatch string) (result PortalDelegationSettings, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegationSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DelegationSettingsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DelegationSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalDelegationSettings, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DelegationSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DelegationSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result PortalDelegationSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get Delegation Settings for the Portal. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client DelegationSettingsClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result PortalDelegationSettings, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegationSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DelegationSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DelegationSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DelegationSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DelegationSettingsClient) GetResponder(resp *http.Response) (result PortalDelegationSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the DelegationSettings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client DelegationSettingsClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegationSettingsClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DelegationSettingsClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client DelegationSettingsClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client DelegationSettingsClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client DelegationSettingsClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListSecrets gets the secret validation key of the DelegationSettings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client DelegationSettingsClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string) (result PortalSettingValidationKeyContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegationSettingsClient.ListSecrets") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DelegationSettingsClient", "ListSecrets", err.Error()) + } + + req, err := client.ListSecretsPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "ListSecrets", nil, "Failure preparing request") + return + } + + resp, err := client.ListSecretsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "ListSecrets", resp, "Failure sending request") + return + } + + result, err = client.ListSecretsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "ListSecrets", resp, "Failure responding to request") + return + } + + return +} + +// ListSecretsPreparer prepares the ListSecrets request. +func (client DelegationSettingsClient) ListSecretsPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSecretsSender sends the ListSecrets request. The method will close the +// http.Response Body if it receives an error. +func (client DelegationSettingsClient) ListSecretsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSecretsResponder handles the response to the ListSecrets request. The method always +// closes the http.Response Body. +func (client DelegationSettingsClient) ListSecretsResponder(resp *http.Response) (result PortalSettingValidationKeyContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update Delegation settings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - update Delegation settings. +// 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. +func (client DelegationSettingsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalDelegationSettings, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DelegationSettingsClient.Update") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DelegationSettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DelegationSettingsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DelegationSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalDelegationSettings, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DelegationSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DelegationSettingsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/deletedservices.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/deletedservices.go new file mode 100644 index 000000000000..f827a771e9ef --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/deletedservices.go @@ -0,0 +1,315 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DeletedServicesClient is the apiManagement Client +type DeletedServicesClient struct { + BaseClient +} + +// NewDeletedServicesClient creates an instance of the DeletedServicesClient client. +func NewDeletedServicesClient(subscriptionID string) DeletedServicesClient { + return NewDeletedServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDeletedServicesClientWithBaseURI creates an instance of the DeletedServicesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDeletedServicesClientWithBaseURI(baseURI string, subscriptionID string) DeletedServicesClient { + return DeletedServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByName get soft-deleted Api Management Service by name. +// Parameters: +// serviceName - the name of the API Management service. +// location - the location of the deleted API Management service. +func (client DeletedServicesClient) GetByName(ctx context.Context, serviceName string, location string) (result DeletedServiceContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServicesClient.GetByName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DeletedServicesClient", "GetByName", err.Error()) + } + + req, err := client.GetByNamePreparer(ctx, serviceName, location) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "GetByName", nil, "Failure preparing request") + return + } + + resp, err := client.GetByNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "GetByName", resp, "Failure sending request") + return + } + + result, err = client.GetByNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "GetByName", resp, "Failure responding to request") + return + } + + return +} + +// GetByNamePreparer prepares the GetByName request. +func (client DeletedServicesClient) GetByNamePreparer(ctx context.Context, serviceName string, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByNameSender sends the GetByName request. The method will close the +// http.Response Body if it receives an error. +func (client DeletedServicesClient) GetByNameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByNameResponder handles the response to the GetByName request. The method always +// closes the http.Response Body. +func (client DeletedServicesClient) GetByNameResponder(resp *http.Response) (result DeletedServiceContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription lists all soft-deleted services available for undelete for the given subscription. +func (client DeletedServicesClient) ListBySubscription(ctx context.Context) (result DeletedServicesCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServicesClient.ListBySubscription") + defer func() { + sc := -1 + if result.dsc.Response.Response != nil { + sc = result.dsc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.dsc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.dsc, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.dsc.hasNextLink() && result.dsc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client DeletedServicesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client DeletedServicesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client DeletedServicesClient) ListBySubscriptionResponder(resp *http.Response) (result DeletedServicesCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client DeletedServicesClient) listBySubscriptionNextResults(ctx context.Context, lastResults DeletedServicesCollection) (result DeletedServicesCollection, err error) { + req, err := lastResults.deletedServicesCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client DeletedServicesClient) ListBySubscriptionComplete(ctx context.Context) (result DeletedServicesCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServicesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Purge purges Api Management Service (deletes it with no option to undelete). +// Parameters: +// serviceName - the name of the API Management service. +// location - the location of the deleted API Management service. +func (client DeletedServicesClient) Purge(ctx context.Context, serviceName string, location string) (result DeletedServicesPurgeFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServicesClient.Purge") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DeletedServicesClient", "Purge", err.Error()) + } + + req, err := client.PurgePreparer(ctx, serviceName, location) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "Purge", nil, "Failure preparing request") + return + } + + result, err = client.PurgeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesClient", "Purge", nil, "Failure sending request") + return + } + + return +} + +// PurgePreparer prepares the Purge request. +func (client DeletedServicesClient) PurgePreparer(ctx context.Context, serviceName string, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PurgeSender sends the Purge request. The method will close the +// http.Response Body if it receives an error. +func (client DeletedServicesClient) PurgeSender(req *http.Request) (future DeletedServicesPurgeFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// PurgeResponder handles the response to the Purge request. The method always +// closes the http.Response Body. +func (client DeletedServicesClient) PurgeResponder(resp *http.Response) (result DeletedServiceContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/diagnostic.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/diagnostic.go new file mode 100644 index 000000000000..31e571f74f10 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/diagnostic.go @@ -0,0 +1,681 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DiagnosticClient is the apiManagement Client +type DiagnosticClient struct { + BaseClient +} + +// NewDiagnosticClient creates an instance of the DiagnosticClient client. +func NewDiagnosticClient(subscriptionID string) DiagnosticClient { + return NewDiagnosticClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDiagnosticClientWithBaseURI creates an instance of the DiagnosticClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDiagnosticClientWithBaseURI(baseURI string, subscriptionID string) DiagnosticClient { + return DiagnosticClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Diagnostic or updates an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// diagnosticID - diagnostic identifier. Must be unique in the current API Management service instance. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client DiagnosticClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, parameters DiagnosticContract, ifMatch string) (result DiagnosticContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.LoggerID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DiagnosticContractProperties.Sampling", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Sampling.Percentage", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Sampling.Percentage", Name: validation.InclusiveMaximum, Rule: float64(100), Chain: nil}, + {Target: "parameters.DiagnosticContractProperties.Sampling.Percentage", Name: validation.InclusiveMinimum, Rule: float64(0), Chain: nil}, + }}, + }}, + {Target: "parameters.DiagnosticContractProperties.Frontend", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Request", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Request.Body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Request.Body.Bytes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Request.Body.Bytes", Name: validation.InclusiveMaximum, Rule: int64(8192), Chain: nil}}}, + }}, + }}, + {Target: "parameters.DiagnosticContractProperties.Frontend.Response", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Response.Body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Response.Body.Bytes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Frontend.Response.Body.Bytes", Name: validation.InclusiveMaximum, Rule: int64(8192), Chain: nil}}}, + }}, + }}, + }}, + {Target: "parameters.DiagnosticContractProperties.Backend", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Request", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Request.Body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Request.Body.Bytes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Request.Body.Bytes", Name: validation.InclusiveMaximum, Rule: int64(8192), Chain: nil}}}, + }}, + }}, + {Target: "parameters.DiagnosticContractProperties.Backend.Response", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Response.Body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Response.Body.Bytes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DiagnosticContractProperties.Backend.Response.Body.Bytes", Name: validation.InclusiveMaximum, Rule: int64(8192), Chain: nil}}}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.DiagnosticClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, diagnosticID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DiagnosticClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, parameters DiagnosticContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DiagnosticClient) CreateOrUpdateResponder(resp *http.Response) (result DiagnosticContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified Diagnostic. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client DiagnosticClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DiagnosticClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, diagnosticID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DiagnosticClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DiagnosticClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the Diagnostic specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// diagnosticID - diagnostic identifier. Must be unique in the current API Management service instance. +func (client DiagnosticClient) Get(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string) (result DiagnosticContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DiagnosticClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, diagnosticID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DiagnosticClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DiagnosticClient) GetResponder(resp *http.Response) (result DiagnosticContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the Diagnostic specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// diagnosticID - diagnostic identifier. Must be unique in the current API Management service instance. +func (client DiagnosticClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DiagnosticClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, diagnosticID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client DiagnosticClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client DiagnosticClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists all diagnostics of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client DiagnosticClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result DiagnosticCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticClient.ListByService") + defer func() { + sc := -1 + if result.dc.Response.Response != nil { + sc = result.dc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.DiagnosticClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.dc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "ListByService", resp, "Failure sending request") + return + } + + result.dc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "ListByService", resp, "Failure responding to request") + return + } + if result.dc.hasNextLink() && result.dc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client DiagnosticClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client DiagnosticClient) ListByServiceResponder(resp *http.Response) (result DiagnosticCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client DiagnosticClient) listByServiceNextResults(ctx context.Context, lastResults DiagnosticCollection) (result DiagnosticCollection, err error) { + req, err := lastResults.diagnosticCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client DiagnosticClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result DiagnosticCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// Update updates the details of the Diagnostic specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// diagnosticID - diagnostic identifier. Must be unique in the current API Management service instance. +// parameters - diagnostic Update parameters. +// 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. +func (client DiagnosticClient) Update(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, parameters DiagnosticContract, ifMatch string) (result DiagnosticContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: diagnosticID, + Constraints: []validation.Constraint{{Target: "diagnosticID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "diagnosticID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "diagnosticID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.DiagnosticClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, diagnosticID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DiagnosticClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DiagnosticClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, parameters DiagnosticContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "diagnosticId": autorest.Encode("path", diagnosticID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DiagnosticClient) UpdateResponder(resp *http.Response) (result DiagnosticContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/emailtemplate.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/emailtemplate.go new file mode 100644 index 000000000000..22576929ab3c --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/emailtemplate.go @@ -0,0 +1,632 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// EmailTemplateClient is the apiManagement Client +type EmailTemplateClient struct { + BaseClient +} + +// NewEmailTemplateClient creates an instance of the EmailTemplateClient client. +func NewEmailTemplateClient(subscriptionID string) EmailTemplateClient { + return NewEmailTemplateClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEmailTemplateClientWithBaseURI creates an instance of the EmailTemplateClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewEmailTemplateClientWithBaseURI(baseURI string, subscriptionID string) EmailTemplateClient { + return EmailTemplateClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates an Email Template. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// templateName - email Template Name Identifier. +// parameters - email Template update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client EmailTemplateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, parameters EmailTemplateUpdateParameters, ifMatch string) (result EmailTemplateContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EmailTemplateClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.EmailTemplateUpdateParameterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.EmailTemplateUpdateParameterProperties.Subject", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.EmailTemplateUpdateParameterProperties.Subject", Name: validation.MaxLength, Rule: 1000, Chain: nil}, + {Target: "parameters.EmailTemplateUpdateParameterProperties.Subject", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + {Target: "parameters.EmailTemplateUpdateParameterProperties.Body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.EmailTemplateUpdateParameterProperties.Body", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.EmailTemplateClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, templateName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client EmailTemplateClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, parameters EmailTemplateUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "templateName": autorest.Encode("path", templateName), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client EmailTemplateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client EmailTemplateClient) CreateOrUpdateResponder(resp *http.Response) (result EmailTemplateContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete reset the Email Template to default template provided by the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// templateName - email Template Name 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. +func (client EmailTemplateClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EmailTemplateClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.EmailTemplateClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, templateName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client EmailTemplateClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "templateName": autorest.Encode("path", templateName), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client EmailTemplateClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client EmailTemplateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the email template specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// templateName - email Template Name Identifier. +func (client EmailTemplateClient) Get(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName) (result EmailTemplateContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EmailTemplateClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.EmailTemplateClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, templateName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client EmailTemplateClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "templateName": autorest.Encode("path", templateName), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client EmailTemplateClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client EmailTemplateClient) GetResponder(resp *http.Response) (result EmailTemplateContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the email template specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// templateName - email Template Name Identifier. +func (client EmailTemplateClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EmailTemplateClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.EmailTemplateClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, templateName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client EmailTemplateClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "templateName": autorest.Encode("path", templateName), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client EmailTemplateClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client EmailTemplateClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService gets all email templates +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client EmailTemplateClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result EmailTemplateCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EmailTemplateClient.ListByService") + defer func() { + sc := -1 + if result.etc.Response.Response != nil { + sc = result.etc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.EmailTemplateClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.etc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "ListByService", resp, "Failure sending request") + return + } + + result.etc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "ListByService", resp, "Failure responding to request") + return + } + if result.etc.hasNextLink() && result.etc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client EmailTemplateClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client EmailTemplateClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client EmailTemplateClient) ListByServiceResponder(resp *http.Response) (result EmailTemplateCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client EmailTemplateClient) listByServiceNextResults(ctx context.Context, lastResults EmailTemplateCollection) (result EmailTemplateCollection, err error) { + req, err := lastResults.emailTemplateCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client EmailTemplateClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result EmailTemplateCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EmailTemplateClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// Update updates API Management email template +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// templateName - email Template Name 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. +// parameters - update parameters. +func (client EmailTemplateClient) Update(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, parameters EmailTemplateUpdateParameters) (result EmailTemplateContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EmailTemplateClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.EmailTemplateClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, templateName, ifMatch, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.EmailTemplateClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client EmailTemplateClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, parameters EmailTemplateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "templateName": autorest.Encode("path", templateName), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client EmailTemplateClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client EmailTemplateClient) UpdateResponder(resp *http.Response) (result EmailTemplateContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/enums.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/enums.go new file mode 100644 index 000000000000..7dabec348a02 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/enums.go @@ -0,0 +1,983 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +// AccessIDName enumerates the values for access id name. +type AccessIDName string + +const ( + // AccessIDNameAccess ... + AccessIDNameAccess AccessIDName = "access" + // AccessIDNameGitAccess ... + AccessIDNameGitAccess AccessIDName = "gitAccess" +) + +// PossibleAccessIDNameValues returns an array of possible values for the AccessIDName const type. +func PossibleAccessIDNameValues() []AccessIDName { + return []AccessIDName{AccessIDNameAccess, AccessIDNameGitAccess} +} + +// AlwaysLog enumerates the values for always log. +type AlwaysLog string + +const ( + // AlwaysLogAllErrors Always log all erroneous request regardless of sampling settings. + AlwaysLogAllErrors AlwaysLog = "allErrors" +) + +// PossibleAlwaysLogValues returns an array of possible values for the AlwaysLog const type. +func PossibleAlwaysLogValues() []AlwaysLog { + return []AlwaysLog{AlwaysLogAllErrors} +} + +// ApimIdentityType enumerates the values for apim identity type. +type ApimIdentityType string + +const ( + // ApimIdentityTypeNone ... + ApimIdentityTypeNone ApimIdentityType = "None" + // ApimIdentityTypeSystemAssigned ... + ApimIdentityTypeSystemAssigned ApimIdentityType = "SystemAssigned" + // ApimIdentityTypeSystemAssignedUserAssigned ... + ApimIdentityTypeSystemAssignedUserAssigned ApimIdentityType = "SystemAssigned, UserAssigned" + // ApimIdentityTypeUserAssigned ... + ApimIdentityTypeUserAssigned ApimIdentityType = "UserAssigned" +) + +// PossibleApimIdentityTypeValues returns an array of possible values for the ApimIdentityType const type. +func PossibleApimIdentityTypeValues() []ApimIdentityType { + return []ApimIdentityType{ApimIdentityTypeNone, ApimIdentityTypeSystemAssigned, ApimIdentityTypeSystemAssignedUserAssigned, ApimIdentityTypeUserAssigned} +} + +// APIType enumerates the values for api type. +type APIType string + +const ( + // APITypeHTTP ... + APITypeHTTP APIType = "http" + // APITypeSoap ... + APITypeSoap APIType = "soap" + // APITypeWebsocket ... + APITypeWebsocket APIType = "websocket" +) + +// PossibleAPITypeValues returns an array of possible values for the APIType const type. +func PossibleAPITypeValues() []APIType { + return []APIType{APITypeHTTP, APITypeSoap, APITypeWebsocket} +} + +// AppType enumerates the values for app type. +type AppType string + +const ( + // AppTypeDeveloperPortal User create request was sent by new developer portal. + AppTypeDeveloperPortal AppType = "developerPortal" + // AppTypePortal User create request was sent by legacy developer portal. + AppTypePortal AppType = "portal" +) + +// PossibleAppTypeValues returns an array of possible values for the AppType const type. +func PossibleAppTypeValues() []AppType { + return []AppType{AppTypeDeveloperPortal, AppTypePortal} +} + +// AsyncOperationStatus enumerates the values for async operation status. +type AsyncOperationStatus string + +const ( + // AsyncOperationStatusFailed ... + AsyncOperationStatusFailed AsyncOperationStatus = "Failed" + // AsyncOperationStatusInProgress ... + AsyncOperationStatusInProgress AsyncOperationStatus = "InProgress" + // AsyncOperationStatusStarted ... + AsyncOperationStatusStarted AsyncOperationStatus = "Started" + // AsyncOperationStatusSucceeded ... + AsyncOperationStatusSucceeded AsyncOperationStatus = "Succeeded" +) + +// PossibleAsyncOperationStatusValues returns an array of possible values for the AsyncOperationStatus const type. +func PossibleAsyncOperationStatusValues() []AsyncOperationStatus { + return []AsyncOperationStatus{AsyncOperationStatusFailed, AsyncOperationStatusInProgress, AsyncOperationStatusStarted, AsyncOperationStatusSucceeded} +} + +// AuthorizationMethod enumerates the values for authorization method. +type AuthorizationMethod string + +const ( + // AuthorizationMethodDELETE ... + AuthorizationMethodDELETE AuthorizationMethod = "DELETE" + // AuthorizationMethodGET ... + AuthorizationMethodGET AuthorizationMethod = "GET" + // AuthorizationMethodHEAD ... + AuthorizationMethodHEAD AuthorizationMethod = "HEAD" + // AuthorizationMethodOPTIONS ... + AuthorizationMethodOPTIONS AuthorizationMethod = "OPTIONS" + // AuthorizationMethodPATCH ... + AuthorizationMethodPATCH AuthorizationMethod = "PATCH" + // AuthorizationMethodPOST ... + AuthorizationMethodPOST AuthorizationMethod = "POST" + // AuthorizationMethodPUT ... + AuthorizationMethodPUT AuthorizationMethod = "PUT" + // AuthorizationMethodTRACE ... + AuthorizationMethodTRACE AuthorizationMethod = "TRACE" +) + +// PossibleAuthorizationMethodValues returns an array of possible values for the AuthorizationMethod const type. +func PossibleAuthorizationMethodValues() []AuthorizationMethod { + return []AuthorizationMethod{AuthorizationMethodDELETE, AuthorizationMethodGET, AuthorizationMethodHEAD, AuthorizationMethodOPTIONS, AuthorizationMethodPATCH, AuthorizationMethodPOST, AuthorizationMethodPUT, AuthorizationMethodTRACE} +} + +// BackendProtocol enumerates the values for backend protocol. +type BackendProtocol string + +const ( + // BackendProtocolHTTP The Backend is a RESTful service. + BackendProtocolHTTP BackendProtocol = "http" + // BackendProtocolSoap The Backend is a SOAP service. + BackendProtocolSoap BackendProtocol = "soap" +) + +// PossibleBackendProtocolValues returns an array of possible values for the BackendProtocol const type. +func PossibleBackendProtocolValues() []BackendProtocol { + return []BackendProtocol{BackendProtocolHTTP, BackendProtocolSoap} +} + +// BearerTokenSendingMethod enumerates the values for bearer token sending method. +type BearerTokenSendingMethod string + +const ( + // BearerTokenSendingMethodAuthorizationHeader ... + BearerTokenSendingMethodAuthorizationHeader BearerTokenSendingMethod = "authorizationHeader" + // BearerTokenSendingMethodQuery ... + BearerTokenSendingMethodQuery BearerTokenSendingMethod = "query" +) + +// PossibleBearerTokenSendingMethodValues returns an array of possible values for the BearerTokenSendingMethod const type. +func PossibleBearerTokenSendingMethodValues() []BearerTokenSendingMethod { + return []BearerTokenSendingMethod{BearerTokenSendingMethodAuthorizationHeader, BearerTokenSendingMethodQuery} +} + +// BearerTokenSendingMethods enumerates the values for bearer token sending methods. +type BearerTokenSendingMethods string + +const ( + // BearerTokenSendingMethodsAuthorizationHeader Access token will be transmitted in the Authorization + // header using Bearer schema + BearerTokenSendingMethodsAuthorizationHeader BearerTokenSendingMethods = "authorizationHeader" + // BearerTokenSendingMethodsQuery Access token will be transmitted as query parameters. + BearerTokenSendingMethodsQuery BearerTokenSendingMethods = "query" +) + +// PossibleBearerTokenSendingMethodsValues returns an array of possible values for the BearerTokenSendingMethods const type. +func PossibleBearerTokenSendingMethodsValues() []BearerTokenSendingMethods { + return []BearerTokenSendingMethods{BearerTokenSendingMethodsAuthorizationHeader, BearerTokenSendingMethodsQuery} +} + +// CertificateSource enumerates the values for certificate source. +type CertificateSource string + +const ( + // CertificateSourceBuiltIn ... + CertificateSourceBuiltIn CertificateSource = "BuiltIn" + // CertificateSourceCustom ... + CertificateSourceCustom CertificateSource = "Custom" + // CertificateSourceKeyVault ... + CertificateSourceKeyVault CertificateSource = "KeyVault" + // CertificateSourceManaged ... + CertificateSourceManaged CertificateSource = "Managed" +) + +// PossibleCertificateSourceValues returns an array of possible values for the CertificateSource const type. +func PossibleCertificateSourceValues() []CertificateSource { + return []CertificateSource{CertificateSourceBuiltIn, CertificateSourceCustom, CertificateSourceKeyVault, CertificateSourceManaged} +} + +// CertificateStatus enumerates the values for certificate status. +type CertificateStatus string + +const ( + // CertificateStatusCompleted ... + CertificateStatusCompleted CertificateStatus = "Completed" + // CertificateStatusFailed ... + CertificateStatusFailed CertificateStatus = "Failed" + // CertificateStatusInProgress ... + CertificateStatusInProgress CertificateStatus = "InProgress" +) + +// PossibleCertificateStatusValues returns an array of possible values for the CertificateStatus const type. +func PossibleCertificateStatusValues() []CertificateStatus { + return []CertificateStatus{CertificateStatusCompleted, CertificateStatusFailed, CertificateStatusInProgress} +} + +// ClientAuthenticationMethod enumerates the values for client authentication method. +type ClientAuthenticationMethod string + +const ( + // ClientAuthenticationMethodBasic Basic Client Authentication method. + ClientAuthenticationMethodBasic ClientAuthenticationMethod = "Basic" + // ClientAuthenticationMethodBody Body based Authentication method. + ClientAuthenticationMethodBody ClientAuthenticationMethod = "Body" +) + +// PossibleClientAuthenticationMethodValues returns an array of possible values for the ClientAuthenticationMethod const type. +func PossibleClientAuthenticationMethodValues() []ClientAuthenticationMethod { + return []ClientAuthenticationMethod{ClientAuthenticationMethodBasic, ClientAuthenticationMethodBody} +} + +// Confirmation enumerates the values for confirmation. +type Confirmation string + +const ( + // ConfirmationInvite Send an e-mail inviting the user to sign-up and complete registration. + ConfirmationInvite Confirmation = "invite" + // ConfirmationSignup Send an e-mail to the user confirming they have successfully signed up. + ConfirmationSignup Confirmation = "signup" +) + +// PossibleConfirmationValues returns an array of possible values for the Confirmation const type. +func PossibleConfirmationValues() []Confirmation { + return []Confirmation{ConfirmationInvite, ConfirmationSignup} +} + +// ConnectivityStatusType enumerates the values for connectivity status type. +type ConnectivityStatusType string + +const ( + // ConnectivityStatusTypeFailure ... + ConnectivityStatusTypeFailure ConnectivityStatusType = "failure" + // ConnectivityStatusTypeInitializing ... + ConnectivityStatusTypeInitializing ConnectivityStatusType = "initializing" + // ConnectivityStatusTypeSuccess ... + ConnectivityStatusTypeSuccess ConnectivityStatusType = "success" +) + +// PossibleConnectivityStatusTypeValues returns an array of possible values for the ConnectivityStatusType const type. +func PossibleConnectivityStatusTypeValues() []ConnectivityStatusType { + return []ConnectivityStatusType{ConnectivityStatusTypeFailure, ConnectivityStatusTypeInitializing, ConnectivityStatusTypeSuccess} +} + +// ContentFormat enumerates the values for content format. +type ContentFormat string + +const ( + // 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. + ContentFormatOpenapijson ContentFormat = "openapi+json" + // ContentFormatOpenapijsonLink The OpenAPI 3.0 JSON document is hosted on a publicly accessible internet + // address. + ContentFormatOpenapijsonLink ContentFormat = "openapi+json-link" + // ContentFormatOpenapiLink The OpenAPI 3.0 YAML document is hosted on a publicly accessible internet + // address. + ContentFormatOpenapiLink ContentFormat = "openapi-link" + // ContentFormatSwaggerJSON The contents are inline and Content Type is a OpenAPI 2.0 JSON Document. + ContentFormatSwaggerJSON ContentFormat = "swagger-json" + // ContentFormatSwaggerLinkJSON The OpenAPI 2.0 JSON document is hosted on a publicly accessible internet + // address. + ContentFormatSwaggerLinkJSON ContentFormat = "swagger-link-json" + // ContentFormatWadlLinkJSON The WADL document is hosted on a publicly accessible internet address. + ContentFormatWadlLinkJSON ContentFormat = "wadl-link-json" + // ContentFormatWadlXML The contents are inline and Content type is a WADL document. + ContentFormatWadlXML ContentFormat = "wadl-xml" + // ContentFormatWsdl The contents are inline and the document is a WSDL/Soap document. + ContentFormatWsdl ContentFormat = "wsdl" + // ContentFormatWsdlLink The WSDL document is hosted on a publicly accessible internet address. + ContentFormatWsdlLink ContentFormat = "wsdl-link" +) + +// PossibleContentFormatValues returns an array of possible values for the ContentFormat const type. +func PossibleContentFormatValues() []ContentFormat { + return []ContentFormat{ContentFormatOpenapi, ContentFormatOpenapijson, ContentFormatOpenapijsonLink, ContentFormatOpenapiLink, ContentFormatSwaggerJSON, ContentFormatSwaggerLinkJSON, ContentFormatWadlLinkJSON, ContentFormatWadlXML, ContentFormatWsdl, ContentFormatWsdlLink} +} + +// DataMaskingMode enumerates the values for data masking mode. +type DataMaskingMode string + +const ( + // DataMaskingModeHide Hide the presence of an entity. + DataMaskingModeHide DataMaskingMode = "Hide" + // DataMaskingModeMask Mask the value of an entity. + DataMaskingModeMask DataMaskingMode = "Mask" +) + +// PossibleDataMaskingModeValues returns an array of possible values for the DataMaskingMode const type. +func PossibleDataMaskingModeValues() []DataMaskingMode { + return []DataMaskingMode{DataMaskingModeHide, DataMaskingModeMask} +} + +// ExportFormat enumerates the values for export format. +type ExportFormat string + +const ( + // ExportFormatOpenapi Export the Api Definition in OpenAPI 3.0 Specification as YAML document to Storage + // Blob. + ExportFormatOpenapi ExportFormat = "openapi-link" + // ExportFormatOpenapiJSON Export the Api Definition in OpenAPI 3.0 Specification as JSON document to + // Storage Blob. + ExportFormatOpenapiJSON ExportFormat = "openapi+json-link" + // ExportFormatSwagger Export the Api Definition in OpenAPI 2.0 Specification as JSON document to the + // Storage Blob. + ExportFormatSwagger ExportFormat = "swagger-link" + // ExportFormatWadl Export the Api Definition in WADL Schema to Storage Blob. + ExportFormatWadl ExportFormat = "wadl-link" + // ExportFormatWsdl Export the Api Definition in WSDL Schema to Storage Blob. This is only supported for + // APIs of Type `soap` + ExportFormatWsdl ExportFormat = "wsdl-link" +) + +// PossibleExportFormatValues returns an array of possible values for the ExportFormat const type. +func PossibleExportFormatValues() []ExportFormat { + return []ExportFormat{ExportFormatOpenapi, ExportFormatOpenapiJSON, ExportFormatSwagger, ExportFormatWadl, ExportFormatWsdl} +} + +// ExportResultFormat enumerates the values for export result format. +type ExportResultFormat string + +const ( + // ExportResultFormatOpenAPI Export the API Definition in OpenAPI Specification 3.0 to Storage Blob. + ExportResultFormatOpenAPI ExportResultFormat = "openapi-link" + // ExportResultFormatSwagger The API Definition is exported in OpenAPI Specification 2.0 format to the + // Storage Blob. + ExportResultFormatSwagger ExportResultFormat = "swagger-link-json" + // ExportResultFormatWadl Export the API Definition in WADL Schema to Storage Blob. + ExportResultFormatWadl ExportResultFormat = "wadl-link-json" + // ExportResultFormatWsdl The API Definition is exported in WSDL Schema to Storage Blob. This is only + // supported for APIs of Type `soap` + ExportResultFormatWsdl ExportResultFormat = "wsdl-link+xml" +) + +// PossibleExportResultFormatValues returns an array of possible values for the ExportResultFormat const type. +func PossibleExportResultFormatValues() []ExportResultFormat { + return []ExportResultFormat{ExportResultFormatOpenAPI, ExportResultFormatSwagger, ExportResultFormatWadl, ExportResultFormatWsdl} +} + +// GrantType enumerates the values for grant type. +type GrantType string + +const ( + // GrantTypeAuthorizationCode Authorization Code Grant flow as described + // https://tools.ietf.org/html/rfc6749#section-4.1. + GrantTypeAuthorizationCode GrantType = "authorizationCode" + // GrantTypeClientCredentials Client Credentials Grant flow as described + // https://tools.ietf.org/html/rfc6749#section-4.4. + GrantTypeClientCredentials GrantType = "clientCredentials" + // GrantTypeImplicit Implicit Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.2. + GrantTypeImplicit GrantType = "implicit" + // GrantTypeResourceOwnerPassword Resource Owner Password Grant flow as described + // https://tools.ietf.org/html/rfc6749#section-4.3. + GrantTypeResourceOwnerPassword GrantType = "resourceOwnerPassword" +) + +// PossibleGrantTypeValues returns an array of possible values for the GrantType const type. +func PossibleGrantTypeValues() []GrantType { + return []GrantType{GrantTypeAuthorizationCode, GrantTypeClientCredentials, GrantTypeImplicit, GrantTypeResourceOwnerPassword} +} + +// GroupType enumerates the values for group type. +type GroupType string + +const ( + // GroupTypeCustom ... + GroupTypeCustom GroupType = "custom" + // GroupTypeExternal ... + GroupTypeExternal GroupType = "external" + // GroupTypeSystem ... + GroupTypeSystem GroupType = "system" +) + +// PossibleGroupTypeValues returns an array of possible values for the GroupType const type. +func PossibleGroupTypeValues() []GroupType { + return []GroupType{GroupTypeCustom, GroupTypeExternal, GroupTypeSystem} +} + +// HostnameType enumerates the values for hostname type. +type HostnameType string + +const ( + // HostnameTypeDeveloperPortal ... + HostnameTypeDeveloperPortal HostnameType = "DeveloperPortal" + // HostnameTypeManagement ... + HostnameTypeManagement HostnameType = "Management" + // HostnameTypePortal ... + HostnameTypePortal HostnameType = "Portal" + // HostnameTypeProxy ... + HostnameTypeProxy HostnameType = "Proxy" + // HostnameTypeScm ... + HostnameTypeScm HostnameType = "Scm" +) + +// PossibleHostnameTypeValues returns an array of possible values for the HostnameType const type. +func PossibleHostnameTypeValues() []HostnameType { + return []HostnameType{HostnameTypeDeveloperPortal, HostnameTypeManagement, HostnameTypePortal, HostnameTypeProxy, HostnameTypeScm} +} + +// HTTPCorrelationProtocol enumerates the values for http correlation protocol. +type HTTPCorrelationProtocol string + +const ( + // HTTPCorrelationProtocolLegacy Inject Request-Id and Request-Context headers with request correlation + // data. See + // https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md. + HTTPCorrelationProtocolLegacy HTTPCorrelationProtocol = "Legacy" + // HTTPCorrelationProtocolNone Do not read and inject correlation headers. + HTTPCorrelationProtocolNone HTTPCorrelationProtocol = "None" + // HTTPCorrelationProtocolW3C Inject Trace Context headers. See https://w3c.github.io/trace-context. + HTTPCorrelationProtocolW3C HTTPCorrelationProtocol = "W3C" +) + +// PossibleHTTPCorrelationProtocolValues returns an array of possible values for the HTTPCorrelationProtocol const type. +func PossibleHTTPCorrelationProtocolValues() []HTTPCorrelationProtocol { + return []HTTPCorrelationProtocol{HTTPCorrelationProtocolLegacy, HTTPCorrelationProtocolNone, HTTPCorrelationProtocolW3C} +} + +// IdentityProviderType enumerates the values for identity provider type. +type IdentityProviderType string + +const ( + // IdentityProviderTypeAad Azure Active Directory as Identity provider. + IdentityProviderTypeAad IdentityProviderType = "aad" + // IdentityProviderTypeAadB2C Azure Active Directory B2C as Identity provider. + IdentityProviderTypeAadB2C IdentityProviderType = "aadB2C" + // IdentityProviderTypeFacebook Facebook as Identity provider. + IdentityProviderTypeFacebook IdentityProviderType = "facebook" + // IdentityProviderTypeGoogle Google as Identity provider. + IdentityProviderTypeGoogle IdentityProviderType = "google" + // IdentityProviderTypeMicrosoft Microsoft Live as Identity provider. + IdentityProviderTypeMicrosoft IdentityProviderType = "microsoft" + // IdentityProviderTypeTwitter Twitter as Identity provider. + IdentityProviderTypeTwitter IdentityProviderType = "twitter" +) + +// PossibleIdentityProviderTypeValues returns an array of possible values for the IdentityProviderType const type. +func PossibleIdentityProviderTypeValues() []IdentityProviderType { + return []IdentityProviderType{IdentityProviderTypeAad, IdentityProviderTypeAadB2C, IdentityProviderTypeFacebook, IdentityProviderTypeGoogle, IdentityProviderTypeMicrosoft, IdentityProviderTypeTwitter} +} + +// KeyType enumerates the values for key type. +type KeyType string + +const ( + // KeyTypePrimary ... + KeyTypePrimary KeyType = "primary" + // KeyTypeSecondary ... + KeyTypeSecondary KeyType = "secondary" +) + +// PossibleKeyTypeValues returns an array of possible values for the KeyType const type. +func PossibleKeyTypeValues() []KeyType { + return []KeyType{KeyTypePrimary, KeyTypeSecondary} +} + +// LoggerType enumerates the values for logger type. +type LoggerType string + +const ( + // LoggerTypeApplicationInsights Azure Application Insights as log destination. + LoggerTypeApplicationInsights LoggerType = "applicationInsights" + // LoggerTypeAzureEventHub Azure Event Hub as log destination. + LoggerTypeAzureEventHub LoggerType = "azureEventHub" + // LoggerTypeAzureMonitor Azure Monitor + LoggerTypeAzureMonitor LoggerType = "azureMonitor" +) + +// PossibleLoggerTypeValues returns an array of possible values for the LoggerType const type. +func PossibleLoggerTypeValues() []LoggerType { + return []LoggerType{LoggerTypeApplicationInsights, LoggerTypeAzureEventHub, LoggerTypeAzureMonitor} +} + +// NameAvailabilityReason enumerates the values for name availability reason. +type NameAvailabilityReason string + +const ( + // NameAvailabilityReasonAlreadyExists ... + NameAvailabilityReasonAlreadyExists NameAvailabilityReason = "AlreadyExists" + // NameAvailabilityReasonInvalid ... + NameAvailabilityReasonInvalid NameAvailabilityReason = "Invalid" + // NameAvailabilityReasonValid ... + NameAvailabilityReasonValid NameAvailabilityReason = "Valid" +) + +// PossibleNameAvailabilityReasonValues returns an array of possible values for the NameAvailabilityReason const type. +func PossibleNameAvailabilityReasonValues() []NameAvailabilityReason { + return []NameAvailabilityReason{NameAvailabilityReasonAlreadyExists, NameAvailabilityReasonInvalid, NameAvailabilityReasonValid} +} + +// NotificationName enumerates the values for notification name. +type NotificationName string + +const ( + // NotificationNameAccountClosedPublisher The following email recipients and users will receive email + // notifications when developer closes his account. + NotificationNameAccountClosedPublisher NotificationName = "AccountClosedPublisher" + // NotificationNameBCC The following recipients will receive blind carbon copies of all emails sent to + // developers. + NotificationNameBCC NotificationName = "BCC" + // NotificationNameNewApplicationNotificationMessage The following email recipients and users will receive + // email notifications when new applications are submitted to the application gallery. + NotificationNameNewApplicationNotificationMessage NotificationName = "NewApplicationNotificationMessage" + // NotificationNameNewIssuePublisherNotificationMessage The following email recipients and users will + // receive email notifications when a new issue or comment is submitted on the developer portal. + NotificationNameNewIssuePublisherNotificationMessage NotificationName = "NewIssuePublisherNotificationMessage" + // NotificationNamePurchasePublisherNotificationMessage The following email recipients and users will + // receive email notifications about new API product subscriptions. + NotificationNamePurchasePublisherNotificationMessage NotificationName = "PurchasePublisherNotificationMessage" + // NotificationNameQuotaLimitApproachingPublisherNotificationMessage The following email recipients and + // users will receive email notifications when subscription usage gets close to usage quota. + NotificationNameQuotaLimitApproachingPublisherNotificationMessage NotificationName = "QuotaLimitApproachingPublisherNotificationMessage" + // NotificationNameRequestPublisherNotificationMessage The following email recipients and users will + // receive email notifications about subscription requests for API products requiring approval. + NotificationNameRequestPublisherNotificationMessage NotificationName = "RequestPublisherNotificationMessage" +) + +// PossibleNotificationNameValues returns an array of possible values for the NotificationName const type. +func PossibleNotificationNameValues() []NotificationName { + return []NotificationName{NotificationNameAccountClosedPublisher, NotificationNameBCC, NotificationNameNewApplicationNotificationMessage, NotificationNameNewIssuePublisherNotificationMessage, NotificationNamePurchasePublisherNotificationMessage, NotificationNameQuotaLimitApproachingPublisherNotificationMessage, NotificationNameRequestPublisherNotificationMessage} +} + +// OperationNameFormat enumerates the values for operation name format. +type OperationNameFormat string + +const ( + // OperationNameFormatName API_NAME;rev=API_REVISION - OPERATION_NAME + OperationNameFormatName OperationNameFormat = "Name" + // OperationNameFormatURL HTTP_VERB URL + OperationNameFormatURL OperationNameFormat = "Url" +) + +// PossibleOperationNameFormatValues returns an array of possible values for the OperationNameFormat const type. +func PossibleOperationNameFormatValues() []OperationNameFormat { + return []OperationNameFormat{OperationNameFormatName, OperationNameFormatURL} +} + +// PolicyContentFormat enumerates the values for policy content format. +type PolicyContentFormat string + +const ( + // PolicyContentFormatRawxml The contents are inline and Content type is a non XML encoded policy document. + PolicyContentFormatRawxml PolicyContentFormat = "rawxml" + // PolicyContentFormatRawxmlLink The policy document is not Xml encoded and is hosted on a http endpoint + // accessible from the API Management service. + PolicyContentFormatRawxmlLink PolicyContentFormat = "rawxml-link" + // PolicyContentFormatXML The contents are inline and Content type is an XML document. + PolicyContentFormatXML PolicyContentFormat = "xml" + // PolicyContentFormatXMLLink The policy XML document is hosted on a http endpoint accessible from the API + // Management service. + PolicyContentFormatXMLLink PolicyContentFormat = "xml-link" +) + +// PossiblePolicyContentFormatValues returns an array of possible values for the PolicyContentFormat const type. +func PossiblePolicyContentFormatValues() []PolicyContentFormat { + return []PolicyContentFormat{PolicyContentFormatRawxml, PolicyContentFormatRawxmlLink, PolicyContentFormatXML, PolicyContentFormatXMLLink} +} + +// PolicyExportFormat enumerates the values for policy export format. +type PolicyExportFormat string + +const ( + // PolicyExportFormatRawxml The contents are inline and Content type is a non XML encoded policy document. + PolicyExportFormatRawxml PolicyExportFormat = "rawxml" + // PolicyExportFormatXML The contents are inline and Content type is an XML document. + PolicyExportFormatXML PolicyExportFormat = "xml" +) + +// PossiblePolicyExportFormatValues returns an array of possible values for the PolicyExportFormat const type. +func PossiblePolicyExportFormatValues() []PolicyExportFormat { + return []PolicyExportFormat{PolicyExportFormatRawxml, PolicyExportFormatXML} +} + +// PolicyScopeContract enumerates the values for policy scope contract. +type PolicyScopeContract string + +const ( + // PolicyScopeContractAll ... + PolicyScopeContractAll PolicyScopeContract = "All" + // PolicyScopeContractAPI ... + PolicyScopeContractAPI PolicyScopeContract = "Api" + // PolicyScopeContractOperation ... + PolicyScopeContractOperation PolicyScopeContract = "Operation" + // PolicyScopeContractProduct ... + PolicyScopeContractProduct PolicyScopeContract = "Product" + // PolicyScopeContractTenant ... + PolicyScopeContractTenant PolicyScopeContract = "Tenant" +) + +// PossiblePolicyScopeContractValues returns an array of possible values for the PolicyScopeContract const type. +func PossiblePolicyScopeContractValues() []PolicyScopeContract { + return []PolicyScopeContract{PolicyScopeContractAll, PolicyScopeContractAPI, PolicyScopeContractOperation, PolicyScopeContractProduct, PolicyScopeContractTenant} +} + +// PortalRevisionStatus enumerates the values for portal revision status. +type PortalRevisionStatus string + +const ( + // PortalRevisionStatusCompleted Portal's revision publishing completed. + PortalRevisionStatusCompleted PortalRevisionStatus = "completed" + // PortalRevisionStatusFailed Portal's revision publishing failed. + PortalRevisionStatusFailed PortalRevisionStatus = "failed" + // PortalRevisionStatusPending Portal's revision has been queued. + PortalRevisionStatusPending PortalRevisionStatus = "pending" + // PortalRevisionStatusPublishing Portal's revision is being published. + PortalRevisionStatusPublishing PortalRevisionStatus = "publishing" +) + +// PossiblePortalRevisionStatusValues returns an array of possible values for the PortalRevisionStatus const type. +func PossiblePortalRevisionStatusValues() []PortalRevisionStatus { + return []PortalRevisionStatus{PortalRevisionStatusCompleted, PortalRevisionStatusFailed, PortalRevisionStatusPending, PortalRevisionStatusPublishing} +} + +// ProductState enumerates the values for product state. +type ProductState string + +const ( + // ProductStateNotPublished ... + ProductStateNotPublished ProductState = "notPublished" + // ProductStatePublished ... + ProductStatePublished ProductState = "published" +) + +// PossibleProductStateValues returns an array of possible values for the ProductState const type. +func PossibleProductStateValues() []ProductState { + return []ProductState{ProductStateNotPublished, ProductStatePublished} +} + +// Protocol enumerates the values for protocol. +type Protocol string + +const ( + // ProtocolHTTP ... + ProtocolHTTP Protocol = "http" + // ProtocolHTTPS ... + ProtocolHTTPS Protocol = "https" + // ProtocolWs ... + ProtocolWs Protocol = "ws" + // ProtocolWss ... + ProtocolWss Protocol = "wss" +) + +// PossibleProtocolValues returns an array of possible values for the Protocol const type. +func PossibleProtocolValues() []Protocol { + return []Protocol{ProtocolHTTP, ProtocolHTTPS, ProtocolWs, ProtocolWss} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCreated ... + ProvisioningStateCreated ProvisioningState = "created" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCreated} +} + +// ResourceSkuCapacityScaleType enumerates the values for resource sku capacity scale type. +type ResourceSkuCapacityScaleType string + +const ( + // ResourceSkuCapacityScaleTypeAutomatic Supported scale type automatic. + ResourceSkuCapacityScaleTypeAutomatic ResourceSkuCapacityScaleType = "automatic" + // ResourceSkuCapacityScaleTypeManual Supported scale type manual. + ResourceSkuCapacityScaleTypeManual ResourceSkuCapacityScaleType = "manual" + // ResourceSkuCapacityScaleTypeNone Scaling not supported. + ResourceSkuCapacityScaleTypeNone ResourceSkuCapacityScaleType = "none" +) + +// PossibleResourceSkuCapacityScaleTypeValues returns an array of possible values for the ResourceSkuCapacityScaleType const type. +func PossibleResourceSkuCapacityScaleTypeValues() []ResourceSkuCapacityScaleType { + return []ResourceSkuCapacityScaleType{ResourceSkuCapacityScaleTypeAutomatic, ResourceSkuCapacityScaleTypeManual, ResourceSkuCapacityScaleTypeNone} +} + +// SamplingType enumerates the values for sampling type. +type SamplingType string + +const ( + // SamplingTypeFixed Fixed-rate sampling. + SamplingTypeFixed SamplingType = "fixed" +) + +// PossibleSamplingTypeValues returns an array of possible values for the SamplingType const type. +func PossibleSamplingTypeValues() []SamplingType { + return []SamplingType{SamplingTypeFixed} +} + +// SkuCapacityScaleType enumerates the values for sku capacity scale type. +type SkuCapacityScaleType string + +const ( + // SkuCapacityScaleTypeAutomatic ... + SkuCapacityScaleTypeAutomatic SkuCapacityScaleType = "Automatic" + // SkuCapacityScaleTypeManual ... + SkuCapacityScaleTypeManual SkuCapacityScaleType = "Manual" + // SkuCapacityScaleTypeNone ... + SkuCapacityScaleTypeNone SkuCapacityScaleType = "None" +) + +// PossibleSkuCapacityScaleTypeValues returns an array of possible values for the SkuCapacityScaleType const type. +func PossibleSkuCapacityScaleTypeValues() []SkuCapacityScaleType { + return []SkuCapacityScaleType{SkuCapacityScaleTypeAutomatic, SkuCapacityScaleTypeManual, SkuCapacityScaleTypeNone} +} + +// SkuRestrictionsReasonCode enumerates the values for sku restrictions reason code. +type SkuRestrictionsReasonCode string + +const ( + // SkuRestrictionsReasonCodeNotAvailableForSubscription ... + SkuRestrictionsReasonCodeNotAvailableForSubscription SkuRestrictionsReasonCode = "NotAvailableForSubscription" + // SkuRestrictionsReasonCodeQuotaID ... + SkuRestrictionsReasonCodeQuotaID SkuRestrictionsReasonCode = "QuotaId" +) + +// PossibleSkuRestrictionsReasonCodeValues returns an array of possible values for the SkuRestrictionsReasonCode const type. +func PossibleSkuRestrictionsReasonCodeValues() []SkuRestrictionsReasonCode { + return []SkuRestrictionsReasonCode{SkuRestrictionsReasonCodeNotAvailableForSubscription, SkuRestrictionsReasonCodeQuotaID} +} + +// SkuRestrictionsType enumerates the values for sku restrictions type. +type SkuRestrictionsType string + +const ( + // SkuRestrictionsTypeLocation ... + SkuRestrictionsTypeLocation SkuRestrictionsType = "Location" + // SkuRestrictionsTypeZone ... + SkuRestrictionsTypeZone SkuRestrictionsType = "Zone" +) + +// PossibleSkuRestrictionsTypeValues returns an array of possible values for the SkuRestrictionsType const type. +func PossibleSkuRestrictionsTypeValues() []SkuRestrictionsType { + return []SkuRestrictionsType{SkuRestrictionsTypeLocation, SkuRestrictionsTypeZone} +} + +// SkuType enumerates the values for sku type. +type SkuType string + +const ( + // SkuTypeBasic Basic SKU of Api Management. + SkuTypeBasic SkuType = "Basic" + // SkuTypeConsumption Consumption SKU of Api Management. + SkuTypeConsumption SkuType = "Consumption" + // SkuTypeDeveloper Developer SKU of Api Management. + SkuTypeDeveloper SkuType = "Developer" + // SkuTypeIsolated Isolated SKU of Api Management. + SkuTypeIsolated SkuType = "Isolated" + // SkuTypePremium Premium SKU of Api Management. + SkuTypePremium SkuType = "Premium" + // SkuTypeStandard Standard SKU of Api Management. + SkuTypeStandard SkuType = "Standard" +) + +// PossibleSkuTypeValues returns an array of possible values for the SkuType const type. +func PossibleSkuTypeValues() []SkuType { + return []SkuType{SkuTypeBasic, SkuTypeConsumption, SkuTypeDeveloper, SkuTypeIsolated, SkuTypePremium, SkuTypeStandard} +} + +// SoapAPIType enumerates the values for soap api type. +type SoapAPIType string + +const ( + // SoapAPITypeSoapPassThrough Imports the Soap API having a SOAP front end. + SoapAPITypeSoapPassThrough SoapAPIType = "soap" + // SoapAPITypeSoapToRest Imports a SOAP API having a RESTful front end. + SoapAPITypeSoapToRest SoapAPIType = "http" + // SoapAPITypeWebSocket Imports the Soap API having a Websocket front end. + SoapAPITypeWebSocket SoapAPIType = "websocket" +) + +// PossibleSoapAPITypeValues returns an array of possible values for the SoapAPIType const type. +func PossibleSoapAPITypeValues() []SoapAPIType { + return []SoapAPIType{SoapAPITypeSoapPassThrough, SoapAPITypeSoapToRest, SoapAPITypeWebSocket} +} + +// State enumerates the values for state. +type State string + +const ( + // StateClosed The issue was closed. + StateClosed State = "closed" + // StateOpen The issue is opened. + StateOpen State = "open" + // StateProposed The issue is proposed. + StateProposed State = "proposed" + // StateRemoved The issue was removed. + StateRemoved State = "removed" + // StateResolved The issue is now resolved. + StateResolved State = "resolved" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{StateClosed, StateOpen, StateProposed, StateRemoved, StateResolved} +} + +// StoreName enumerates the values for store name. +type StoreName string + +const ( + // StoreNameCertificateAuthority ... + StoreNameCertificateAuthority StoreName = "CertificateAuthority" + // StoreNameRoot ... + StoreNameRoot StoreName = "Root" +) + +// PossibleStoreNameValues returns an array of possible values for the StoreName const type. +func PossibleStoreNameValues() []StoreName { + return []StoreName{StoreNameCertificateAuthority, StoreNameRoot} +} + +// SubscriptionState enumerates the values for subscription state. +type SubscriptionState string + +const ( + // SubscriptionStateActive ... + SubscriptionStateActive SubscriptionState = "active" + // SubscriptionStateCancelled ... + SubscriptionStateCancelled SubscriptionState = "cancelled" + // SubscriptionStateExpired ... + SubscriptionStateExpired SubscriptionState = "expired" + // SubscriptionStateRejected ... + SubscriptionStateRejected SubscriptionState = "rejected" + // SubscriptionStateSubmitted ... + SubscriptionStateSubmitted SubscriptionState = "submitted" + // SubscriptionStateSuspended ... + SubscriptionStateSuspended SubscriptionState = "suspended" +) + +// PossibleSubscriptionStateValues returns an array of possible values for the SubscriptionState const type. +func PossibleSubscriptionStateValues() []SubscriptionState { + return []SubscriptionState{SubscriptionStateActive, SubscriptionStateCancelled, SubscriptionStateExpired, SubscriptionStateRejected, SubscriptionStateSubmitted, SubscriptionStateSuspended} +} + +// TemplateName enumerates the values for template name. +type TemplateName string + +const ( + // TemplateNameAccountClosedDeveloper ... + TemplateNameAccountClosedDeveloper TemplateName = "accountClosedDeveloper" + // TemplateNameApplicationApprovedNotificationMessage ... + TemplateNameApplicationApprovedNotificationMessage TemplateName = "applicationApprovedNotificationMessage" + // TemplateNameConfirmSignUpIdentityDefault ... + TemplateNameConfirmSignUpIdentityDefault TemplateName = "confirmSignUpIdentityDefault" + // TemplateNameEmailChangeIdentityDefault ... + TemplateNameEmailChangeIdentityDefault TemplateName = "emailChangeIdentityDefault" + // TemplateNameInviteUserNotificationMessage ... + TemplateNameInviteUserNotificationMessage TemplateName = "inviteUserNotificationMessage" + // TemplateNameNewCommentNotificationMessage ... + TemplateNameNewCommentNotificationMessage TemplateName = "newCommentNotificationMessage" + // TemplateNameNewDeveloperNotificationMessage ... + TemplateNameNewDeveloperNotificationMessage TemplateName = "newDeveloperNotificationMessage" + // TemplateNameNewIssueNotificationMessage ... + TemplateNameNewIssueNotificationMessage TemplateName = "newIssueNotificationMessage" + // TemplateNamePasswordResetByAdminNotificationMessage ... + TemplateNamePasswordResetByAdminNotificationMessage TemplateName = "passwordResetByAdminNotificationMessage" + // TemplateNamePasswordResetIdentityDefault ... + TemplateNamePasswordResetIdentityDefault TemplateName = "passwordResetIdentityDefault" + // TemplateNamePurchaseDeveloperNotificationMessage ... + TemplateNamePurchaseDeveloperNotificationMessage TemplateName = "purchaseDeveloperNotificationMessage" + // TemplateNameQuotaLimitApproachingDeveloperNotificationMessage ... + TemplateNameQuotaLimitApproachingDeveloperNotificationMessage TemplateName = "quotaLimitApproachingDeveloperNotificationMessage" + // TemplateNameRejectDeveloperNotificationMessage ... + TemplateNameRejectDeveloperNotificationMessage TemplateName = "rejectDeveloperNotificationMessage" + // TemplateNameRequestDeveloperNotificationMessage ... + TemplateNameRequestDeveloperNotificationMessage TemplateName = "requestDeveloperNotificationMessage" +) + +// PossibleTemplateNameValues returns an array of possible values for the TemplateName const type. +func PossibleTemplateNameValues() []TemplateName { + return []TemplateName{TemplateNameAccountClosedDeveloper, TemplateNameApplicationApprovedNotificationMessage, TemplateNameConfirmSignUpIdentityDefault, TemplateNameEmailChangeIdentityDefault, TemplateNameInviteUserNotificationMessage, TemplateNameNewCommentNotificationMessage, TemplateNameNewDeveloperNotificationMessage, TemplateNameNewIssueNotificationMessage, TemplateNamePasswordResetByAdminNotificationMessage, TemplateNamePasswordResetIdentityDefault, TemplateNamePurchaseDeveloperNotificationMessage, TemplateNameQuotaLimitApproachingDeveloperNotificationMessage, TemplateNameRejectDeveloperNotificationMessage, TemplateNameRequestDeveloperNotificationMessage} +} + +// UserState enumerates the values for user state. +type UserState string + +const ( + // UserStateActive User state is active. + UserStateActive UserState = "active" + // UserStateBlocked User is blocked. Blocked users cannot authenticate at developer portal or call API. + UserStateBlocked UserState = "blocked" + // UserStateDeleted User account is closed. All identities and related entities are removed. + UserStateDeleted UserState = "deleted" + // UserStatePending User account is pending. Requires identity confirmation before it can be made active. + UserStatePending UserState = "pending" +) + +// PossibleUserStateValues returns an array of possible values for the UserState const type. +func PossibleUserStateValues() []UserState { + return []UserState{UserStateActive, UserStateBlocked, UserStateDeleted, UserStatePending} +} + +// Verbosity enumerates the values for verbosity. +type Verbosity string + +const ( + // VerbosityError Only traces with 'severity' set to 'error' will be sent to the logger attached to this + // diagnostic instance. + VerbosityError Verbosity = "error" + // VerbosityInformation Traces with 'severity' set to 'information' and 'error' will be sent to the logger + // attached to this diagnostic instance. + VerbosityInformation Verbosity = "information" + // VerbosityVerbose All the traces emitted by trace policies will be sent to the logger attached to this + // diagnostic instance. + VerbosityVerbose Verbosity = "verbose" +) + +// PossibleVerbosityValues returns an array of possible values for the Verbosity const type. +func PossibleVerbosityValues() []Verbosity { + return []Verbosity{VerbosityError, VerbosityInformation, VerbosityVerbose} +} + +// VersioningScheme enumerates the values for versioning scheme. +type VersioningScheme string + +const ( + // VersioningSchemeHeader The API Version is passed in a HTTP header. + VersioningSchemeHeader VersioningScheme = "Header" + // VersioningSchemeQuery The API Version is passed in a query parameter. + VersioningSchemeQuery VersioningScheme = "Query" + // VersioningSchemeSegment The API Version is passed in a path segment. + VersioningSchemeSegment VersioningScheme = "Segment" +) + +// PossibleVersioningSchemeValues returns an array of possible values for the VersioningScheme const type. +func PossibleVersioningSchemeValues() []VersioningScheme { + return []VersioningScheme{VersioningSchemeHeader, VersioningSchemeQuery, VersioningSchemeSegment} +} + +// VersioningScheme1 enumerates the values for versioning scheme 1. +type VersioningScheme1 string + +const ( + // VersioningScheme1Header ... + VersioningScheme1Header VersioningScheme1 = "Header" + // VersioningScheme1Query ... + VersioningScheme1Query VersioningScheme1 = "Query" + // VersioningScheme1Segment ... + VersioningScheme1Segment VersioningScheme1 = "Segment" +) + +// PossibleVersioningScheme1Values returns an array of possible values for the VersioningScheme1 const type. +func PossibleVersioningScheme1Values() []VersioningScheme1 { + return []VersioningScheme1{VersioningScheme1Header, VersioningScheme1Query, VersioningScheme1Segment} +} + +// VirtualNetworkType enumerates the values for virtual network type. +type VirtualNetworkType string + +const ( + // VirtualNetworkTypeExternal The service 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 VirtualNetworkType = "Internal" + // VirtualNetworkTypeNone The service is not part of any Virtual Network. + VirtualNetworkTypeNone VirtualNetworkType = "None" +) + +// PossibleVirtualNetworkTypeValues returns an array of possible values for the VirtualNetworkType const type. +func PossibleVirtualNetworkTypeValues() []VirtualNetworkType { + return []VirtualNetworkType{VirtualNetworkTypeExternal, VirtualNetworkTypeInternal, VirtualNetworkTypeNone} +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gateway.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gateway.go new file mode 100644 index 000000000000..e18919cf18a0 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gateway.go @@ -0,0 +1,933 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GatewayClient is the apiManagement Client +type GatewayClient struct { + BaseClient +} + +// NewGatewayClient creates an instance of the GatewayClient client. +func NewGatewayClient(subscriptionID string) GatewayClient { + return NewGatewayClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGatewayClientWithBaseURI creates an instance of the GatewayClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewGatewayClientWithBaseURI(baseURI string, subscriptionID string) GatewayClient { + return GatewayClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a Gateway to be used in Api Management instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client GatewayClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayContract, ifMatch string) (result GatewayContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.GatewayContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.GatewayContractProperties.LocationData", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.GatewayContractProperties.LocationData.Name", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.GatewayContractProperties.LocationData.Name", Name: validation.MaxLength, Rule: 256, Chain: nil}}}, + {Target: "parameters.GatewayContractProperties.LocationData.City", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.GatewayContractProperties.LocationData.City", Name: validation.MaxLength, Rule: 256, Chain: nil}}}, + {Target: "parameters.GatewayContractProperties.LocationData.District", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.GatewayContractProperties.LocationData.District", Name: validation.MaxLength, Rule: 256, Chain: nil}}}, + {Target: "parameters.GatewayContractProperties.LocationData.CountryOrRegion", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.GatewayContractProperties.LocationData.CountryOrRegion", Name: validation.MaxLength, Rule: 256, Chain: nil}}}, + }}, + {Target: "parameters.GatewayContractProperties.Description", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.GatewayContractProperties.Description", Name: validation.MaxLength, Rule: 1000, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, gatewayID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GatewayClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GatewayClient) CreateOrUpdateResponder(resp *http.Response) (result GatewayContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific Gateway. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// 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. +func (client GatewayClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, gatewayID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GatewayClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GatewayClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateToken gets the Shared Access Authorization Token for the gateway. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +func (client GatewayClient) GenerateToken(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayTokenRequestContract) (result GatewayTokenContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.GenerateToken") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Expiry", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayClient", "GenerateToken", err.Error()) + } + + req, err := client.GenerateTokenPreparer(ctx, resourceGroupName, serviceName, gatewayID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "GenerateToken", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateTokenSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "GenerateToken", resp, "Failure sending request") + return + } + + result, err = client.GenerateTokenResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "GenerateToken", resp, "Failure responding to request") + return + } + + return +} + +// GenerateTokenPreparer prepares the GenerateToken request. +func (client GatewayClient) GenerateTokenPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayTokenRequestContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateTokenSender sends the GenerateToken request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) GenerateTokenSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateTokenResponder handles the response to the GenerateToken request. The method always +// closes the http.Response Body. +func (client GatewayClient) GenerateTokenResponder(resp *http.Response) (result GatewayTokenContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the details of the Gateway specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +func (client GatewayClient) Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string) (result GatewayContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, gatewayID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GatewayClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GatewayClient) GetResponder(resp *http.Response) (result GatewayContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the Gateway specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +func (client GatewayClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, gatewayID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client GatewayClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client GatewayClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of gateways registered with service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
| region | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client GatewayClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result GatewayCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.ListByService") + defer func() { + sc := -1 + if result.gc.Response.Response != nil { + sc = result.gc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.gc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "ListByService", resp, "Failure sending request") + return + } + + result.gc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "ListByService", resp, "Failure responding to request") + return + } + if result.gc.hasNextLink() && result.gc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client GatewayClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client GatewayClient) ListByServiceResponder(resp *http.Response) (result GatewayCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client GatewayClient) listByServiceNextResults(ctx context.Context, lastResults GatewayCollection) (result GatewayCollection, err error) { + req, err := lastResults.gatewayCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client GatewayClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result GatewayCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// ListKeys retrieves gateway keys. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +func (client GatewayClient) ListKeys(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string) (result GatewayKeysContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.ListKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayClient", "ListKeys", err.Error()) + } + + req, err := client.ListKeysPreparer(ctx, resourceGroupName, serviceName, gatewayID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "ListKeys", resp, "Failure sending request") + return + } + + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "ListKeys", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client GatewayClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client GatewayClient) ListKeysResponder(resp *http.Response) (result GatewayKeysContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateKey regenerates specified gateway key invalidating any tokens created with it. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +func (client GatewayClient) RegenerateKey(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayKeyRegenerationRequestContract) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.RegenerateKey") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayClient", "RegenerateKey", err.Error()) + } + + req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, serviceName, gatewayID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "RegenerateKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "RegenerateKey", resp, "Failure responding to request") + return + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client GatewayClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayKeyRegenerationRequestContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client GatewayClient) RegenerateKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates the details of the gateway specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// 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. +func (client GatewayClient) Update(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayContract, ifMatch string) (result GatewayContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, gatewayID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client GatewayClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client GatewayClient) UpdateResponder(resp *http.Response) (result GatewayContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gatewayapi.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gatewayapi.go new file mode 100644 index 000000000000..6b6e386f2323 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gatewayapi.go @@ -0,0 +1,472 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GatewayAPIClient is the apiManagement Client +type GatewayAPIClient struct { + BaseClient +} + +// NewGatewayAPIClient creates an instance of the GatewayAPIClient client. +func NewGatewayAPIClient(subscriptionID string) GatewayAPIClient { + return NewGatewayAPIClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGatewayAPIClientWithBaseURI creates an instance of the GatewayAPIClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewGatewayAPIClientWithBaseURI(baseURI string, subscriptionID string) GatewayAPIClient { + return GatewayAPIClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate adds an API to the specified Gateway. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// apiid - API identifier. Must be unique in the current API Management service instance. +func (client GatewayAPIClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiid string, parameters *AssociationContract) (result APIContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayAPIClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayAPIClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, gatewayID, apiid, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GatewayAPIClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiid string, parameters *AssociationContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayAPIClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GatewayAPIClient) CreateOrUpdateResponder(resp *http.Response) (result APIContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified API from the specified Gateway. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// apiid - API identifier. Must be unique in the current API Management service instance. +func (client GatewayAPIClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayAPIClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayAPIClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, gatewayID, apiid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GatewayAPIClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayAPIClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GatewayAPIClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetEntityTag checks that API entity specified by identifier is associated with the Gateway entity. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// apiid - API identifier. Must be unique in the current API Management service instance. +func (client GatewayAPIClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayAPIClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayAPIClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, gatewayID, apiid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client GatewayAPIClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayAPIClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client GatewayAPIClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of the APIs associated with a gateway. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client GatewayAPIClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result APICollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayAPIClient.ListByService") + defer func() { + sc := -1 + if result.ac.Response.Response != nil { + sc = result.ac.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayAPIClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, gatewayID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.ac.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "ListByService", resp, "Failure sending request") + return + } + + result.ac, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "ListByService", resp, "Failure responding to request") + return + } + if result.ac.hasNextLink() && result.ac.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client GatewayAPIClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayAPIClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client GatewayAPIClient) ListByServiceResponder(resp *http.Response) (result APICollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client GatewayAPIClient) listByServiceNextResults(ctx context.Context, lastResults APICollection) (result APICollection, err error) { + req, err := lastResults.aPICollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayAPIClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client GatewayAPIClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result APICollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayAPIClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, gatewayID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gatewaycertificateauthority.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gatewaycertificateauthority.go new file mode 100644 index 000000000000..798a843d7c08 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gatewaycertificateauthority.go @@ -0,0 +1,580 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GatewayCertificateAuthorityClient is the apiManagement Client +type GatewayCertificateAuthorityClient struct { + BaseClient +} + +// NewGatewayCertificateAuthorityClient creates an instance of the GatewayCertificateAuthorityClient client. +func NewGatewayCertificateAuthorityClient(subscriptionID string) GatewayCertificateAuthorityClient { + return NewGatewayCertificateAuthorityClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGatewayCertificateAuthorityClientWithBaseURI creates an instance of the GatewayCertificateAuthorityClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewGatewayCertificateAuthorityClientWithBaseURI(baseURI string, subscriptionID string) GatewayCertificateAuthorityClient { + return GatewayCertificateAuthorityClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate assign Certificate entity to Gateway entity as Certificate Authority. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// certificateID - identifier of the certificate entity. Must be unique in the current API Management service +// instance. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client GatewayCertificateAuthorityClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, parameters GatewayCertificateAuthorityContract, ifMatch string) (result GatewayCertificateAuthorityContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, gatewayID, certificateID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GatewayCertificateAuthorityClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, parameters GatewayCertificateAuthorityContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateId": autorest.Encode("path", certificateID), + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayCertificateAuthorityClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GatewayCertificateAuthorityClient) CreateOrUpdateResponder(resp *http.Response) (result GatewayCertificateAuthorityContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete remove relationship between Certificate Authority and Gateway entity. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// 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. +func (client GatewayCertificateAuthorityClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, gatewayID, certificateID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GatewayCertificateAuthorityClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateId": autorest.Encode("path", certificateID), + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayCertificateAuthorityClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GatewayCertificateAuthorityClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get assigned Gateway Certificate Authority details. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// certificateID - identifier of the certificate entity. Must be unique in the current API Management service +// instance. +func (client GatewayCertificateAuthorityClient) Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (result GatewayCertificateAuthorityContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, gatewayID, certificateID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GatewayCertificateAuthorityClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateId": autorest.Encode("path", certificateID), + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayCertificateAuthorityClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GatewayCertificateAuthorityClient) GetResponder(resp *http.Response) (result GatewayCertificateAuthorityContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag checks if Certificate entity is assigned to Gateway entity as Certificate Authority. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// certificateID - identifier of the certificate entity. Must be unique in the current API Management service +// instance. +func (client GatewayCertificateAuthorityClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: certificateID, + Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, gatewayID, certificateID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client GatewayCertificateAuthorityClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateId": autorest.Encode("path", certificateID), + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayCertificateAuthorityClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client GatewayCertificateAuthorityClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists the collection of Certificate Authorities for the specified Gateway entity. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | eq, ne | |
+// top - number of records to return. +// skip - number of records to skip. +func (client GatewayCertificateAuthorityClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result GatewayCertificateAuthorityCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.ListByService") + defer func() { + sc := -1 + if result.gcac.Response.Response != nil { + sc = result.gcac.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayCertificateAuthorityClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, gatewayID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.gcac.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "ListByService", resp, "Failure sending request") + return + } + + result.gcac, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "ListByService", resp, "Failure responding to request") + return + } + if result.gcac.hasNextLink() && result.gcac.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client GatewayCertificateAuthorityClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayCertificateAuthorityClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client GatewayCertificateAuthorityClient) ListByServiceResponder(resp *http.Response) (result GatewayCertificateAuthorityCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client GatewayCertificateAuthorityClient) listByServiceNextResults(ctx context.Context, lastResults GatewayCertificateAuthorityCollection) (result GatewayCertificateAuthorityCollection, err error) { + req, err := lastResults.gatewayCertificateAuthorityCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayCertificateAuthorityClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client GatewayCertificateAuthorityClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result GatewayCertificateAuthorityCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, gatewayID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gatewayhostnameconfiguration.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gatewayhostnameconfiguration.go new file mode 100644 index 000000000000..f9283b9087d3 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/gatewayhostnameconfiguration.go @@ -0,0 +1,574 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GatewayHostnameConfigurationClient is the apiManagement Client +type GatewayHostnameConfigurationClient struct { + BaseClient +} + +// NewGatewayHostnameConfigurationClient creates an instance of the GatewayHostnameConfigurationClient client. +func NewGatewayHostnameConfigurationClient(subscriptionID string) GatewayHostnameConfigurationClient { + return NewGatewayHostnameConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGatewayHostnameConfigurationClientWithBaseURI creates an instance of the GatewayHostnameConfigurationClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewGatewayHostnameConfigurationClientWithBaseURI(baseURI string, subscriptionID string) GatewayHostnameConfigurationClient { + return GatewayHostnameConfigurationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates of updates hostname configuration for a Gateway. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// hcID - gateway hostname configuration identifier. Must be unique in the scope of parent Gateway entity. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client GatewayHostnameConfigurationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, parameters GatewayHostnameConfigurationContract, ifMatch string) (result GatewayHostnameConfigurationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayHostnameConfigurationClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: hcID, + Constraints: []validation.Constraint{{Target: "hcID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "hcID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayHostnameConfigurationClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, gatewayID, hcID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GatewayHostnameConfigurationClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, parameters GatewayHostnameConfigurationContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "hcId": autorest.Encode("path", hcID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayHostnameConfigurationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GatewayHostnameConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result GatewayHostnameConfigurationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified hostname configuration from the specified Gateway. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// hcID - gateway hostname configuration identifier. Must be unique in the scope of parent Gateway entity. +// 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. +func (client GatewayHostnameConfigurationClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayHostnameConfigurationClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: hcID, + Constraints: []validation.Constraint{{Target: "hcID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "hcID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayHostnameConfigurationClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, gatewayID, hcID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GatewayHostnameConfigurationClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "hcId": autorest.Encode("path", hcID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayHostnameConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GatewayHostnameConfigurationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get details of a hostname configuration +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// hcID - gateway hostname configuration identifier. Must be unique in the scope of parent Gateway entity. +func (client GatewayHostnameConfigurationClient) Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string) (result GatewayHostnameConfigurationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayHostnameConfigurationClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: hcID, + Constraints: []validation.Constraint{{Target: "hcID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "hcID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayHostnameConfigurationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, gatewayID, hcID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GatewayHostnameConfigurationClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "hcId": autorest.Encode("path", hcID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayHostnameConfigurationClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GatewayHostnameConfigurationClient) GetResponder(resp *http.Response) (result GatewayHostnameConfigurationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag checks that hostname configuration entity specified by identifier exists for specified Gateway entity. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// hcID - gateway hostname configuration identifier. Must be unique in the scope of parent Gateway entity. +func (client GatewayHostnameConfigurationClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayHostnameConfigurationClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: hcID, + Constraints: []validation.Constraint{{Target: "hcID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "hcID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayHostnameConfigurationClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, gatewayID, hcID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client GatewayHostnameConfigurationClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "hcId": autorest.Encode("path", hcID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayHostnameConfigurationClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client GatewayHostnameConfigurationClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists the collection of hostname configurations for the specified gateway. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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' +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
| hostname | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client GatewayHostnameConfigurationClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result GatewayHostnameConfigurationCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayHostnameConfigurationClient.ListByService") + defer func() { + sc := -1 + if result.ghcc.Response.Response != nil { + sc = result.ghcc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: gatewayID, + Constraints: []validation.Constraint{{Target: "gatewayID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "gatewayID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.GatewayHostnameConfigurationClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, gatewayID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.ghcc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "ListByService", resp, "Failure sending request") + return + } + + result.ghcc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "ListByService", resp, "Failure responding to request") + return + } + if result.ghcc.hasNextLink() && result.ghcc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client GatewayHostnameConfigurationClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayId": autorest.Encode("path", gatewayID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayHostnameConfigurationClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client GatewayHostnameConfigurationClient) ListByServiceResponder(resp *http.Response) (result GatewayHostnameConfigurationCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client GatewayHostnameConfigurationClient) listByServiceNextResults(ctx context.Context, lastResults GatewayHostnameConfigurationCollection) (result GatewayHostnameConfigurationCollection, err error) { + req, err := lastResults.gatewayHostnameConfigurationCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GatewayHostnameConfigurationClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client GatewayHostnameConfigurationClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, filter string, top *int32, skip *int32) (result GatewayHostnameConfigurationCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayHostnameConfigurationClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, gatewayID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/group.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/group.go new file mode 100644 index 000000000000..262b585eb864 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/group.go @@ -0,0 +1,647 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GroupClient is the apiManagement Client +type GroupClient struct { + BaseClient +} + +// NewGroupClient creates an instance of the GroupClient client. +func NewGroupClient(subscriptionID string) GroupClient { + return NewGroupClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGroupClientWithBaseURI creates an instance of the GroupClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewGroupClientWithBaseURI(baseURI string, subscriptionID string) GroupClient { + return GroupClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or Updates a group. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// groupID - group identifier. Must be unique in the current API Management service instance. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client GroupClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupCreateParameters, ifMatch string) (result GroupContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.GroupCreateParametersProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.GroupCreateParametersProperties.DisplayName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.GroupCreateParametersProperties.DisplayName", Name: validation.MaxLength, Rule: 300, Chain: nil}, + {Target: "parameters.GroupCreateParametersProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, groupID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GroupClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupCreateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client GroupClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GroupClient) CreateOrUpdateResponder(resp *http.Response) (result GroupContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific group of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client GroupClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, groupID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GroupClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client GroupClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the group specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// groupID - group identifier. Must be unique in the current API Management service instance. +func (client GroupClient) Get(ctx context.Context, resourceGroupName string, serviceName string, groupID string) (result GroupContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, groupID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GroupClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, groupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GroupClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GroupClient) GetResponder(resp *http.Response) (result GroupContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the group specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// groupID - group identifier. Must be unique in the current API Management service instance. +func (client GroupClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, groupID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, groupID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client GroupClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, groupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client GroupClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client GroupClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of groups defined within a service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 | |
+// top - number of records to return. +// skip - number of records to skip. +func (client GroupClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result GroupCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupClient.ListByService") + defer func() { + sc := -1 + if result.gc.Response.Response != nil { + sc = result.gc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.gc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "ListByService", resp, "Failure sending request") + return + } + + result.gc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "ListByService", resp, "Failure responding to request") + return + } + if result.gc.hasNextLink() && result.gc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client GroupClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client GroupClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client GroupClient) ListByServiceResponder(resp *http.Response) (result GroupCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client GroupClient) listByServiceNextResults(ctx context.Context, lastResults GroupCollection) (result GroupCollection, err error) { + req, err := lastResults.groupCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.GroupClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.GroupClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client GroupClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result GroupCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// Update updates the details of the group specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// groupID - group identifier. Must be unique in the current API Management service instance. +// parameters - update parameters. +// 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. +func (client GroupClient) Update(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupUpdateParameters, ifMatch string) (result GroupContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, groupID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client GroupClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client GroupClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client GroupClient) UpdateResponder(resp *http.Response) (result GroupContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/groupuser.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/groupuser.go new file mode 100644 index 000000000000..6314f91751e5 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/groupuser.go @@ -0,0 +1,467 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GroupUserClient is the apiManagement Client +type GroupUserClient struct { + BaseClient +} + +// NewGroupUserClient creates an instance of the GroupUserClient client. +func NewGroupUserClient(subscriptionID string) GroupUserClient { + return NewGroupUserClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGroupUserClientWithBaseURI creates an instance of the GroupUserClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewGroupUserClientWithBaseURI(baseURI string, subscriptionID string) GroupUserClient { + return GroupUserClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckEntityExists checks that user entity specified by identifier is associated with the group entity. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client GroupUserClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupUserClient.CheckEntityExists") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupUserClient", "CheckEntityExists", err.Error()) + } + + req, err := client.CheckEntityExistsPreparer(ctx, resourceGroupName, serviceName, groupID, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "CheckEntityExists", nil, "Failure preparing request") + return + } + + resp, err := client.CheckEntityExistsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "CheckEntityExists", resp, "Failure sending request") + return + } + + result, err = client.CheckEntityExistsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "CheckEntityExists", resp, "Failure responding to request") + return + } + + return +} + +// CheckEntityExistsPreparer prepares the CheckEntityExists request. +func (client GroupUserClient) CheckEntityExistsPreparer(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckEntityExistsSender sends the CheckEntityExists request. The method will close the +// http.Response Body if it receives an error. +func (client GroupUserClient) CheckEntityExistsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckEntityExistsResponder handles the response to the CheckEntityExists request. The method always +// closes the http.Response Body. +func (client GroupUserClient) CheckEntityExistsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// Create add existing user to existing group +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client GroupUserClient) Create(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string) (result UserContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupUserClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupUserClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serviceName, groupID, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client GroupUserClient) CreatePreparer(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client GroupUserClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client GroupUserClient) CreateResponder(resp *http.Response) (result UserContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete remove existing user from existing group. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client GroupUserClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupUserClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupUserClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, groupID, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GroupUserClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client GroupUserClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GroupUserClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// List lists a collection of user entities associated with the group. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// groupID - group identifier. Must be unique in the current API Management service instance. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +func (client GroupUserClient) List(ctx context.Context, resourceGroupName string, serviceName string, groupID string, filter string, top *int32, skip *int32) (result UserCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupUserClient.List") + defer func() { + sc := -1 + if result.uc.Response.Response != nil { + sc = result.uc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.GroupUserClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, serviceName, groupID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.uc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "List", resp, "Failure sending request") + return + } + + result.uc, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "List", resp, "Failure responding to request") + return + } + if result.uc.hasNextLink() && result.uc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client GroupUserClient) ListPreparer(ctx context.Context, resourceGroupName string, serviceName string, groupID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client GroupUserClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client GroupUserClient) ListResponder(resp *http.Response) (result UserCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client GroupUserClient) listNextResults(ctx context.Context, lastResults UserCollection) (result UserCollection, err error) { + req, err := lastResults.userCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.GroupUserClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client GroupUserClient) ListComplete(ctx context.Context, resourceGroupName string, serviceName string, groupID string, filter string, top *int32, skip *int32) (result UserCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupUserClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, serviceName, groupID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/identityprovider.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/identityprovider.go new file mode 100644 index 000000000000..31c69cea4962 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/identityprovider.go @@ -0,0 +1,697 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IdentityProviderClient is the apiManagement Client +type IdentityProviderClient struct { + BaseClient +} + +// NewIdentityProviderClient creates an instance of the IdentityProviderClient client. +func NewIdentityProviderClient(subscriptionID string) IdentityProviderClient { + return NewIdentityProviderClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewIdentityProviderClientWithBaseURI creates an instance of the IdentityProviderClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewIdentityProviderClientWithBaseURI(baseURI string, subscriptionID string) IdentityProviderClient { + return IdentityProviderClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or Updates the IdentityProvider configuration. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// identityProviderName - identity Provider Type identifier. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client IdentityProviderClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderCreateContract, ifMatch string) (result IdentityProviderContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.IdentityProviderCreateContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.IdentityProviderCreateContractProperties.ClientID", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.IdentityProviderCreateContractProperties.ClientID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {Target: "parameters.IdentityProviderCreateContractProperties.ClientSecret", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.IdentityProviderCreateContractProperties.ClientSecret", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.IdentityProviderClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, identityProviderName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client IdentityProviderClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderCreateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "identityProviderName": autorest.Encode("path", identityProviderName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client IdentityProviderClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client IdentityProviderClient) CreateOrUpdateResponder(resp *http.Response) (result IdentityProviderContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified identity provider configuration. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// identityProviderName - identity Provider Type 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. +func (client IdentityProviderClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.IdentityProviderClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, identityProviderName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client IdentityProviderClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "identityProviderName": autorest.Encode("path", identityProviderName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client IdentityProviderClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client IdentityProviderClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the configuration details of the identity Provider configured in specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// identityProviderName - identity Provider Type identifier. +func (client IdentityProviderClient) Get(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (result IdentityProviderContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.IdentityProviderClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, identityProviderName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client IdentityProviderClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "identityProviderName": autorest.Encode("path", identityProviderName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IdentityProviderClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IdentityProviderClient) GetResponder(resp *http.Response) (result IdentityProviderContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the identityProvider specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// identityProviderName - identity Provider Type identifier. +func (client IdentityProviderClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.IdentityProviderClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, identityProviderName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client IdentityProviderClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "identityProviderName": autorest.Encode("path", identityProviderName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client IdentityProviderClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client IdentityProviderClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of Identity Provider configured in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client IdentityProviderClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result IdentityProviderListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.ListByService") + defer func() { + sc := -1 + if result.ipl.Response.Response != nil { + sc = result.ipl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.IdentityProviderClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.ipl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListByService", resp, "Failure sending request") + return + } + + result.ipl, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListByService", resp, "Failure responding to request") + return + } + if result.ipl.hasNextLink() && result.ipl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client IdentityProviderClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client IdentityProviderClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client IdentityProviderClient) ListByServiceResponder(resp *http.Response) (result IdentityProviderList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client IdentityProviderClient) listByServiceNextResults(ctx context.Context, lastResults IdentityProviderList) (result IdentityProviderList, err error) { + req, err := lastResults.identityProviderListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client IdentityProviderClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string) (result IdentityProviderListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName) + return +} + +// ListSecrets gets the client secret details of the Identity Provider. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// identityProviderName - identity Provider Type identifier. +func (client IdentityProviderClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (result ClientSecretContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.ListSecrets") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.IdentityProviderClient", "ListSecrets", err.Error()) + } + + req, err := client.ListSecretsPreparer(ctx, resourceGroupName, serviceName, identityProviderName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListSecrets", nil, "Failure preparing request") + return + } + + resp, err := client.ListSecretsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListSecrets", resp, "Failure sending request") + return + } + + result, err = client.ListSecretsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "ListSecrets", resp, "Failure responding to request") + return + } + + return +} + +// ListSecretsPreparer prepares the ListSecrets request. +func (client IdentityProviderClient) ListSecretsPreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "identityProviderName": autorest.Encode("path", identityProviderName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSecretsSender sends the ListSecrets request. The method will close the +// http.Response Body if it receives an error. +func (client IdentityProviderClient) ListSecretsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSecretsResponder handles the response to the ListSecrets request. The method always +// closes the http.Response Body. +func (client IdentityProviderClient) ListSecretsResponder(resp *http.Response) (result ClientSecretContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing IdentityProvider configuration. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// identityProviderName - identity Provider Type identifier. +// parameters - update parameters. +// 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. +func (client IdentityProviderClient) Update(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderUpdateParameters, ifMatch string) (result IdentityProviderContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.IdentityProviderClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, identityProviderName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IdentityProviderClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client IdentityProviderClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "identityProviderName": autorest.Encode("path", identityProviderName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client IdentityProviderClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client IdentityProviderClient) UpdateResponder(resp *http.Response) (result IdentityProviderContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/issue.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/issue.go new file mode 100644 index 000000000000..3a98525f5006 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/issue.go @@ -0,0 +1,272 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IssueClient is the apiManagement Client +type IssueClient struct { + BaseClient +} + +// NewIssueClient creates an instance of the IssueClient client. +func NewIssueClient(subscriptionID string) IssueClient { + return NewIssueClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewIssueClientWithBaseURI creates an instance of the IssueClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewIssueClientWithBaseURI(baseURI string, subscriptionID string) IssueClient { + return IssueClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets API Management issue details +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// issueID - issue identifier. Must be unique in the current API Management service instance. +func (client IssueClient) Get(ctx context.Context, resourceGroupName string, serviceName string, issueID string) (result IssueContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IssueClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.IssueClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, issueID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IssueClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.IssueClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IssueClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client IssueClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, issueID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IssueClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IssueClient) GetResponder(resp *http.Response) (result IssueContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists a collection of issues in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
| apiId | filter | ge, le, eq, ne, gt, lt | substringof, +// contains, startswith, endswith |
| title | filter | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith |
| state | filter | eq | |
+// top - number of records to return. +// skip - number of records to skip. +func (client IssueClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result IssueCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IssueClient.ListByService") + defer func() { + sc := -1 + if result.ic.Response.Response != nil { + sc = result.ic.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.IssueClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IssueClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.ic.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.IssueClient", "ListByService", resp, "Failure sending request") + return + } + + result.ic, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IssueClient", "ListByService", resp, "Failure responding to request") + return + } + if result.ic.hasNextLink() && result.ic.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client IssueClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client IssueClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client IssueClient) ListByServiceResponder(resp *http.Response) (result IssueCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client IssueClient) listByServiceNextResults(ctx context.Context, lastResults IssueCollection) (result IssueCollection, err error) { + req, err := lastResults.issueCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.IssueClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.IssueClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.IssueClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client IssueClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result IssueCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IssueClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/logger.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/logger.go new file mode 100644 index 000000000000..d11f0aa1e6f8 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/logger.go @@ -0,0 +1,645 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LoggerClient is the apiManagement Client +type LoggerClient struct { + BaseClient +} + +// NewLoggerClient creates an instance of the LoggerClient client. +func NewLoggerClient(subscriptionID string) LoggerClient { + return NewLoggerClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLoggerClientWithBaseURI creates an instance of the LoggerClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewLoggerClientWithBaseURI(baseURI string, subscriptionID string) LoggerClient { + return LoggerClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or Updates a logger. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// loggerID - logger identifier. Must be unique in the API Management service instance. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client LoggerClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, parameters LoggerContract, ifMatch string) (result LoggerContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LoggerClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: loggerID, + Constraints: []validation.Constraint{{Target: "loggerID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "loggerID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LoggerContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.LoggerContractProperties.Description", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.LoggerContractProperties.Description", Name: validation.MaxLength, Rule: 256, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.LoggerClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, loggerID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LoggerClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, parameters LoggerContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "loggerId": autorest.Encode("path", loggerID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client LoggerClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LoggerClient) CreateOrUpdateResponder(resp *http.Response) (result LoggerContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified logger. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client LoggerClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LoggerClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: loggerID, + Constraints: []validation.Constraint{{Target: "loggerID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "loggerID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.LoggerClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, loggerID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LoggerClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "loggerId": autorest.Encode("path", loggerID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LoggerClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LoggerClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the logger specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// loggerID - logger identifier. Must be unique in the API Management service instance. +func (client LoggerClient) Get(ctx context.Context, resourceGroupName string, serviceName string, loggerID string) (result LoggerContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LoggerClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: loggerID, + Constraints: []validation.Constraint{{Target: "loggerID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "loggerID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.LoggerClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, loggerID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LoggerClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, loggerID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "loggerId": autorest.Encode("path", loggerID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LoggerClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LoggerClient) GetResponder(resp *http.Response) (result LoggerContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the logger specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// loggerID - logger identifier. Must be unique in the API Management service instance. +func (client LoggerClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, loggerID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LoggerClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: loggerID, + Constraints: []validation.Constraint{{Target: "loggerID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "loggerID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.LoggerClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, loggerID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client LoggerClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, loggerID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "loggerId": autorest.Encode("path", loggerID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client LoggerClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client LoggerClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of loggers in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +func (client LoggerClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result LoggerCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LoggerClient.ListByService") + defer func() { + sc := -1 + if result.lc.Response.Response != nil { + sc = result.lc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.LoggerClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.lc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "ListByService", resp, "Failure sending request") + return + } + + result.lc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "ListByService", resp, "Failure responding to request") + return + } + if result.lc.hasNextLink() && result.lc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client LoggerClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client LoggerClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client LoggerClient) ListByServiceResponder(resp *http.Response) (result LoggerCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client LoggerClient) listByServiceNextResults(ctx context.Context, lastResults LoggerCollection) (result LoggerCollection, err error) { + req, err := lastResults.loggerCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client LoggerClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result LoggerCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LoggerClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// Update updates an existing logger. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// loggerID - logger identifier. Must be unique in the API Management service instance. +// parameters - update parameters. +// 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. +func (client LoggerClient) Update(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, parameters LoggerUpdateContract, ifMatch string) (result LoggerContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LoggerClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: loggerID, + Constraints: []validation.Constraint{{Target: "loggerID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "loggerID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.LoggerClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, loggerID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.LoggerClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LoggerClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, parameters LoggerUpdateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "loggerId": autorest.Encode("path", loggerID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client LoggerClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LoggerClient) UpdateResponder(resp *http.Response) (result LoggerContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/models.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/models.go new file mode 100644 index 000000000000..44ca103615ab --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/models.go @@ -0,0 +1,16434 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement" + +// AccessInformationCollection paged AccessInformation list representation. +type AccessInformationCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]AccessInformationContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessInformationCollection. +func (aic AccessInformationCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aic.Count != nil { + objectMap["count"] = aic.Count + } + return json.Marshal(objectMap) +} + +// AccessInformationCollectionIterator provides access to a complete listing of AccessInformationContract +// values. +type AccessInformationCollectionIterator struct { + i int + page AccessInformationCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AccessInformationCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessInformationCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AccessInformationCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AccessInformationCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AccessInformationCollectionIterator) Response() AccessInformationCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AccessInformationCollectionIterator) Value() AccessInformationContract { + if !iter.page.NotDone() { + return AccessInformationContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AccessInformationCollectionIterator type. +func NewAccessInformationCollectionIterator(page AccessInformationCollectionPage) AccessInformationCollectionIterator { + return AccessInformationCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aic AccessInformationCollection) IsEmpty() bool { + return aic.Value == nil || len(*aic.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (aic AccessInformationCollection) hasNextLink() bool { + return aic.NextLink != nil && len(*aic.NextLink) != 0 +} + +// accessInformationCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aic AccessInformationCollection) accessInformationCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !aic.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aic.NextLink))) +} + +// AccessInformationCollectionPage contains a page of AccessInformationContract values. +type AccessInformationCollectionPage struct { + fn func(context.Context, AccessInformationCollection) (AccessInformationCollection, error) + aic AccessInformationCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AccessInformationCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccessInformationCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.aic) + if err != nil { + return err + } + page.aic = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AccessInformationCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AccessInformationCollectionPage) NotDone() bool { + return !page.aic.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AccessInformationCollectionPage) Response() AccessInformationCollection { + return page.aic +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AccessInformationCollectionPage) Values() []AccessInformationContract { + if page.aic.IsEmpty() { + return nil + } + return *page.aic.Value +} + +// Creates a new instance of the AccessInformationCollectionPage type. +func NewAccessInformationCollectionPage(cur AccessInformationCollection, getNextPage func(context.Context, AccessInformationCollection) (AccessInformationCollection, error)) AccessInformationCollectionPage { + return AccessInformationCollectionPage{ + fn: getNextPage, + aic: cur, + } +} + +// AccessInformationContract tenant Settings. +type AccessInformationContract struct { + autorest.Response `json:"-"` + // AccessInformationContractProperties - AccessInformation entity contract properties. + *AccessInformationContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessInformationContract. +func (aic AccessInformationContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aic.AccessInformationContractProperties != nil { + objectMap["properties"] = aic.AccessInformationContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessInformationContract struct. +func (aic *AccessInformationContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accessInformationContractProperties AccessInformationContractProperties + err = json.Unmarshal(*v, &accessInformationContractProperties) + if err != nil { + return err + } + aic.AccessInformationContractProperties = &accessInformationContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + aic.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + aic.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + aic.Type = &typeVar + } + } + } + + return nil +} + +// AccessInformationContractProperties tenant access information contract of the API Management service. +type AccessInformationContractProperties struct { + // ID - Access Information type ('access' or 'gitAccess') + ID *string `json:"id,omitempty"` + // PrincipalID - Principal (User) Identifier. + PrincipalID *string `json:"principalId,omitempty"` + // Enabled - Determines whether direct access is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// AccessInformationCreateParameterProperties tenant access information update parameters of the API +// Management service +type AccessInformationCreateParameterProperties struct { + // PrincipalID - Principal (User) Identifier. + PrincipalID *string `json:"principalId,omitempty"` + // PrimaryKey - Primary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - Secondary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // Enabled - Determines whether direct access is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// AccessInformationCreateParameters tenant access information update parameters. +type AccessInformationCreateParameters struct { + // AccessInformationCreateParameterProperties - Tenant access information update parameter properties. + *AccessInformationCreateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessInformationCreateParameters. +func (aicp AccessInformationCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aicp.AccessInformationCreateParameterProperties != nil { + objectMap["properties"] = aicp.AccessInformationCreateParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessInformationCreateParameters struct. +func (aicp *AccessInformationCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accessInformationCreateParameterProperties AccessInformationCreateParameterProperties + err = json.Unmarshal(*v, &accessInformationCreateParameterProperties) + if err != nil { + return err + } + aicp.AccessInformationCreateParameterProperties = &accessInformationCreateParameterProperties + } + } + } + + return nil +} + +// AccessInformationSecretsContract tenant access information contract of the API Management service. +type AccessInformationSecretsContract struct { + autorest.Response `json:"-"` + // ID - Access Information type ('access' or 'gitAccess') + ID *string `json:"id,omitempty"` + // PrincipalID - Principal (User) Identifier. + PrincipalID *string `json:"principalId,omitempty"` + // PrimaryKey - Primary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - Secondary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // Enabled - Determines whether direct access is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// AccessInformationUpdateParameterProperties tenant access information update parameters of the API +// Management service +type AccessInformationUpdateParameterProperties struct { + // Enabled - Determines whether direct access is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// AccessInformationUpdateParameters tenant access information update parameters. +type AccessInformationUpdateParameters struct { + // AccessInformationUpdateParameterProperties - Tenant access information update parameter properties. + *AccessInformationUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccessInformationUpdateParameters. +func (aiup AccessInformationUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aiup.AccessInformationUpdateParameterProperties != nil { + objectMap["properties"] = aiup.AccessInformationUpdateParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccessInformationUpdateParameters struct. +func (aiup *AccessInformationUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accessInformationUpdateParameterProperties AccessInformationUpdateParameterProperties + err = json.Unmarshal(*v, &accessInformationUpdateParameterProperties) + if err != nil { + return err + } + aiup.AccessInformationUpdateParameterProperties = &accessInformationUpdateParameterProperties + } + } + } + + return nil +} + +// AdditionalLocation description of an additional API Management resource location. +type AdditionalLocation struct { + // Location - The location name of the additional region among Azure Data center regions. + Location *string `json:"location,omitempty"` + // Sku - SKU properties of the API Management service. + Sku *ServiceSkuProperties `json:"sku,omitempty"` + // Zones - A list of availability zones denoting where the resource needs to come from. + Zones *[]string `json:"zones,omitempty"` + // PublicIPAddresses - READ-ONLY; Public Static Load Balanced IP addresses of the API Management service in the additional location. Available only for Basic, Standard, Premium and Isolated SKU. + PublicIPAddresses *[]string `json:"publicIPAddresses,omitempty"` + // PrivateIPAddresses - READ-ONLY; Private Static Load Balanced IP addresses of the API Management service which is deployed in an Internal Virtual Network in a particular additional location. Available only for Basic, Standard, Premium and Isolated SKU. + PrivateIPAddresses *[]string `json:"privateIPAddresses,omitempty"` + // PublicIPAddressID - Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the location. Supported only for Premium SKU being deployed in Virtual Network. + PublicIPAddressID *string `json:"publicIpAddressId,omitempty"` + // VirtualNetworkConfiguration - Virtual network configuration for the location. + VirtualNetworkConfiguration *VirtualNetworkConfiguration `json:"virtualNetworkConfiguration,omitempty"` + // GatewayRegionalURL - READ-ONLY; Gateway URL of the API Management service in the Region. + GatewayRegionalURL *string `json:"gatewayRegionalUrl,omitempty"` + // DisableGateway - Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in this additional location. + DisableGateway *bool `json:"disableGateway,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdditionalLocation. +func (al AdditionalLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if al.Location != nil { + objectMap["location"] = al.Location + } + if al.Sku != nil { + objectMap["sku"] = al.Sku + } + if al.Zones != nil { + objectMap["zones"] = al.Zones + } + if al.PublicIPAddressID != nil { + objectMap["publicIpAddressId"] = al.PublicIPAddressID + } + if al.VirtualNetworkConfiguration != nil { + objectMap["virtualNetworkConfiguration"] = al.VirtualNetworkConfiguration + } + if al.DisableGateway != nil { + objectMap["disableGateway"] = al.DisableGateway + } + return json.Marshal(objectMap) +} + +// APICollection paged API list representation. +type APICollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]APIContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for APICollection. +func (ac APICollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ac.Count != nil { + objectMap["count"] = ac.Count + } + return json.Marshal(objectMap) +} + +// APICollectionIterator provides access to a complete listing of APIContract values. +type APICollectionIterator struct { + i int + page APICollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *APICollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APICollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *APICollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter APICollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter APICollectionIterator) Response() APICollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter APICollectionIterator) Value() APIContract { + if !iter.page.NotDone() { + return APIContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the APICollectionIterator type. +func NewAPICollectionIterator(page APICollectionPage) APICollectionIterator { + return APICollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ac APICollection) IsEmpty() bool { + return ac.Value == nil || len(*ac.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ac APICollection) hasNextLink() bool { + return ac.NextLink != nil && len(*ac.NextLink) != 0 +} + +// aPICollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ac APICollection) aPICollectionPreparer(ctx context.Context) (*http.Request, error) { + if !ac.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ac.NextLink))) +} + +// APICollectionPage contains a page of APIContract values. +type APICollectionPage struct { + fn func(context.Context, APICollection) (APICollection, error) + ac APICollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *APICollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APICollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ac) + if err != nil { + return err + } + page.ac = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *APICollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page APICollectionPage) NotDone() bool { + return !page.ac.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page APICollectionPage) Response() APICollection { + return page.ac +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page APICollectionPage) Values() []APIContract { + if page.ac.IsEmpty() { + return nil + } + return *page.ac.Value +} + +// Creates a new instance of the APICollectionPage type. +func NewAPICollectionPage(cur APICollection, getNextPage func(context.Context, APICollection) (APICollection, error)) APICollectionPage { + return APICollectionPage{ + fn: getNextPage, + ac: cur, + } +} + +// APIContactInformation API contact information +type APIContactInformation struct { + // Name - The identifying name of the contact person/organization + Name *string `json:"name,omitempty"` + // URL - The URL pointing to the contact information. MUST be in the format of a URL + URL *string `json:"url,omitempty"` + // Email - The email address of the contact person/organization. MUST be in the format of an email address + Email *string `json:"email,omitempty"` +} + +// APIContract API details. +type APIContract struct { + autorest.Response `json:"-"` + // APIContractProperties - API entity contract properties. + *APIContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIContract. +func (ac APIContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ac.APIContractProperties != nil { + objectMap["properties"] = ac.APIContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for APIContract struct. +func (ac *APIContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var APIContractProperties APIContractProperties + err = json.Unmarshal(*v, &APIContractProperties) + if err != nil { + return err + } + ac.APIContractProperties = &APIContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ac.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ac.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ac.Type = &typeVar + } + } + } + + return nil +} + +// APIContractProperties API Entity Properties +type APIContractProperties struct { + // SourceAPIID - API identifier of the source API. + SourceAPIID *string `json:"sourceApiId,omitempty"` + // DisplayName - API name. Must be 1 to 300 characters long. + DisplayName *string `json:"displayName,omitempty"` + // ServiceURL - Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long. + ServiceURL *string `json:"serviceUrl,omitempty"` + // Path - Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the API endpoint base URL specified during the service instance creation to form a public URL for this API. + Path *string `json:"path,omitempty"` + // Protocols - Describes on which protocols the operations in this API can be invoked. + Protocols *[]Protocol `json:"protocols,omitempty"` + // APIVersionSet - Version set details + APIVersionSet *APIVersionSetContractDetails `json:"apiVersionSet,omitempty"` + // Description - Description of the API. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // AuthenticationSettings - Collection of authentication settings included into this API. + AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` + // SubscriptionKeyParameterNames - Protocols over which API is made available. + SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` + // APIType - Type of API. Possible values include: 'APITypeHTTP', 'APITypeSoap', 'APITypeWebsocket' + APIType APIType `json:"type,omitempty"` + // APIRevision - Describes the revision of the API. If no value is provided, default revision 1 is created + APIRevision *string `json:"apiRevision,omitempty"` + // APIVersion - Indicates the version identifier of the API if the API is versioned + APIVersion *string `json:"apiVersion,omitempty"` + // IsCurrent - Indicates if API revision is current api revision. + IsCurrent *bool `json:"isCurrent,omitempty"` + // IsOnline - READ-ONLY; Indicates if API revision is accessible via the gateway. + IsOnline *bool `json:"isOnline,omitempty"` + // APIRevisionDescription - Description of the API Revision. + APIRevisionDescription *string `json:"apiRevisionDescription,omitempty"` + // APIVersionDescription - Description of the API Version. + APIVersionDescription *string `json:"apiVersionDescription,omitempty"` + // APIVersionSetID - A resource identifier for the related ApiVersionSet. + APIVersionSetID *string `json:"apiVersionSetId,omitempty"` + // SubscriptionRequired - Specifies whether an API or Product subscription is required for accessing the API. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + // TermsOfServiceURL - A URL to the Terms of Service for the API. MUST be in the format of a URL. + TermsOfServiceURL *string `json:"termsOfServiceUrl,omitempty"` + // Contact - Contact information for the API. + Contact *APIContactInformation `json:"contact,omitempty"` + // License - License information for the API. + License *APILicenseInformation `json:"license,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIContractProperties. +func (acp APIContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if acp.SourceAPIID != nil { + objectMap["sourceApiId"] = acp.SourceAPIID + } + if acp.DisplayName != nil { + objectMap["displayName"] = acp.DisplayName + } + if acp.ServiceURL != nil { + objectMap["serviceUrl"] = acp.ServiceURL + } + if acp.Path != nil { + objectMap["path"] = acp.Path + } + if acp.Protocols != nil { + objectMap["protocols"] = acp.Protocols + } + if acp.APIVersionSet != nil { + objectMap["apiVersionSet"] = acp.APIVersionSet + } + if acp.Description != nil { + objectMap["description"] = acp.Description + } + if acp.AuthenticationSettings != nil { + objectMap["authenticationSettings"] = acp.AuthenticationSettings + } + if acp.SubscriptionKeyParameterNames != nil { + objectMap["subscriptionKeyParameterNames"] = acp.SubscriptionKeyParameterNames + } + if acp.APIType != "" { + objectMap["type"] = acp.APIType + } + if acp.APIRevision != nil { + objectMap["apiRevision"] = acp.APIRevision + } + if acp.APIVersion != nil { + objectMap["apiVersion"] = acp.APIVersion + } + if acp.IsCurrent != nil { + objectMap["isCurrent"] = acp.IsCurrent + } + if acp.APIRevisionDescription != nil { + objectMap["apiRevisionDescription"] = acp.APIRevisionDescription + } + if acp.APIVersionDescription != nil { + objectMap["apiVersionDescription"] = acp.APIVersionDescription + } + if acp.APIVersionSetID != nil { + objectMap["apiVersionSetId"] = acp.APIVersionSetID + } + if acp.SubscriptionRequired != nil { + objectMap["subscriptionRequired"] = acp.SubscriptionRequired + } + if acp.TermsOfServiceURL != nil { + objectMap["termsOfServiceUrl"] = acp.TermsOfServiceURL + } + if acp.Contact != nil { + objectMap["contact"] = acp.Contact + } + if acp.License != nil { + objectMap["license"] = acp.License + } + return json.Marshal(objectMap) +} + +// APIContractUpdateProperties API update contract properties. +type APIContractUpdateProperties struct { + // DisplayName - API name. + DisplayName *string `json:"displayName,omitempty"` + // ServiceURL - Absolute URL of the backend service implementing this API. + ServiceURL *string `json:"serviceUrl,omitempty"` + // Path - Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the API endpoint base URL specified during the service instance creation to form a public URL for this API. + Path *string `json:"path,omitempty"` + // Protocols - Describes on which protocols the operations in this API can be invoked. + Protocols *[]Protocol `json:"protocols,omitempty"` + // Description - Description of the API. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // AuthenticationSettings - Collection of authentication settings included into this API. + AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` + // SubscriptionKeyParameterNames - Protocols over which API is made available. + SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` + // APIType - Type of API. Possible values include: 'APITypeHTTP', 'APITypeSoap', 'APITypeWebsocket' + APIType APIType `json:"type,omitempty"` + // APIRevision - Describes the revision of the API. If no value is provided, default revision 1 is created + APIRevision *string `json:"apiRevision,omitempty"` + // APIVersion - Indicates the version identifier of the API if the API is versioned + APIVersion *string `json:"apiVersion,omitempty"` + // IsCurrent - Indicates if API revision is current api revision. + IsCurrent *bool `json:"isCurrent,omitempty"` + // IsOnline - READ-ONLY; Indicates if API revision is accessible via the gateway. + IsOnline *bool `json:"isOnline,omitempty"` + // APIRevisionDescription - Description of the API Revision. + APIRevisionDescription *string `json:"apiRevisionDescription,omitempty"` + // APIVersionDescription - Description of the API Version. + APIVersionDescription *string `json:"apiVersionDescription,omitempty"` + // APIVersionSetID - A resource identifier for the related ApiVersionSet. + APIVersionSetID *string `json:"apiVersionSetId,omitempty"` + // SubscriptionRequired - Specifies whether an API or Product subscription is required for accessing the API. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + // TermsOfServiceURL - A URL to the Terms of Service for the API. MUST be in the format of a URL. + TermsOfServiceURL *string `json:"termsOfServiceUrl,omitempty"` + // Contact - Contact information for the API. + Contact *APIContactInformation `json:"contact,omitempty"` + // License - License information for the API. + License *APILicenseInformation `json:"license,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIContractUpdateProperties. +func (acup APIContractUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if acup.DisplayName != nil { + objectMap["displayName"] = acup.DisplayName + } + if acup.ServiceURL != nil { + objectMap["serviceUrl"] = acup.ServiceURL + } + if acup.Path != nil { + objectMap["path"] = acup.Path + } + if acup.Protocols != nil { + objectMap["protocols"] = acup.Protocols + } + if acup.Description != nil { + objectMap["description"] = acup.Description + } + if acup.AuthenticationSettings != nil { + objectMap["authenticationSettings"] = acup.AuthenticationSettings + } + if acup.SubscriptionKeyParameterNames != nil { + objectMap["subscriptionKeyParameterNames"] = acup.SubscriptionKeyParameterNames + } + if acup.APIType != "" { + objectMap["type"] = acup.APIType + } + if acup.APIRevision != nil { + objectMap["apiRevision"] = acup.APIRevision + } + if acup.APIVersion != nil { + objectMap["apiVersion"] = acup.APIVersion + } + if acup.IsCurrent != nil { + objectMap["isCurrent"] = acup.IsCurrent + } + if acup.APIRevisionDescription != nil { + objectMap["apiRevisionDescription"] = acup.APIRevisionDescription + } + if acup.APIVersionDescription != nil { + objectMap["apiVersionDescription"] = acup.APIVersionDescription + } + if acup.APIVersionSetID != nil { + objectMap["apiVersionSetId"] = acup.APIVersionSetID + } + if acup.SubscriptionRequired != nil { + objectMap["subscriptionRequired"] = acup.SubscriptionRequired + } + if acup.TermsOfServiceURL != nil { + objectMap["termsOfServiceUrl"] = acup.TermsOfServiceURL + } + if acup.Contact != nil { + objectMap["contact"] = acup.Contact + } + if acup.License != nil { + objectMap["license"] = acup.License + } + return json.Marshal(objectMap) +} + +// APICreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type APICreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(APIClient) (APIContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *APICreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for APICreateOrUpdateFuture.Result. +func (future *APICreateOrUpdateFuture) result(client APIClient) (ac APIContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APICreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ac.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.APICreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ac.Response.Response, err = future.GetResult(sender); err == nil && ac.Response.Response.StatusCode != http.StatusNoContent { + ac, err = client.CreateOrUpdateResponder(ac.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APICreateOrUpdateFuture", "Result", ac.Response.Response, "Failure responding to request") + } + } + return +} + +// APICreateOrUpdateParameter API Create or Update Parameters. +type APICreateOrUpdateParameter struct { + // APICreateOrUpdateProperties - API entity create of update properties. + *APICreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for APICreateOrUpdateParameter. +func (acoup APICreateOrUpdateParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if acoup.APICreateOrUpdateProperties != nil { + objectMap["properties"] = acoup.APICreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for APICreateOrUpdateParameter struct. +func (acoup *APICreateOrUpdateParameter) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var APICreateOrUpdateProperties APICreateOrUpdateProperties + err = json.Unmarshal(*v, &APICreateOrUpdateProperties) + if err != nil { + return err + } + acoup.APICreateOrUpdateProperties = &APICreateOrUpdateProperties + } + } + } + + return nil +} + +// APICreateOrUpdateProperties API Create or Update Properties. +type APICreateOrUpdateProperties struct { + // Value - Content value when Importing an API. + Value *string `json:"value,omitempty"` + // Format - Format of the Content in which the API is getting imported. Possible values include: 'ContentFormatWadlXML', 'ContentFormatWadlLinkJSON', 'ContentFormatSwaggerJSON', 'ContentFormatSwaggerLinkJSON', 'ContentFormatWsdl', 'ContentFormatWsdlLink', 'ContentFormatOpenapi', 'ContentFormatOpenapijson', 'ContentFormatOpenapiLink', 'ContentFormatOpenapijsonLink' + Format ContentFormat `json:"format,omitempty"` + // WsdlSelector - Criteria to limit import of WSDL to a subset of the document. + WsdlSelector *APICreateOrUpdatePropertiesWsdlSelector `json:"wsdlSelector,omitempty"` + // SoapAPIType - Type of API to create. + // * `http` creates a REST API + // * `soap` creates a SOAP pass-through API + // * `websocket` creates websocket API. Possible values include: 'SoapAPITypeSoapToRest', 'SoapAPITypeSoapPassThrough', 'SoapAPITypeWebSocket' + SoapAPIType SoapAPIType `json:"apiType,omitempty"` + // SourceAPIID - API identifier of the source API. + SourceAPIID *string `json:"sourceApiId,omitempty"` + // DisplayName - API name. Must be 1 to 300 characters long. + DisplayName *string `json:"displayName,omitempty"` + // ServiceURL - Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long. + ServiceURL *string `json:"serviceUrl,omitempty"` + // Path - Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the API endpoint base URL specified during the service instance creation to form a public URL for this API. + Path *string `json:"path,omitempty"` + // Protocols - Describes on which protocols the operations in this API can be invoked. + Protocols *[]Protocol `json:"protocols,omitempty"` + // APIVersionSet - Version set details + APIVersionSet *APIVersionSetContractDetails `json:"apiVersionSet,omitempty"` + // Description - Description of the API. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // AuthenticationSettings - Collection of authentication settings included into this API. + AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` + // SubscriptionKeyParameterNames - Protocols over which API is made available. + SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` + // APIType - Type of API. Possible values include: 'APITypeHTTP', 'APITypeSoap', 'APITypeWebsocket' + APIType APIType `json:"type,omitempty"` + // APIRevision - Describes the revision of the API. If no value is provided, default revision 1 is created + APIRevision *string `json:"apiRevision,omitempty"` + // APIVersion - Indicates the version identifier of the API if the API is versioned + APIVersion *string `json:"apiVersion,omitempty"` + // IsCurrent - Indicates if API revision is current api revision. + IsCurrent *bool `json:"isCurrent,omitempty"` + // IsOnline - READ-ONLY; Indicates if API revision is accessible via the gateway. + IsOnline *bool `json:"isOnline,omitempty"` + // APIRevisionDescription - Description of the API Revision. + APIRevisionDescription *string `json:"apiRevisionDescription,omitempty"` + // APIVersionDescription - Description of the API Version. + APIVersionDescription *string `json:"apiVersionDescription,omitempty"` + // APIVersionSetID - A resource identifier for the related ApiVersionSet. + APIVersionSetID *string `json:"apiVersionSetId,omitempty"` + // SubscriptionRequired - Specifies whether an API or Product subscription is required for accessing the API. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + // TermsOfServiceURL - A URL to the Terms of Service for the API. MUST be in the format of a URL. + TermsOfServiceURL *string `json:"termsOfServiceUrl,omitempty"` + // Contact - Contact information for the API. + Contact *APIContactInformation `json:"contact,omitempty"` + // License - License information for the API. + License *APILicenseInformation `json:"license,omitempty"` +} + +// MarshalJSON is the custom marshaler for APICreateOrUpdateProperties. +func (acoup APICreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if acoup.Value != nil { + objectMap["value"] = acoup.Value + } + if acoup.Format != "" { + objectMap["format"] = acoup.Format + } + if acoup.WsdlSelector != nil { + objectMap["wsdlSelector"] = acoup.WsdlSelector + } + if acoup.SoapAPIType != "" { + objectMap["apiType"] = acoup.SoapAPIType + } + if acoup.SourceAPIID != nil { + objectMap["sourceApiId"] = acoup.SourceAPIID + } + if acoup.DisplayName != nil { + objectMap["displayName"] = acoup.DisplayName + } + if acoup.ServiceURL != nil { + objectMap["serviceUrl"] = acoup.ServiceURL + } + if acoup.Path != nil { + objectMap["path"] = acoup.Path + } + if acoup.Protocols != nil { + objectMap["protocols"] = acoup.Protocols + } + if acoup.APIVersionSet != nil { + objectMap["apiVersionSet"] = acoup.APIVersionSet + } + if acoup.Description != nil { + objectMap["description"] = acoup.Description + } + if acoup.AuthenticationSettings != nil { + objectMap["authenticationSettings"] = acoup.AuthenticationSettings + } + if acoup.SubscriptionKeyParameterNames != nil { + objectMap["subscriptionKeyParameterNames"] = acoup.SubscriptionKeyParameterNames + } + if acoup.APIType != "" { + objectMap["type"] = acoup.APIType + } + if acoup.APIRevision != nil { + objectMap["apiRevision"] = acoup.APIRevision + } + if acoup.APIVersion != nil { + objectMap["apiVersion"] = acoup.APIVersion + } + if acoup.IsCurrent != nil { + objectMap["isCurrent"] = acoup.IsCurrent + } + if acoup.APIRevisionDescription != nil { + objectMap["apiRevisionDescription"] = acoup.APIRevisionDescription + } + if acoup.APIVersionDescription != nil { + objectMap["apiVersionDescription"] = acoup.APIVersionDescription + } + if acoup.APIVersionSetID != nil { + objectMap["apiVersionSetId"] = acoup.APIVersionSetID + } + if acoup.SubscriptionRequired != nil { + objectMap["subscriptionRequired"] = acoup.SubscriptionRequired + } + if acoup.TermsOfServiceURL != nil { + objectMap["termsOfServiceUrl"] = acoup.TermsOfServiceURL + } + if acoup.Contact != nil { + objectMap["contact"] = acoup.Contact + } + if acoup.License != nil { + objectMap["license"] = acoup.License + } + return json.Marshal(objectMap) +} + +// APICreateOrUpdatePropertiesWsdlSelector criteria to limit import of WSDL to a subset of the document. +type APICreateOrUpdatePropertiesWsdlSelector struct { + // WsdlServiceName - Name of service to import from WSDL + WsdlServiceName *string `json:"wsdlServiceName,omitempty"` + // WsdlEndpointName - Name of endpoint(port) to import from WSDL + WsdlEndpointName *string `json:"wsdlEndpointName,omitempty"` +} + +// APIEntityBaseContract API base contract details. +type APIEntityBaseContract struct { + // Description - Description of the API. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // AuthenticationSettings - Collection of authentication settings included into this API. + AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` + // SubscriptionKeyParameterNames - Protocols over which API is made available. + SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` + // APIType - Type of API. Possible values include: 'APITypeHTTP', 'APITypeSoap', 'APITypeWebsocket' + APIType APIType `json:"type,omitempty"` + // APIRevision - Describes the revision of the API. If no value is provided, default revision 1 is created + APIRevision *string `json:"apiRevision,omitempty"` + // APIVersion - Indicates the version identifier of the API if the API is versioned + APIVersion *string `json:"apiVersion,omitempty"` + // IsCurrent - Indicates if API revision is current api revision. + IsCurrent *bool `json:"isCurrent,omitempty"` + // IsOnline - READ-ONLY; Indicates if API revision is accessible via the gateway. + IsOnline *bool `json:"isOnline,omitempty"` + // APIRevisionDescription - Description of the API Revision. + APIRevisionDescription *string `json:"apiRevisionDescription,omitempty"` + // APIVersionDescription - Description of the API Version. + APIVersionDescription *string `json:"apiVersionDescription,omitempty"` + // APIVersionSetID - A resource identifier for the related ApiVersionSet. + APIVersionSetID *string `json:"apiVersionSetId,omitempty"` + // SubscriptionRequired - Specifies whether an API or Product subscription is required for accessing the API. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + // TermsOfServiceURL - A URL to the Terms of Service for the API. MUST be in the format of a URL. + TermsOfServiceURL *string `json:"termsOfServiceUrl,omitempty"` + // Contact - Contact information for the API. + Contact *APIContactInformation `json:"contact,omitempty"` + // License - License information for the API. + License *APILicenseInformation `json:"license,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIEntityBaseContract. +func (aebc APIEntityBaseContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aebc.Description != nil { + objectMap["description"] = aebc.Description + } + if aebc.AuthenticationSettings != nil { + objectMap["authenticationSettings"] = aebc.AuthenticationSettings + } + if aebc.SubscriptionKeyParameterNames != nil { + objectMap["subscriptionKeyParameterNames"] = aebc.SubscriptionKeyParameterNames + } + if aebc.APIType != "" { + objectMap["type"] = aebc.APIType + } + if aebc.APIRevision != nil { + objectMap["apiRevision"] = aebc.APIRevision + } + if aebc.APIVersion != nil { + objectMap["apiVersion"] = aebc.APIVersion + } + if aebc.IsCurrent != nil { + objectMap["isCurrent"] = aebc.IsCurrent + } + if aebc.APIRevisionDescription != nil { + objectMap["apiRevisionDescription"] = aebc.APIRevisionDescription + } + if aebc.APIVersionDescription != nil { + objectMap["apiVersionDescription"] = aebc.APIVersionDescription + } + if aebc.APIVersionSetID != nil { + objectMap["apiVersionSetId"] = aebc.APIVersionSetID + } + if aebc.SubscriptionRequired != nil { + objectMap["subscriptionRequired"] = aebc.SubscriptionRequired + } + if aebc.TermsOfServiceURL != nil { + objectMap["termsOfServiceUrl"] = aebc.TermsOfServiceURL + } + if aebc.Contact != nil { + objectMap["contact"] = aebc.Contact + } + if aebc.License != nil { + objectMap["license"] = aebc.License + } + return json.Marshal(objectMap) +} + +// APIExportResult API Export result. +type APIExportResult struct { + autorest.Response `json:"-"` + // ID - ResourceId of the API which was exported. + ID *string `json:"id,omitempty"` + // ExportResultFormat - Format in which the API Details are exported to the Storage Blob with Sas Key valid for 5 minutes. Possible values include: 'ExportResultFormatSwagger', 'ExportResultFormatWsdl', 'ExportResultFormatWadl', 'ExportResultFormatOpenAPI' + ExportResultFormat ExportResultFormat `json:"format,omitempty"` + // Value - The object defining the schema of the exported API Detail + Value *APIExportResultValue `json:"value,omitempty"` +} + +// APIExportResultValue the object defining the schema of the exported API Detail +type APIExportResultValue struct { + // Link - Link to the Storage Blob containing the result of the export operation. The Blob Uri is only valid for 5 minutes. + Link *string `json:"link,omitempty"` +} + +// APILicenseInformation API license information +type APILicenseInformation struct { + // Name - The license name used for the API + Name *string `json:"name,omitempty"` + // URL - A URL to the license used for the API. MUST be in the format of a URL + URL *string `json:"url,omitempty"` +} + +// ApimResource the Resource definition. +type ApimResource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource is set to Microsoft.ApiManagement. + Type *string `json:"type,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ApimResource. +func (ar ApimResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ar.Tags != nil { + objectMap["tags"] = ar.Tags + } + return json.Marshal(objectMap) +} + +// APIReleaseCollection paged ApiRelease list representation. +type APIReleaseCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]APIReleaseContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIReleaseCollection. +func (arc APIReleaseCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arc.Count != nil { + objectMap["count"] = arc.Count + } + return json.Marshal(objectMap) +} + +// APIReleaseCollectionIterator provides access to a complete listing of APIReleaseContract values. +type APIReleaseCollectionIterator struct { + i int + page APIReleaseCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *APIReleaseCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *APIReleaseCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter APIReleaseCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter APIReleaseCollectionIterator) Response() APIReleaseCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter APIReleaseCollectionIterator) Value() APIReleaseContract { + if !iter.page.NotDone() { + return APIReleaseContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the APIReleaseCollectionIterator type. +func NewAPIReleaseCollectionIterator(page APIReleaseCollectionPage) APIReleaseCollectionIterator { + return APIReleaseCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (arc APIReleaseCollection) IsEmpty() bool { + return arc.Value == nil || len(*arc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (arc APIReleaseCollection) hasNextLink() bool { + return arc.NextLink != nil && len(*arc.NextLink) != 0 +} + +// aPIReleaseCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (arc APIReleaseCollection) aPIReleaseCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !arc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(arc.NextLink))) +} + +// APIReleaseCollectionPage contains a page of APIReleaseContract values. +type APIReleaseCollectionPage struct { + fn func(context.Context, APIReleaseCollection) (APIReleaseCollection, error) + arc APIReleaseCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *APIReleaseCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.arc) + if err != nil { + return err + } + page.arc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *APIReleaseCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page APIReleaseCollectionPage) NotDone() bool { + return !page.arc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page APIReleaseCollectionPage) Response() APIReleaseCollection { + return page.arc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page APIReleaseCollectionPage) Values() []APIReleaseContract { + if page.arc.IsEmpty() { + return nil + } + return *page.arc.Value +} + +// Creates a new instance of the APIReleaseCollectionPage type. +func NewAPIReleaseCollectionPage(cur APIReleaseCollection, getNextPage func(context.Context, APIReleaseCollection) (APIReleaseCollection, error)) APIReleaseCollectionPage { + return APIReleaseCollectionPage{ + fn: getNextPage, + arc: cur, + } +} + +// APIReleaseContract apiRelease details. +type APIReleaseContract struct { + autorest.Response `json:"-"` + // APIReleaseContractProperties - ApiRelease entity contract properties. + *APIReleaseContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIReleaseContract. +func (arc APIReleaseContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arc.APIReleaseContractProperties != nil { + objectMap["properties"] = arc.APIReleaseContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for APIReleaseContract struct. +func (arc *APIReleaseContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var APIReleaseContractProperties APIReleaseContractProperties + err = json.Unmarshal(*v, &APIReleaseContractProperties) + if err != nil { + return err + } + arc.APIReleaseContractProperties = &APIReleaseContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + arc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + arc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + arc.Type = &typeVar + } + } + } + + return nil +} + +// APIReleaseContractProperties API Release details +type APIReleaseContractProperties struct { + // APIID - Identifier of the API the release belongs to. + APIID *string `json:"apiId,omitempty"` + // CreatedDateTime - READ-ONLY; The time the API was released. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + CreatedDateTime *date.Time `json:"createdDateTime,omitempty"` + // UpdatedDateTime - READ-ONLY; The time the API release was updated. + UpdatedDateTime *date.Time `json:"updatedDateTime,omitempty"` + // Notes - Release Notes + Notes *string `json:"notes,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIReleaseContractProperties. +func (arcp APIReleaseContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arcp.APIID != nil { + objectMap["apiId"] = arcp.APIID + } + if arcp.Notes != nil { + objectMap["notes"] = arcp.Notes + } + return json.Marshal(objectMap) +} + +// APIRevisionCollection paged API Revision list representation. +type APIRevisionCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]APIRevisionContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIRevisionCollection. +func (arc APIRevisionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arc.Count != nil { + objectMap["count"] = arc.Count + } + return json.Marshal(objectMap) +} + +// APIRevisionCollectionIterator provides access to a complete listing of APIRevisionContract values. +type APIRevisionCollectionIterator struct { + i int + page APIRevisionCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *APIRevisionCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIRevisionCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *APIRevisionCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter APIRevisionCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter APIRevisionCollectionIterator) Response() APIRevisionCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter APIRevisionCollectionIterator) Value() APIRevisionContract { + if !iter.page.NotDone() { + return APIRevisionContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the APIRevisionCollectionIterator type. +func NewAPIRevisionCollectionIterator(page APIRevisionCollectionPage) APIRevisionCollectionIterator { + return APIRevisionCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (arc APIRevisionCollection) IsEmpty() bool { + return arc.Value == nil || len(*arc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (arc APIRevisionCollection) hasNextLink() bool { + return arc.NextLink != nil && len(*arc.NextLink) != 0 +} + +// aPIRevisionCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (arc APIRevisionCollection) aPIRevisionCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !arc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(arc.NextLink))) +} + +// APIRevisionCollectionPage contains a page of APIRevisionContract values. +type APIRevisionCollectionPage struct { + fn func(context.Context, APIRevisionCollection) (APIRevisionCollection, error) + arc APIRevisionCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *APIRevisionCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIRevisionCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.arc) + if err != nil { + return err + } + page.arc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *APIRevisionCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page APIRevisionCollectionPage) NotDone() bool { + return !page.arc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page APIRevisionCollectionPage) Response() APIRevisionCollection { + return page.arc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page APIRevisionCollectionPage) Values() []APIRevisionContract { + if page.arc.IsEmpty() { + return nil + } + return *page.arc.Value +} + +// Creates a new instance of the APIRevisionCollectionPage type. +func NewAPIRevisionCollectionPage(cur APIRevisionCollection, getNextPage func(context.Context, APIRevisionCollection) (APIRevisionCollection, error)) APIRevisionCollectionPage { + return APIRevisionCollectionPage{ + fn: getNextPage, + arc: cur, + } +} + +// APIRevisionContract summary of revision metadata. +type APIRevisionContract struct { + // APIID - READ-ONLY; Identifier of the API Revision. + APIID *string `json:"apiId,omitempty"` + // APIRevision - READ-ONLY; Revision number of API. + APIRevision *string `json:"apiRevision,omitempty"` + // CreatedDateTime - READ-ONLY; The time the API Revision was created. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + CreatedDateTime *date.Time `json:"createdDateTime,omitempty"` + // UpdatedDateTime - READ-ONLY; The time the API Revision were updated. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + UpdatedDateTime *date.Time `json:"updatedDateTime,omitempty"` + // Description - READ-ONLY; Description of the API Revision. + Description *string `json:"description,omitempty"` + // PrivateURL - READ-ONLY; Gateway URL for accessing the non-current API Revision. + PrivateURL *string `json:"privateUrl,omitempty"` + // IsOnline - READ-ONLY; Indicates if API revision is the current api revision. + IsOnline *bool `json:"isOnline,omitempty"` + // IsCurrent - READ-ONLY; Indicates if API revision is accessible via the gateway. + IsCurrent *bool `json:"isCurrent,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIRevisionContract. +func (arc APIRevisionContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// APIRevisionInfoContract object used to create an API Revision or Version based on an existing API +// Revision +type APIRevisionInfoContract struct { + // SourceAPIID - Resource identifier of API to be used to create the revision from. + SourceAPIID *string `json:"sourceApiId,omitempty"` + // APIVersionName - Version identifier for the new API Version. + APIVersionName *string `json:"apiVersionName,omitempty"` + // APIRevisionDescription - Description of new API Revision. + APIRevisionDescription *string `json:"apiRevisionDescription,omitempty"` + // APIVersionSet - Version set details + APIVersionSet *APIVersionSetContractDetails `json:"apiVersionSet,omitempty"` +} + +// APISchemaCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type APISchemaCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(APISchemaClient) (SchemaContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *APISchemaCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for APISchemaCreateOrUpdateFuture.Result. +func (future *APISchemaCreateOrUpdateFuture) result(client APISchemaClient) (sc SchemaContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.APISchemaCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sc.Response.Response, err = future.GetResult(sender); err == nil && sc.Response.Response.StatusCode != http.StatusNoContent { + sc, err = client.CreateOrUpdateResponder(sc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APISchemaCreateOrUpdateFuture", "Result", sc.Response.Response, "Failure responding to request") + } + } + return +} + +// APITagResourceContractProperties API contract properties for the Tag Resources. +type APITagResourceContractProperties struct { + // ID - API identifier in the form /apis/{apiId}. + ID *string `json:"id,omitempty"` + // Name - API name. + Name *string `json:"name,omitempty"` + // ServiceURL - Absolute URL of the backend service implementing this API. + ServiceURL *string `json:"serviceUrl,omitempty"` + // Path - Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the API endpoint base URL specified during the service instance creation to form a public URL for this API. + Path *string `json:"path,omitempty"` + // Protocols - Describes on which protocols the operations in this API can be invoked. + Protocols *[]Protocol `json:"protocols,omitempty"` + // Description - Description of the API. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // AuthenticationSettings - Collection of authentication settings included into this API. + AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` + // SubscriptionKeyParameterNames - Protocols over which API is made available. + SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` + // APIType - Type of API. Possible values include: 'APITypeHTTP', 'APITypeSoap', 'APITypeWebsocket' + APIType APIType `json:"type,omitempty"` + // APIRevision - Describes the revision of the API. If no value is provided, default revision 1 is created + APIRevision *string `json:"apiRevision,omitempty"` + // APIVersion - Indicates the version identifier of the API if the API is versioned + APIVersion *string `json:"apiVersion,omitempty"` + // IsCurrent - Indicates if API revision is current api revision. + IsCurrent *bool `json:"isCurrent,omitempty"` + // IsOnline - READ-ONLY; Indicates if API revision is accessible via the gateway. + IsOnline *bool `json:"isOnline,omitempty"` + // APIRevisionDescription - Description of the API Revision. + APIRevisionDescription *string `json:"apiRevisionDescription,omitempty"` + // APIVersionDescription - Description of the API Version. + APIVersionDescription *string `json:"apiVersionDescription,omitempty"` + // APIVersionSetID - A resource identifier for the related ApiVersionSet. + APIVersionSetID *string `json:"apiVersionSetId,omitempty"` + // SubscriptionRequired - Specifies whether an API or Product subscription is required for accessing the API. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + // TermsOfServiceURL - A URL to the Terms of Service for the API. MUST be in the format of a URL. + TermsOfServiceURL *string `json:"termsOfServiceUrl,omitempty"` + // Contact - Contact information for the API. + Contact *APIContactInformation `json:"contact,omitempty"` + // License - License information for the API. + License *APILicenseInformation `json:"license,omitempty"` +} + +// MarshalJSON is the custom marshaler for APITagResourceContractProperties. +func (atrcp APITagResourceContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atrcp.ID != nil { + objectMap["id"] = atrcp.ID + } + if atrcp.Name != nil { + objectMap["name"] = atrcp.Name + } + if atrcp.ServiceURL != nil { + objectMap["serviceUrl"] = atrcp.ServiceURL + } + if atrcp.Path != nil { + objectMap["path"] = atrcp.Path + } + if atrcp.Protocols != nil { + objectMap["protocols"] = atrcp.Protocols + } + if atrcp.Description != nil { + objectMap["description"] = atrcp.Description + } + if atrcp.AuthenticationSettings != nil { + objectMap["authenticationSettings"] = atrcp.AuthenticationSettings + } + if atrcp.SubscriptionKeyParameterNames != nil { + objectMap["subscriptionKeyParameterNames"] = atrcp.SubscriptionKeyParameterNames + } + if atrcp.APIType != "" { + objectMap["type"] = atrcp.APIType + } + if atrcp.APIRevision != nil { + objectMap["apiRevision"] = atrcp.APIRevision + } + if atrcp.APIVersion != nil { + objectMap["apiVersion"] = atrcp.APIVersion + } + if atrcp.IsCurrent != nil { + objectMap["isCurrent"] = atrcp.IsCurrent + } + if atrcp.APIRevisionDescription != nil { + objectMap["apiRevisionDescription"] = atrcp.APIRevisionDescription + } + if atrcp.APIVersionDescription != nil { + objectMap["apiVersionDescription"] = atrcp.APIVersionDescription + } + if atrcp.APIVersionSetID != nil { + objectMap["apiVersionSetId"] = atrcp.APIVersionSetID + } + if atrcp.SubscriptionRequired != nil { + objectMap["subscriptionRequired"] = atrcp.SubscriptionRequired + } + if atrcp.TermsOfServiceURL != nil { + objectMap["termsOfServiceUrl"] = atrcp.TermsOfServiceURL + } + if atrcp.Contact != nil { + objectMap["contact"] = atrcp.Contact + } + if atrcp.License != nil { + objectMap["license"] = atrcp.License + } + return json.Marshal(objectMap) +} + +// APIUpdateContract API update contract details. +type APIUpdateContract struct { + // APIContractUpdateProperties - Properties of the API entity that can be updated. + *APIContractUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIUpdateContract. +func (auc APIUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if auc.APIContractUpdateProperties != nil { + objectMap["properties"] = auc.APIContractUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for APIUpdateContract struct. +func (auc *APIUpdateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var APIContractUpdateProperties APIContractUpdateProperties + err = json.Unmarshal(*v, &APIContractUpdateProperties) + if err != nil { + return err + } + auc.APIContractUpdateProperties = &APIContractUpdateProperties + } + } + } + + return nil +} + +// APIVersionConstraint control Plane Apis version constraint for the API Management service. +type APIVersionConstraint struct { + // MinAPIVersion - Limit control plane API calls to API Management service with version equal to or newer than this value. + MinAPIVersion *string `json:"minApiVersion,omitempty"` +} + +// APIVersionSetCollection paged API Version Set list representation. +type APIVersionSetCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]APIVersionSetContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// APIVersionSetCollectionIterator provides access to a complete listing of APIVersionSetContract values. +type APIVersionSetCollectionIterator struct { + i int + page APIVersionSetCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *APIVersionSetCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIVersionSetCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *APIVersionSetCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter APIVersionSetCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter APIVersionSetCollectionIterator) Response() APIVersionSetCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter APIVersionSetCollectionIterator) Value() APIVersionSetContract { + if !iter.page.NotDone() { + return APIVersionSetContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the APIVersionSetCollectionIterator type. +func NewAPIVersionSetCollectionIterator(page APIVersionSetCollectionPage) APIVersionSetCollectionIterator { + return APIVersionSetCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (avsc APIVersionSetCollection) IsEmpty() bool { + return avsc.Value == nil || len(*avsc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (avsc APIVersionSetCollection) hasNextLink() bool { + return avsc.NextLink != nil && len(*avsc.NextLink) != 0 +} + +// aPIVersionSetCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (avsc APIVersionSetCollection) aPIVersionSetCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !avsc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(avsc.NextLink))) +} + +// APIVersionSetCollectionPage contains a page of APIVersionSetContract values. +type APIVersionSetCollectionPage struct { + fn func(context.Context, APIVersionSetCollection) (APIVersionSetCollection, error) + avsc APIVersionSetCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *APIVersionSetCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIVersionSetCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.avsc) + if err != nil { + return err + } + page.avsc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *APIVersionSetCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page APIVersionSetCollectionPage) NotDone() bool { + return !page.avsc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page APIVersionSetCollectionPage) Response() APIVersionSetCollection { + return page.avsc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page APIVersionSetCollectionPage) Values() []APIVersionSetContract { + if page.avsc.IsEmpty() { + return nil + } + return *page.avsc.Value +} + +// Creates a new instance of the APIVersionSetCollectionPage type. +func NewAPIVersionSetCollectionPage(cur APIVersionSetCollection, getNextPage func(context.Context, APIVersionSetCollection) (APIVersionSetCollection, error)) APIVersionSetCollectionPage { + return APIVersionSetCollectionPage{ + fn: getNextPage, + avsc: cur, + } +} + +// APIVersionSetContract API Version Set Contract details. +type APIVersionSetContract struct { + autorest.Response `json:"-"` + // APIVersionSetContractProperties - API VersionSet contract properties. + *APIVersionSetContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIVersionSetContract. +func (avsc APIVersionSetContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if avsc.APIVersionSetContractProperties != nil { + objectMap["properties"] = avsc.APIVersionSetContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for APIVersionSetContract struct. +func (avsc *APIVersionSetContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var APIVersionSetContractProperties APIVersionSetContractProperties + err = json.Unmarshal(*v, &APIVersionSetContractProperties) + if err != nil { + return err + } + avsc.APIVersionSetContractProperties = &APIVersionSetContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + avsc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + avsc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + avsc.Type = &typeVar + } + } + } + + return nil +} + +// APIVersionSetContractDetails an API Version Set contains the common configuration for a set of API +// Versions relating +type APIVersionSetContractDetails struct { + // ID - Identifier for existing API Version Set. Omit this value to create a new Version Set. + ID *string `json:"id,omitempty"` + // Name - The display Name of the API Version Set. + Name *string `json:"name,omitempty"` + // Description - Description of API Version Set. + Description *string `json:"description,omitempty"` + // VersioningScheme - An value that determines where the API Version identifier will be located in a HTTP request. Possible values include: 'VersioningScheme1Segment', 'VersioningScheme1Query', 'VersioningScheme1Header' + VersioningScheme VersioningScheme1 `json:"versioningScheme,omitempty"` + // VersionQueryName - Name of query parameter that indicates the API Version if versioningScheme is set to `query`. + VersionQueryName *string `json:"versionQueryName,omitempty"` + // VersionHeaderName - Name of HTTP header parameter that indicates the API Version if versioningScheme is set to `header`. + VersionHeaderName *string `json:"versionHeaderName,omitempty"` +} + +// APIVersionSetContractProperties properties of an API Version Set. +type APIVersionSetContractProperties struct { + // DisplayName - Name of API Version Set + DisplayName *string `json:"displayName,omitempty"` + // VersioningScheme - An value that determines where the API Version identifier will be located in a HTTP request. Possible values include: 'VersioningSchemeSegment', 'VersioningSchemeQuery', 'VersioningSchemeHeader' + VersioningScheme VersioningScheme `json:"versioningScheme,omitempty"` + // Description - Description of API Version Set. + Description *string `json:"description,omitempty"` + // VersionQueryName - Name of query parameter that indicates the API Version if versioningScheme is set to `query`. + VersionQueryName *string `json:"versionQueryName,omitempty"` + // VersionHeaderName - Name of HTTP header parameter that indicates the API Version if versioningScheme is set to `header`. + VersionHeaderName *string `json:"versionHeaderName,omitempty"` +} + +// APIVersionSetEntityBase API Version set base parameters +type APIVersionSetEntityBase struct { + // Description - Description of API Version Set. + Description *string `json:"description,omitempty"` + // VersionQueryName - Name of query parameter that indicates the API Version if versioningScheme is set to `query`. + VersionQueryName *string `json:"versionQueryName,omitempty"` + // VersionHeaderName - Name of HTTP header parameter that indicates the API Version if versioningScheme is set to `header`. + VersionHeaderName *string `json:"versionHeaderName,omitempty"` +} + +// APIVersionSetUpdateParameters parameters to update or create an API Version Set Contract. +type APIVersionSetUpdateParameters struct { + // APIVersionSetUpdateParametersProperties - Parameters to update or create an API Version Set Contract. + *APIVersionSetUpdateParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIVersionSetUpdateParameters. +func (avsup APIVersionSetUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if avsup.APIVersionSetUpdateParametersProperties != nil { + objectMap["properties"] = avsup.APIVersionSetUpdateParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for APIVersionSetUpdateParameters struct. +func (avsup *APIVersionSetUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var APIVersionSetUpdateParametersProperties APIVersionSetUpdateParametersProperties + err = json.Unmarshal(*v, &APIVersionSetUpdateParametersProperties) + if err != nil { + return err + } + avsup.APIVersionSetUpdateParametersProperties = &APIVersionSetUpdateParametersProperties + } + } + } + + return nil +} + +// APIVersionSetUpdateParametersProperties properties used to create or update an API Version Set. +type APIVersionSetUpdateParametersProperties struct { + // DisplayName - Name of API Version Set + DisplayName *string `json:"displayName,omitempty"` + // VersioningScheme - An value that determines where the API Version identifier will be located in a HTTP request. Possible values include: 'VersioningSchemeSegment', 'VersioningSchemeQuery', 'VersioningSchemeHeader' + VersioningScheme VersioningScheme `json:"versioningScheme,omitempty"` + // Description - Description of API Version Set. + Description *string `json:"description,omitempty"` + // VersionQueryName - Name of query parameter that indicates the API Version if versioningScheme is set to `query`. + VersionQueryName *string `json:"versionQueryName,omitempty"` + // VersionHeaderName - Name of HTTP header parameter that indicates the API Version if versioningScheme is set to `header`. + VersionHeaderName *string `json:"versionHeaderName,omitempty"` +} + +// AssociationContract association entity details. +type AssociationContract struct { + // AssociationContractProperties - Association entity contract properties. + *AssociationContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AssociationContract. +func (ac AssociationContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ac.AssociationContractProperties != nil { + objectMap["properties"] = ac.AssociationContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AssociationContract struct. +func (ac *AssociationContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var associationContractProperties AssociationContractProperties + err = json.Unmarshal(*v, &associationContractProperties) + if err != nil { + return err + } + ac.AssociationContractProperties = &associationContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ac.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ac.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ac.Type = &typeVar + } + } + } + + return nil +} + +// AssociationContractProperties association entity contract properties. +type AssociationContractProperties struct { + // ProvisioningState - Provisioning state. Possible values include: 'ProvisioningStateCreated' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// AuthenticationSettingsContract API Authentication Settings. +type AuthenticationSettingsContract struct { + // OAuth2 - OAuth2 Authentication settings + OAuth2 *OAuth2AuthenticationSettingsContract `json:"oAuth2,omitempty"` + // Openid - OpenID Connect Authentication Settings + Openid *OpenIDAuthenticationSettingsContract `json:"openid,omitempty"` +} + +// AuthorizationServerCollection paged OAuth2 Authorization Servers list representation. +type AuthorizationServerCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]AuthorizationServerContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// AuthorizationServerCollectionIterator provides access to a complete listing of +// AuthorizationServerContract values. +type AuthorizationServerCollectionIterator struct { + i int + page AuthorizationServerCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AuthorizationServerCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AuthorizationServerCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AuthorizationServerCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AuthorizationServerCollectionIterator) Response() AuthorizationServerCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AuthorizationServerCollectionIterator) Value() AuthorizationServerContract { + if !iter.page.NotDone() { + return AuthorizationServerContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AuthorizationServerCollectionIterator type. +func NewAuthorizationServerCollectionIterator(page AuthorizationServerCollectionPage) AuthorizationServerCollectionIterator { + return AuthorizationServerCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (asc AuthorizationServerCollection) IsEmpty() bool { + return asc.Value == nil || len(*asc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (asc AuthorizationServerCollection) hasNextLink() bool { + return asc.NextLink != nil && len(*asc.NextLink) != 0 +} + +// authorizationServerCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (asc AuthorizationServerCollection) authorizationServerCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !asc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(asc.NextLink))) +} + +// AuthorizationServerCollectionPage contains a page of AuthorizationServerContract values. +type AuthorizationServerCollectionPage struct { + fn func(context.Context, AuthorizationServerCollection) (AuthorizationServerCollection, error) + asc AuthorizationServerCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AuthorizationServerCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AuthorizationServerCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.asc) + if err != nil { + return err + } + page.asc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AuthorizationServerCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AuthorizationServerCollectionPage) NotDone() bool { + return !page.asc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AuthorizationServerCollectionPage) Response() AuthorizationServerCollection { + return page.asc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AuthorizationServerCollectionPage) Values() []AuthorizationServerContract { + if page.asc.IsEmpty() { + return nil + } + return *page.asc.Value +} + +// Creates a new instance of the AuthorizationServerCollectionPage type. +func NewAuthorizationServerCollectionPage(cur AuthorizationServerCollection, getNextPage func(context.Context, AuthorizationServerCollection) (AuthorizationServerCollection, error)) AuthorizationServerCollectionPage { + return AuthorizationServerCollectionPage{ + fn: getNextPage, + asc: cur, + } +} + +// AuthorizationServerContract external OAuth authorization server settings. +type AuthorizationServerContract struct { + autorest.Response `json:"-"` + // AuthorizationServerContractProperties - Properties of the External OAuth authorization server Contract. + *AuthorizationServerContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AuthorizationServerContract. +func (asc AuthorizationServerContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asc.AuthorizationServerContractProperties != nil { + objectMap["properties"] = asc.AuthorizationServerContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AuthorizationServerContract struct. +func (asc *AuthorizationServerContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var authorizationServerContractProperties AuthorizationServerContractProperties + err = json.Unmarshal(*v, &authorizationServerContractProperties) + if err != nil { + return err + } + asc.AuthorizationServerContractProperties = &authorizationServerContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + asc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + asc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + asc.Type = &typeVar + } + } + } + + return nil +} + +// AuthorizationServerContractBaseProperties external OAuth authorization server Update settings contract. +type AuthorizationServerContractBaseProperties struct { + // Description - Description of the authorization server. Can contain HTML formatting tags. + Description *string `json:"description,omitempty"` + // AuthorizationMethods - HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. + AuthorizationMethods *[]AuthorizationMethod `json:"authorizationMethods,omitempty"` + // ClientAuthenticationMethod - Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. + ClientAuthenticationMethod *[]ClientAuthenticationMethod `json:"clientAuthenticationMethod,omitempty"` + // TokenBodyParameters - Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. + TokenBodyParameters *[]TokenBodyParameterContract `json:"tokenBodyParameters,omitempty"` + // TokenEndpoint - OAuth token endpoint. Contains absolute URI to entity being referenced. + TokenEndpoint *string `json:"tokenEndpoint,omitempty"` + // SupportState - If true, authorization server will include state parameter from the authorization request to its response. Client may use state parameter to raise protocol security. + SupportState *bool `json:"supportState,omitempty"` + // DefaultScope - Access token scope that is going to be requested by default. Can be overridden at the API level. Should be provided in the form of a string containing space-delimited values. + DefaultScope *string `json:"defaultScope,omitempty"` + // BearerTokenSendingMethods - Specifies the mechanism by which access token is passed to the API. + BearerTokenSendingMethods *[]BearerTokenSendingMethod `json:"bearerTokenSendingMethods,omitempty"` + // ResourceOwnerUsername - Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. + ResourceOwnerUsername *string `json:"resourceOwnerUsername,omitempty"` + // ResourceOwnerPassword - Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner password. + ResourceOwnerPassword *string `json:"resourceOwnerPassword,omitempty"` +} + +// AuthorizationServerContractProperties external OAuth authorization server settings Properties. +type AuthorizationServerContractProperties struct { + // DisplayName - User-friendly authorization server name. + DisplayName *string `json:"displayName,omitempty"` + // ClientRegistrationEndpoint - Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. + ClientRegistrationEndpoint *string `json:"clientRegistrationEndpoint,omitempty"` + // AuthorizationEndpoint - OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. + AuthorizationEndpoint *string `json:"authorizationEndpoint,omitempty"` + // GrantTypes - Form of an authorization grant, which the client uses to request the access token. + GrantTypes *[]GrantType `json:"grantTypes,omitempty"` + // ClientID - Client or app id registered with this authorization server. + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - Client or app secret registered with this authorization server. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + ClientSecret *string `json:"clientSecret,omitempty"` + // Description - Description of the authorization server. Can contain HTML formatting tags. + Description *string `json:"description,omitempty"` + // AuthorizationMethods - HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. + AuthorizationMethods *[]AuthorizationMethod `json:"authorizationMethods,omitempty"` + // ClientAuthenticationMethod - Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. + ClientAuthenticationMethod *[]ClientAuthenticationMethod `json:"clientAuthenticationMethod,omitempty"` + // TokenBodyParameters - Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. + TokenBodyParameters *[]TokenBodyParameterContract `json:"tokenBodyParameters,omitempty"` + // TokenEndpoint - OAuth token endpoint. Contains absolute URI to entity being referenced. + TokenEndpoint *string `json:"tokenEndpoint,omitempty"` + // SupportState - If true, authorization server will include state parameter from the authorization request to its response. Client may use state parameter to raise protocol security. + SupportState *bool `json:"supportState,omitempty"` + // DefaultScope - Access token scope that is going to be requested by default. Can be overridden at the API level. Should be provided in the form of a string containing space-delimited values. + DefaultScope *string `json:"defaultScope,omitempty"` + // BearerTokenSendingMethods - Specifies the mechanism by which access token is passed to the API. + BearerTokenSendingMethods *[]BearerTokenSendingMethod `json:"bearerTokenSendingMethods,omitempty"` + // ResourceOwnerUsername - Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. + ResourceOwnerUsername *string `json:"resourceOwnerUsername,omitempty"` + // ResourceOwnerPassword - Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner password. + ResourceOwnerPassword *string `json:"resourceOwnerPassword,omitempty"` +} + +// AuthorizationServerSecretsContract oAuth Server Secrets Contract. +type AuthorizationServerSecretsContract struct { + autorest.Response `json:"-"` + // ClientSecret - oAuth Authorization Server Secrets. + ClientSecret *string `json:"clientSecret,omitempty"` + // ResourceOwnerUsername - Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. + ResourceOwnerUsername *string `json:"resourceOwnerUsername,omitempty"` + // ResourceOwnerPassword - Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner password. + ResourceOwnerPassword *string `json:"resourceOwnerPassword,omitempty"` +} + +// AuthorizationServerUpdateContract external OAuth authorization server settings. +type AuthorizationServerUpdateContract struct { + // AuthorizationServerUpdateContractProperties - Properties of the External OAuth authorization server update Contract. + *AuthorizationServerUpdateContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AuthorizationServerUpdateContract. +func (asuc AuthorizationServerUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asuc.AuthorizationServerUpdateContractProperties != nil { + objectMap["properties"] = asuc.AuthorizationServerUpdateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AuthorizationServerUpdateContract struct. +func (asuc *AuthorizationServerUpdateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var authorizationServerUpdateContractProperties AuthorizationServerUpdateContractProperties + err = json.Unmarshal(*v, &authorizationServerUpdateContractProperties) + if err != nil { + return err + } + asuc.AuthorizationServerUpdateContractProperties = &authorizationServerUpdateContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + asuc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + asuc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + asuc.Type = &typeVar + } + } + } + + return nil +} + +// AuthorizationServerUpdateContractProperties external OAuth authorization server Update settings +// contract. +type AuthorizationServerUpdateContractProperties struct { + // DisplayName - User-friendly authorization server name. + DisplayName *string `json:"displayName,omitempty"` + // ClientRegistrationEndpoint - Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. + ClientRegistrationEndpoint *string `json:"clientRegistrationEndpoint,omitempty"` + // AuthorizationEndpoint - OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. + AuthorizationEndpoint *string `json:"authorizationEndpoint,omitempty"` + // GrantTypes - Form of an authorization grant, which the client uses to request the access token. + GrantTypes *[]GrantType `json:"grantTypes,omitempty"` + // ClientID - Client or app id registered with this authorization server. + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - Client or app secret registered with this authorization server. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + ClientSecret *string `json:"clientSecret,omitempty"` + // Description - Description of the authorization server. Can contain HTML formatting tags. + Description *string `json:"description,omitempty"` + // AuthorizationMethods - HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. + AuthorizationMethods *[]AuthorizationMethod `json:"authorizationMethods,omitempty"` + // ClientAuthenticationMethod - Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. + ClientAuthenticationMethod *[]ClientAuthenticationMethod `json:"clientAuthenticationMethod,omitempty"` + // TokenBodyParameters - Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. + TokenBodyParameters *[]TokenBodyParameterContract `json:"tokenBodyParameters,omitempty"` + // TokenEndpoint - OAuth token endpoint. Contains absolute URI to entity being referenced. + TokenEndpoint *string `json:"tokenEndpoint,omitempty"` + // SupportState - If true, authorization server will include state parameter from the authorization request to its response. Client may use state parameter to raise protocol security. + SupportState *bool `json:"supportState,omitempty"` + // DefaultScope - Access token scope that is going to be requested by default. Can be overridden at the API level. Should be provided in the form of a string containing space-delimited values. + DefaultScope *string `json:"defaultScope,omitempty"` + // BearerTokenSendingMethods - Specifies the mechanism by which access token is passed to the API. + BearerTokenSendingMethods *[]BearerTokenSendingMethod `json:"bearerTokenSendingMethods,omitempty"` + // ResourceOwnerUsername - Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. + ResourceOwnerUsername *string `json:"resourceOwnerUsername,omitempty"` + // ResourceOwnerPassword - Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner password. + ResourceOwnerPassword *string `json:"resourceOwnerPassword,omitempty"` +} + +// BackendAuthorizationHeaderCredentials authorization header information. +type BackendAuthorizationHeaderCredentials struct { + // Scheme - Authentication Scheme name. + Scheme *string `json:"scheme,omitempty"` + // Parameter - Authentication Parameter value. + Parameter *string `json:"parameter,omitempty"` +} + +// BackendBaseParameters backend entity base Parameter set. +type BackendBaseParameters struct { + // Title - Backend Title. + Title *string `json:"title,omitempty"` + // Description - Backend Description. + Description *string `json:"description,omitempty"` + // ResourceID - Management Uri of the Resource in External System. This url can be the Arm Resource Id of Logic Apps, Function Apps or API Apps. + ResourceID *string `json:"resourceId,omitempty"` + // Properties - Backend Properties contract + Properties *BackendProperties `json:"properties,omitempty"` + // Credentials - Backend Credentials Contract Properties + Credentials *BackendCredentialsContract `json:"credentials,omitempty"` + // Proxy - Backend Proxy Contract Properties + Proxy *BackendProxyContract `json:"proxy,omitempty"` + // TLS - Backend TLS Properties + TLS *BackendTLSProperties `json:"tls,omitempty"` +} + +// BackendCollection paged Backend list representation. +type BackendCollection struct { + autorest.Response `json:"-"` + // Value - Backend values. + Value *[]BackendContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// BackendCollectionIterator provides access to a complete listing of BackendContract values. +type BackendCollectionIterator struct { + i int + page BackendCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *BackendCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *BackendCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter BackendCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter BackendCollectionIterator) Response() BackendCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter BackendCollectionIterator) Value() BackendContract { + if !iter.page.NotDone() { + return BackendContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the BackendCollectionIterator type. +func NewBackendCollectionIterator(page BackendCollectionPage) BackendCollectionIterator { + return BackendCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (bc BackendCollection) IsEmpty() bool { + return bc.Value == nil || len(*bc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (bc BackendCollection) hasNextLink() bool { + return bc.NextLink != nil && len(*bc.NextLink) != 0 +} + +// backendCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (bc BackendCollection) backendCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !bc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(bc.NextLink))) +} + +// BackendCollectionPage contains a page of BackendContract values. +type BackendCollectionPage struct { + fn func(context.Context, BackendCollection) (BackendCollection, error) + bc BackendCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *BackendCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackendCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.bc) + if err != nil { + return err + } + page.bc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *BackendCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page BackendCollectionPage) NotDone() bool { + return !page.bc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page BackendCollectionPage) Response() BackendCollection { + return page.bc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page BackendCollectionPage) Values() []BackendContract { + if page.bc.IsEmpty() { + return nil + } + return *page.bc.Value +} + +// Creates a new instance of the BackendCollectionPage type. +func NewBackendCollectionPage(cur BackendCollection, getNextPage func(context.Context, BackendCollection) (BackendCollection, error)) BackendCollectionPage { + return BackendCollectionPage{ + fn: getNextPage, + bc: cur, + } +} + +// BackendContract backend details. +type BackendContract struct { + autorest.Response `json:"-"` + // BackendContractProperties - Backend entity contract properties. + *BackendContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackendContract. +func (bc BackendContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bc.BackendContractProperties != nil { + objectMap["properties"] = bc.BackendContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackendContract struct. +func (bc *BackendContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var backendContractProperties BackendContractProperties + err = json.Unmarshal(*v, &backendContractProperties) + if err != nil { + return err + } + bc.BackendContractProperties = &backendContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bc.Type = &typeVar + } + } + } + + return nil +} + +// BackendContractProperties parameters supplied to the Create Backend operation. +type BackendContractProperties struct { + // URL - Runtime Url of the Backend. + URL *string `json:"url,omitempty"` + // Protocol - Backend communication protocol. Possible values include: 'BackendProtocolHTTP', 'BackendProtocolSoap' + Protocol BackendProtocol `json:"protocol,omitempty"` + // Title - Backend Title. + Title *string `json:"title,omitempty"` + // Description - Backend Description. + Description *string `json:"description,omitempty"` + // ResourceID - Management Uri of the Resource in External System. This url can be the Arm Resource Id of Logic Apps, Function Apps or API Apps. + ResourceID *string `json:"resourceId,omitempty"` + // Properties - Backend Properties contract + Properties *BackendProperties `json:"properties,omitempty"` + // Credentials - Backend Credentials Contract Properties + Credentials *BackendCredentialsContract `json:"credentials,omitempty"` + // Proxy - Backend Proxy Contract Properties + Proxy *BackendProxyContract `json:"proxy,omitempty"` + // TLS - Backend TLS Properties + TLS *BackendTLSProperties `json:"tls,omitempty"` +} + +// BackendCredentialsContract details of the Credentials used to connect to Backend. +type BackendCredentialsContract struct { + // CertificateIds - List of Client Certificate Ids. + CertificateIds *[]string `json:"certificateIds,omitempty"` + // Certificate - List of Client Certificate Thumbprints. Will be ignored if certificatesIds are provided. + Certificate *[]string `json:"certificate,omitempty"` + // Query - Query Parameter description. + Query map[string][]string `json:"query"` + // Header - Header Parameter description. + Header map[string][]string `json:"header"` + // Authorization - Authorization header authentication + Authorization *BackendAuthorizationHeaderCredentials `json:"authorization,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackendCredentialsContract. +func (bcc BackendCredentialsContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bcc.CertificateIds != nil { + objectMap["certificateIds"] = bcc.CertificateIds + } + if bcc.Certificate != nil { + objectMap["certificate"] = bcc.Certificate + } + if bcc.Query != nil { + objectMap["query"] = bcc.Query + } + if bcc.Header != nil { + objectMap["header"] = bcc.Header + } + if bcc.Authorization != nil { + objectMap["authorization"] = bcc.Authorization + } + return json.Marshal(objectMap) +} + +// BackendProperties properties specific to the Backend Type. +type BackendProperties struct { + // ServiceFabricCluster - Backend Service Fabric Cluster Properties + ServiceFabricCluster *BackendServiceFabricClusterProperties `json:"serviceFabricCluster,omitempty"` +} + +// BackendProxyContract details of the Backend WebProxy Server to use in the Request to Backend. +type BackendProxyContract struct { + // URL - WebProxy Server AbsoluteUri property which includes the entire URI stored in the Uri instance, including all fragments and query strings. + URL *string `json:"url,omitempty"` + // Username - Username to connect to the WebProxy server + Username *string `json:"username,omitempty"` + // Password - Password to connect to the WebProxy Server + Password *string `json:"password,omitempty"` +} + +// BackendReconnectContract reconnect request parameters. +type BackendReconnectContract struct { + // BackendReconnectProperties - Reconnect request properties. + *BackendReconnectProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackendReconnectContract. +func (brc BackendReconnectContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if brc.BackendReconnectProperties != nil { + objectMap["properties"] = brc.BackendReconnectProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackendReconnectContract struct. +func (brc *BackendReconnectContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var backendReconnectProperties BackendReconnectProperties + err = json.Unmarshal(*v, &backendReconnectProperties) + if err != nil { + return err + } + brc.BackendReconnectProperties = &backendReconnectProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + brc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + brc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + brc.Type = &typeVar + } + } + } + + return nil +} + +// BackendReconnectProperties properties to control reconnect requests. +type BackendReconnectProperties struct { + // After - Duration in ISO8601 format after which reconnect will be initiated. Minimum duration of the Reconnect is PT2M. + After *string `json:"after,omitempty"` +} + +// BackendServiceFabricClusterProperties properties of the Service Fabric Type Backend. +type BackendServiceFabricClusterProperties struct { + // ClientCertificateID - The client certificate id for the management endpoint. + ClientCertificateID *string `json:"clientCertificateId,omitempty"` + // ClientCertificatethumbprint - The client certificate thumbprint for the management endpoint. Will be ignored if certificatesIds are provided + ClientCertificatethumbprint *string `json:"clientCertificatethumbprint,omitempty"` + // MaxPartitionResolutionRetries - Maximum number of retries while attempting resolve the partition. + MaxPartitionResolutionRetries *int32 `json:"maxPartitionResolutionRetries,omitempty"` + // ManagementEndpoints - The cluster management endpoint. + ManagementEndpoints *[]string `json:"managementEndpoints,omitempty"` + // ServerCertificateThumbprints - Thumbprints of certificates cluster management service uses for tls communication + ServerCertificateThumbprints *[]string `json:"serverCertificateThumbprints,omitempty"` + // ServerX509Names - Server X509 Certificate Names Collection + ServerX509Names *[]X509CertificateName `json:"serverX509Names,omitempty"` +} + +// BackendTLSProperties properties controlling TLS Certificate Validation. +type BackendTLSProperties struct { + // ValidateCertificateChain - Flag indicating whether SSL certificate chain validation should be done when using self-signed certificates for this backend host. + ValidateCertificateChain *bool `json:"validateCertificateChain,omitempty"` + // ValidateCertificateName - Flag indicating whether SSL certificate name validation should be done when using self-signed certificates for this backend host. + ValidateCertificateName *bool `json:"validateCertificateName,omitempty"` +} + +// BackendUpdateParameterProperties parameters supplied to the Update Backend operation. +type BackendUpdateParameterProperties struct { + // URL - Runtime Url of the Backend. + URL *string `json:"url,omitempty"` + // Protocol - Backend communication protocol. Possible values include: 'BackendProtocolHTTP', 'BackendProtocolSoap' + Protocol BackendProtocol `json:"protocol,omitempty"` + // Title - Backend Title. + Title *string `json:"title,omitempty"` + // Description - Backend Description. + Description *string `json:"description,omitempty"` + // ResourceID - Management Uri of the Resource in External System. This url can be the Arm Resource Id of Logic Apps, Function Apps or API Apps. + ResourceID *string `json:"resourceId,omitempty"` + // Properties - Backend Properties contract + Properties *BackendProperties `json:"properties,omitempty"` + // Credentials - Backend Credentials Contract Properties + Credentials *BackendCredentialsContract `json:"credentials,omitempty"` + // Proxy - Backend Proxy Contract Properties + Proxy *BackendProxyContract `json:"proxy,omitempty"` + // TLS - Backend TLS Properties + TLS *BackendTLSProperties `json:"tls,omitempty"` +} + +// BackendUpdateParameters backend update parameters. +type BackendUpdateParameters struct { + // BackendUpdateParameterProperties - Backend entity update contract properties. + *BackendUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackendUpdateParameters. +func (bup BackendUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bup.BackendUpdateParameterProperties != nil { + objectMap["properties"] = bup.BackendUpdateParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackendUpdateParameters struct. +func (bup *BackendUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var backendUpdateParameterProperties BackendUpdateParameterProperties + err = json.Unmarshal(*v, &backendUpdateParameterProperties) + if err != nil { + return err + } + bup.BackendUpdateParameterProperties = &backendUpdateParameterProperties + } + } + } + + return nil +} + +// BodyDiagnosticSettings body logging settings. +type BodyDiagnosticSettings struct { + // Bytes - Number of request body bytes to log. + Bytes *int32 `json:"bytes,omitempty"` +} + +// CacheCollection paged Caches list representation. +type CacheCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]CacheContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// CacheCollectionIterator provides access to a complete listing of CacheContract values. +type CacheCollectionIterator struct { + i int + page CacheCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CacheCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CacheCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *CacheCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CacheCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter CacheCollectionIterator) Response() CacheCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter CacheCollectionIterator) Value() CacheContract { + if !iter.page.NotDone() { + return CacheContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CacheCollectionIterator type. +func NewCacheCollectionIterator(page CacheCollectionPage) CacheCollectionIterator { + return CacheCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cc CacheCollection) IsEmpty() bool { + return cc.Value == nil || len(*cc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cc CacheCollection) hasNextLink() bool { + return cc.NextLink != nil && len(*cc.NextLink) != 0 +} + +// cacheCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cc CacheCollection) cacheCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !cc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cc.NextLink))) +} + +// CacheCollectionPage contains a page of CacheContract values. +type CacheCollectionPage struct { + fn func(context.Context, CacheCollection) (CacheCollection, error) + cc CacheCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CacheCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CacheCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cc) + if err != nil { + return err + } + page.cc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *CacheCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CacheCollectionPage) NotDone() bool { + return !page.cc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CacheCollectionPage) Response() CacheCollection { + return page.cc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CacheCollectionPage) Values() []CacheContract { + if page.cc.IsEmpty() { + return nil + } + return *page.cc.Value +} + +// Creates a new instance of the CacheCollectionPage type. +func NewCacheCollectionPage(cur CacheCollection, getNextPage func(context.Context, CacheCollection) (CacheCollection, error)) CacheCollectionPage { + return CacheCollectionPage{ + fn: getNextPage, + cc: cur, + } +} + +// CacheContract cache details. +type CacheContract struct { + autorest.Response `json:"-"` + // CacheContractProperties - Cache properties details. + *CacheContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CacheContract. +func (cc CacheContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cc.CacheContractProperties != nil { + objectMap["properties"] = cc.CacheContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CacheContract struct. +func (cc *CacheContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var cacheContractProperties CacheContractProperties + err = json.Unmarshal(*v, &cacheContractProperties) + if err != nil { + return err + } + cc.CacheContractProperties = &cacheContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cc.Type = &typeVar + } + } + } + + return nil +} + +// CacheContractProperties properties of the Cache contract. +type CacheContractProperties struct { + // Description - Cache description + Description *string `json:"description,omitempty"` + // ConnectionString - Runtime connection string to cache + ConnectionString *string `json:"connectionString,omitempty"` + // UseFromLocation - Location identifier to use cache from (should be either 'default' or valid Azure region identifier) + UseFromLocation *string `json:"useFromLocation,omitempty"` + // ResourceID - Original uri of entity in external system cache points to + ResourceID *string `json:"resourceId,omitempty"` +} + +// CacheUpdateParameters cache update details. +type CacheUpdateParameters struct { + // CacheUpdateProperties - Cache update properties details. + *CacheUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CacheUpdateParameters. +func (cup CacheUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.CacheUpdateProperties != nil { + objectMap["properties"] = cup.CacheUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CacheUpdateParameters struct. +func (cup *CacheUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var cacheUpdateProperties CacheUpdateProperties + err = json.Unmarshal(*v, &cacheUpdateProperties) + if err != nil { + return err + } + cup.CacheUpdateProperties = &cacheUpdateProperties + } + } + } + + return nil +} + +// CacheUpdateProperties parameters supplied to the Update Cache operation. +type CacheUpdateProperties struct { + // Description - Cache description + Description *string `json:"description,omitempty"` + // ConnectionString - Runtime connection string to cache + ConnectionString *string `json:"connectionString,omitempty"` + // UseFromLocation - Location identifier to use cache from (should be either 'default' or valid Azure region identifier) + UseFromLocation *string `json:"useFromLocation,omitempty"` + // ResourceID - Original uri of entity in external system cache points to + ResourceID *string `json:"resourceId,omitempty"` +} + +// CertificateCollection paged Certificates list representation. +type CertificateCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]CertificateContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// CertificateCollectionIterator provides access to a complete listing of CertificateContract values. +type CertificateCollectionIterator struct { + i int + page CertificateCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CertificateCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CertificateCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *CertificateCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CertificateCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter CertificateCollectionIterator) Response() CertificateCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter CertificateCollectionIterator) Value() CertificateContract { + if !iter.page.NotDone() { + return CertificateContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CertificateCollectionIterator type. +func NewCertificateCollectionIterator(page CertificateCollectionPage) CertificateCollectionIterator { + return CertificateCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cc CertificateCollection) IsEmpty() bool { + return cc.Value == nil || len(*cc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cc CertificateCollection) hasNextLink() bool { + return cc.NextLink != nil && len(*cc.NextLink) != 0 +} + +// certificateCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cc CertificateCollection) certificateCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !cc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cc.NextLink))) +} + +// CertificateCollectionPage contains a page of CertificateContract values. +type CertificateCollectionPage struct { + fn func(context.Context, CertificateCollection) (CertificateCollection, error) + cc CertificateCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CertificateCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CertificateCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cc) + if err != nil { + return err + } + page.cc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *CertificateCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CertificateCollectionPage) NotDone() bool { + return !page.cc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CertificateCollectionPage) Response() CertificateCollection { + return page.cc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CertificateCollectionPage) Values() []CertificateContract { + if page.cc.IsEmpty() { + return nil + } + return *page.cc.Value +} + +// Creates a new instance of the CertificateCollectionPage type. +func NewCertificateCollectionPage(cur CertificateCollection, getNextPage func(context.Context, CertificateCollection) (CertificateCollection, error)) CertificateCollectionPage { + return CertificateCollectionPage{ + fn: getNextPage, + cc: cur, + } +} + +// CertificateConfiguration certificate configuration which consist of non-trusted intermediates and root +// certificates. +type CertificateConfiguration struct { + // EncodedCertificate - Base64 Encoded certificate. + EncodedCertificate *string `json:"encodedCertificate,omitempty"` + // CertificatePassword - Certificate Password. + CertificatePassword *string `json:"certificatePassword,omitempty"` + // StoreName - The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only Root and CertificateAuthority are valid locations. Possible values include: 'StoreNameCertificateAuthority', 'StoreNameRoot' + StoreName StoreName `json:"storeName,omitempty"` + // Certificate - Certificate information. + Certificate *CertificateInformation `json:"certificate,omitempty"` +} + +// CertificateContract certificate details. +type CertificateContract struct { + autorest.Response `json:"-"` + // CertificateContractProperties - Certificate properties details. + *CertificateContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateContract. +func (cc CertificateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cc.CertificateContractProperties != nil { + objectMap["properties"] = cc.CertificateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CertificateContract struct. +func (cc *CertificateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var certificateContractProperties CertificateContractProperties + err = json.Unmarshal(*v, &certificateContractProperties) + if err != nil { + return err + } + cc.CertificateContractProperties = &certificateContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cc.Type = &typeVar + } + } + } + + return nil +} + +// CertificateContractProperties properties of the Certificate contract. +type CertificateContractProperties struct { + // Subject - Subject attribute of the certificate. + Subject *string `json:"subject,omitempty"` + // Thumbprint - Thumbprint of the certificate. + Thumbprint *string `json:"thumbprint,omitempty"` + // ExpirationDate - Expiration date of the certificate. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + ExpirationDate *date.Time `json:"expirationDate,omitempty"` + // KeyVault - KeyVault location details of the certificate. + KeyVault *KeyVaultContractProperties `json:"keyVault,omitempty"` +} + +// CertificateCreateOrUpdateParameters certificate create or update details. +type CertificateCreateOrUpdateParameters struct { + // CertificateCreateOrUpdateProperties - Certificate create or update properties details. + *CertificateCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateCreateOrUpdateParameters. +func (ccoup CertificateCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccoup.CertificateCreateOrUpdateProperties != nil { + objectMap["properties"] = ccoup.CertificateCreateOrUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CertificateCreateOrUpdateParameters struct. +func (ccoup *CertificateCreateOrUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var certificateCreateOrUpdateProperties CertificateCreateOrUpdateProperties + err = json.Unmarshal(*v, &certificateCreateOrUpdateProperties) + if err != nil { + return err + } + ccoup.CertificateCreateOrUpdateProperties = &certificateCreateOrUpdateProperties + } + } + } + + return nil +} + +// CertificateCreateOrUpdateProperties parameters supplied to the CreateOrUpdate certificate operation. +type CertificateCreateOrUpdateProperties struct { + // Data - Base 64 encoded certificate using the application/x-pkcs12 representation. + Data *string `json:"data,omitempty"` + // Password - Password for the Certificate + Password *string `json:"password,omitempty"` + // KeyVault - KeyVault location details of the certificate. + KeyVault *KeyVaultContractCreateProperties `json:"keyVault,omitempty"` +} + +// CertificateInformation SSL certificate information. +type CertificateInformation struct { + // Expiry - Expiration date of the certificate. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + Expiry *date.Time `json:"expiry,omitempty"` + // Thumbprint - Thumbprint of the certificate. + Thumbprint *string `json:"thumbprint,omitempty"` + // Subject - Subject of the certificate. + Subject *string `json:"subject,omitempty"` +} + +// ClientSecretContract client or app secret used in IdentityProviders, Aad, OpenID or OAuth. +type ClientSecretContract struct { + autorest.Response `json:"-"` + // ClientSecret - Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// ConnectivityStatusContract details about connectivity to a resource. +type ConnectivityStatusContract struct { + // Name - The hostname of the resource which the service depends on. This can be the database, storage or any other azure resource on which the service depends upon. + Name *string `json:"name,omitempty"` + // Status - Resource Connectivity Status Type identifier. Possible values include: 'ConnectivityStatusTypeInitializing', 'ConnectivityStatusTypeSuccess', 'ConnectivityStatusTypeFailure' + Status ConnectivityStatusType `json:"status,omitempty"` + // Error - Error details of the connectivity to the resource. + Error *string `json:"error,omitempty"` + // LastUpdated - The date when the resource connectivity status was last updated. This status should be updated every 15 minutes. If this status has not been updated, then it means that the service has lost network connectivity to the resource, from inside the Virtual Network.The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + LastUpdated *date.Time `json:"lastUpdated,omitempty"` + // LastStatusChange - The date when the resource connectivity status last Changed from success to failure or vice-versa. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + LastStatusChange *date.Time `json:"lastStatusChange,omitempty"` + // ResourceType - Resource Type. + ResourceType *string `json:"resourceType,omitempty"` + // IsOptional - Whether this is optional. + IsOptional *bool `json:"isOptional,omitempty"` +} + +// ContentItemCollection paged list of content items. +type ContentItemCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of content items. + Value *[]ContentItemContract `json:"value,omitempty"` + // NextLink - READ-ONLY; Next page link, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ContentItemCollection. +func (cic ContentItemCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ContentItemCollectionIterator provides access to a complete listing of ContentItemContract values. +type ContentItemCollectionIterator struct { + i int + page ContentItemCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ContentItemCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentItemCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ContentItemCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ContentItemCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ContentItemCollectionIterator) Response() ContentItemCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ContentItemCollectionIterator) Value() ContentItemContract { + if !iter.page.NotDone() { + return ContentItemContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ContentItemCollectionIterator type. +func NewContentItemCollectionIterator(page ContentItemCollectionPage) ContentItemCollectionIterator { + return ContentItemCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cic ContentItemCollection) IsEmpty() bool { + return cic.Value == nil || len(*cic.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cic ContentItemCollection) hasNextLink() bool { + return cic.NextLink != nil && len(*cic.NextLink) != 0 +} + +// contentItemCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cic ContentItemCollection) contentItemCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !cic.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cic.NextLink))) +} + +// ContentItemCollectionPage contains a page of ContentItemContract values. +type ContentItemCollectionPage struct { + fn func(context.Context, ContentItemCollection) (ContentItemCollection, error) + cic ContentItemCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ContentItemCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentItemCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cic) + if err != nil { + return err + } + page.cic = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ContentItemCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ContentItemCollectionPage) NotDone() bool { + return !page.cic.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ContentItemCollectionPage) Response() ContentItemCollection { + return page.cic +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ContentItemCollectionPage) Values() []ContentItemContract { + if page.cic.IsEmpty() { + return nil + } + return *page.cic.Value +} + +// Creates a new instance of the ContentItemCollectionPage type. +func NewContentItemCollectionPage(cur ContentItemCollection, getNextPage func(context.Context, ContentItemCollection) (ContentItemCollection, error)) ContentItemCollectionPage { + return ContentItemCollectionPage{ + fn: getNextPage, + cic: cur, + } +} + +// ContentItemContract content type contract details. +type ContentItemContract struct { + autorest.Response `json:"-"` + // Properties - Properties of the content item. + Properties map[string]interface{} `json:"properties"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ContentItemContract. +func (cic ContentItemContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cic.Properties != nil { + objectMap["properties"] = cic.Properties + } + return json.Marshal(objectMap) +} + +// ContentTypeCollection paged list of content types. +type ContentTypeCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of content types. + Value *[]ContentTypeContract `json:"value,omitempty"` + // NextLink - READ-ONLY; Next page link, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ContentTypeCollection. +func (ctc ContentTypeCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ContentTypeCollectionIterator provides access to a complete listing of ContentTypeContract values. +type ContentTypeCollectionIterator struct { + i int + page ContentTypeCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ContentTypeCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentTypeCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ContentTypeCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ContentTypeCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ContentTypeCollectionIterator) Response() ContentTypeCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ContentTypeCollectionIterator) Value() ContentTypeContract { + if !iter.page.NotDone() { + return ContentTypeContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ContentTypeCollectionIterator type. +func NewContentTypeCollectionIterator(page ContentTypeCollectionPage) ContentTypeCollectionIterator { + return ContentTypeCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ctc ContentTypeCollection) IsEmpty() bool { + return ctc.Value == nil || len(*ctc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ctc ContentTypeCollection) hasNextLink() bool { + return ctc.NextLink != nil && len(*ctc.NextLink) != 0 +} + +// contentTypeCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ctc ContentTypeCollection) contentTypeCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !ctc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ctc.NextLink))) +} + +// ContentTypeCollectionPage contains a page of ContentTypeContract values. +type ContentTypeCollectionPage struct { + fn func(context.Context, ContentTypeCollection) (ContentTypeCollection, error) + ctc ContentTypeCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ContentTypeCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContentTypeCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ctc) + if err != nil { + return err + } + page.ctc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ContentTypeCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ContentTypeCollectionPage) NotDone() bool { + return !page.ctc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ContentTypeCollectionPage) Response() ContentTypeCollection { + return page.ctc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ContentTypeCollectionPage) Values() []ContentTypeContract { + if page.ctc.IsEmpty() { + return nil + } + return *page.ctc.Value +} + +// Creates a new instance of the ContentTypeCollectionPage type. +func NewContentTypeCollectionPage(cur ContentTypeCollection, getNextPage func(context.Context, ContentTypeCollection) (ContentTypeCollection, error)) ContentTypeCollectionPage { + return ContentTypeCollectionPage{ + fn: getNextPage, + ctc: cur, + } +} + +// ContentTypeContract content type contract details. +type ContentTypeContract struct { + autorest.Response `json:"-"` + // ContentTypeContractProperties - Properties of the content type. + *ContentTypeContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ContentTypeContract. +func (ctc ContentTypeContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctc.ContentTypeContractProperties != nil { + objectMap["properties"] = ctc.ContentTypeContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ContentTypeContract struct. +func (ctc *ContentTypeContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var contentTypeContractProperties ContentTypeContractProperties + err = json.Unmarshal(*v, &contentTypeContractProperties) + if err != nil { + return err + } + ctc.ContentTypeContractProperties = &contentTypeContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ctc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ctc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ctc.Type = &typeVar + } + } + } + + return nil +} + +// ContentTypeContractProperties ... +type ContentTypeContractProperties struct { + // ID - Content type identifier + ID *string `json:"id,omitempty"` + // Name - Content type name. Must be 1 to 250 characters long. + Name *string `json:"name,omitempty"` + // Description - Content type description. + Description *string `json:"description,omitempty"` + // Schema - Content type schema. + Schema interface{} `json:"schema,omitempty"` + // Version - Content type version. + Version *string `json:"version,omitempty"` +} + +// DataMasking ... +type DataMasking struct { + // QueryParams - Masking settings for Url query parameters + QueryParams *[]DataMaskingEntity `json:"queryParams,omitempty"` + // Headers - Masking settings for headers + Headers *[]DataMaskingEntity `json:"headers,omitempty"` +} + +// DataMaskingEntity ... +type DataMaskingEntity struct { + // Value - The name of an entity to mask (e.g. a name of a header or a query parameter). + Value *string `json:"value,omitempty"` + // Mode - Data masking mode. Possible values include: 'DataMaskingModeMask', 'DataMaskingModeHide' + Mode DataMaskingMode `json:"mode,omitempty"` +} + +// DeletedServiceContract deleted API Management Service information. +type DeletedServiceContract struct { + autorest.Response `json:"-"` + // DeletedServiceContractProperties - Deleted API Management Service details. + *DeletedServiceContractProperties `json:"properties,omitempty"` + // Location - READ-ONLY; API Management Service Master Location. + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeletedServiceContract. +func (dsc DeletedServiceContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsc.DeletedServiceContractProperties != nil { + objectMap["properties"] = dsc.DeletedServiceContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DeletedServiceContract struct. +func (dsc *DeletedServiceContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var deletedServiceContractProperties DeletedServiceContractProperties + err = json.Unmarshal(*v, &deletedServiceContractProperties) + if err != nil { + return err + } + dsc.DeletedServiceContractProperties = &deletedServiceContractProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dsc.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dsc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dsc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dsc.Type = &typeVar + } + } + } + + return nil +} + +// DeletedServiceContractProperties ... +type DeletedServiceContractProperties struct { + // ServiceID - Fully-qualified API Management Service Resource ID + ServiceID *string `json:"serviceId,omitempty"` + // ScheduledPurgeDate - UTC Date and Time when the service will be automatically purged. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + ScheduledPurgeDate *date.Time `json:"scheduledPurgeDate,omitempty"` + // DeletionDate - UTC Timestamp when the service was soft-deleted. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + DeletionDate *date.Time `json:"deletionDate,omitempty"` +} + +// DeletedServicesCollection paged deleted API Management Services List Representation. +type DeletedServicesCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]DeletedServiceContract `json:"value,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeletedServicesCollection. +func (dsc DeletedServicesCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DeletedServicesCollectionIterator provides access to a complete listing of DeletedServiceContract +// values. +type DeletedServicesCollectionIterator struct { + i int + page DeletedServicesCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DeletedServicesCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServicesCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DeletedServicesCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DeletedServicesCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DeletedServicesCollectionIterator) Response() DeletedServicesCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DeletedServicesCollectionIterator) Value() DeletedServiceContract { + if !iter.page.NotDone() { + return DeletedServiceContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DeletedServicesCollectionIterator type. +func NewDeletedServicesCollectionIterator(page DeletedServicesCollectionPage) DeletedServicesCollectionIterator { + return DeletedServicesCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dsc DeletedServicesCollection) IsEmpty() bool { + return dsc.Value == nil || len(*dsc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dsc DeletedServicesCollection) hasNextLink() bool { + return dsc.NextLink != nil && len(*dsc.NextLink) != 0 +} + +// deletedServicesCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dsc DeletedServicesCollection) deletedServicesCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !dsc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dsc.NextLink))) +} + +// DeletedServicesCollectionPage contains a page of DeletedServiceContract values. +type DeletedServicesCollectionPage struct { + fn func(context.Context, DeletedServicesCollection) (DeletedServicesCollection, error) + dsc DeletedServicesCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DeletedServicesCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServicesCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dsc) + if err != nil { + return err + } + page.dsc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DeletedServicesCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DeletedServicesCollectionPage) NotDone() bool { + return !page.dsc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DeletedServicesCollectionPage) Response() DeletedServicesCollection { + return page.dsc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DeletedServicesCollectionPage) Values() []DeletedServiceContract { + if page.dsc.IsEmpty() { + return nil + } + return *page.dsc.Value +} + +// Creates a new instance of the DeletedServicesCollectionPage type. +func NewDeletedServicesCollectionPage(cur DeletedServicesCollection, getNextPage func(context.Context, DeletedServicesCollection) (DeletedServicesCollection, error)) DeletedServicesCollectionPage { + return DeletedServicesCollectionPage{ + fn: getNextPage, + dsc: cur, + } +} + +// DeletedServicesPurgeFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DeletedServicesPurgeFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DeletedServicesClient) (DeletedServiceContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DeletedServicesPurgeFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DeletedServicesPurgeFuture.Result. +func (future *DeletedServicesPurgeFuture) result(client DeletedServicesClient) (dsc DeletedServiceContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesPurgeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + dsc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.DeletedServicesPurgeFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dsc.Response.Response, err = future.GetResult(sender); err == nil && dsc.Response.Response.StatusCode != http.StatusNoContent { + dsc, err = client.PurgeResponder(dsc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.DeletedServicesPurgeFuture", "Result", dsc.Response.Response, "Failure responding to request") + } + } + return +} + +// DeployConfigurationParameterProperties parameters supplied to the Deploy Configuration operation. +type DeployConfigurationParameterProperties struct { + // Branch - The name of the Git branch from which the configuration is to be deployed to the configuration database. + Branch *string `json:"branch,omitempty"` + // Force - The value enforcing deleting subscriptions to products that are deleted in this update. + Force *bool `json:"force,omitempty"` +} + +// DeployConfigurationParameters deploy Tenant Configuration Contract. +type DeployConfigurationParameters struct { + // DeployConfigurationParameterProperties - Deploy Configuration Parameter contract properties. + *DeployConfigurationParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeployConfigurationParameters. +func (dcp DeployConfigurationParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcp.DeployConfigurationParameterProperties != nil { + objectMap["properties"] = dcp.DeployConfigurationParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DeployConfigurationParameters struct. +func (dcp *DeployConfigurationParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var deployConfigurationParameterProperties DeployConfigurationParameterProperties + err = json.Unmarshal(*v, &deployConfigurationParameterProperties) + if err != nil { + return err + } + dcp.DeployConfigurationParameterProperties = &deployConfigurationParameterProperties + } + } + } + + return nil +} + +// DiagnosticCollection paged Diagnostic list representation. +type DiagnosticCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]DiagnosticContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// DiagnosticCollectionIterator provides access to a complete listing of DiagnosticContract values. +type DiagnosticCollectionIterator struct { + i int + page DiagnosticCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DiagnosticCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DiagnosticCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DiagnosticCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DiagnosticCollectionIterator) Response() DiagnosticCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DiagnosticCollectionIterator) Value() DiagnosticContract { + if !iter.page.NotDone() { + return DiagnosticContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DiagnosticCollectionIterator type. +func NewDiagnosticCollectionIterator(page DiagnosticCollectionPage) DiagnosticCollectionIterator { + return DiagnosticCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dc DiagnosticCollection) IsEmpty() bool { + return dc.Value == nil || len(*dc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dc DiagnosticCollection) hasNextLink() bool { + return dc.NextLink != nil && len(*dc.NextLink) != 0 +} + +// diagnosticCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dc DiagnosticCollection) diagnosticCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !dc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dc.NextLink))) +} + +// DiagnosticCollectionPage contains a page of DiagnosticContract values. +type DiagnosticCollectionPage struct { + fn func(context.Context, DiagnosticCollection) (DiagnosticCollection, error) + dc DiagnosticCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DiagnosticCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dc) + if err != nil { + return err + } + page.dc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DiagnosticCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DiagnosticCollectionPage) NotDone() bool { + return !page.dc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DiagnosticCollectionPage) Response() DiagnosticCollection { + return page.dc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DiagnosticCollectionPage) Values() []DiagnosticContract { + if page.dc.IsEmpty() { + return nil + } + return *page.dc.Value +} + +// Creates a new instance of the DiagnosticCollectionPage type. +func NewDiagnosticCollectionPage(cur DiagnosticCollection, getNextPage func(context.Context, DiagnosticCollection) (DiagnosticCollection, error)) DiagnosticCollectionPage { + return DiagnosticCollectionPage{ + fn: getNextPage, + dc: cur, + } +} + +// DiagnosticContract diagnostic details. +type DiagnosticContract struct { + autorest.Response `json:"-"` + // DiagnosticContractProperties - Diagnostic entity contract properties. + *DiagnosticContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DiagnosticContract. +func (dc DiagnosticContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dc.DiagnosticContractProperties != nil { + objectMap["properties"] = dc.DiagnosticContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DiagnosticContract struct. +func (dc *DiagnosticContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var diagnosticContractProperties DiagnosticContractProperties + err = json.Unmarshal(*v, &diagnosticContractProperties) + if err != nil { + return err + } + dc.DiagnosticContractProperties = &diagnosticContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dc.Type = &typeVar + } + } + } + + return nil +} + +// DiagnosticContractProperties diagnostic Entity Properties +type DiagnosticContractProperties struct { + // AlwaysLog - Specifies for what type of messages sampling settings should not apply. Possible values include: 'AlwaysLogAllErrors' + AlwaysLog AlwaysLog `json:"alwaysLog,omitempty"` + // LoggerID - Resource Id of a target logger. + LoggerID *string `json:"loggerId,omitempty"` + // Sampling - Sampling settings for Diagnostic. + Sampling *SamplingSettings `json:"sampling,omitempty"` + // Frontend - Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + Frontend *PipelineDiagnosticSettings `json:"frontend,omitempty"` + // Backend - Diagnostic settings for incoming/outgoing HTTP messages to the Backend + Backend *PipelineDiagnosticSettings `json:"backend,omitempty"` + // LogClientIP - Log the ClientIP. Default is false. + LogClientIP *bool `json:"logClientIp,omitempty"` + // HTTPCorrelationProtocol - Sets correlation protocol to use for Application Insights diagnostics. Possible values include: 'HTTPCorrelationProtocolNone', 'HTTPCorrelationProtocolLegacy', 'HTTPCorrelationProtocolW3C' + HTTPCorrelationProtocol HTTPCorrelationProtocol `json:"httpCorrelationProtocol,omitempty"` + // Verbosity - The verbosity level applied to traces emitted by trace policies. Possible values include: 'VerbosityVerbose', 'VerbosityInformation', 'VerbosityError' + Verbosity Verbosity `json:"verbosity,omitempty"` + // OperationNameFormat - The format of the Operation Name for Application Insights telemetries. Default is Name. Possible values include: 'OperationNameFormatName', 'OperationNameFormatURL' + OperationNameFormat OperationNameFormat `json:"operationNameFormat,omitempty"` +} + +// EmailTemplateCollection paged email template list representation. +type EmailTemplateCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]EmailTemplateContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// EmailTemplateCollectionIterator provides access to a complete listing of EmailTemplateContract values. +type EmailTemplateCollectionIterator struct { + i int + page EmailTemplateCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EmailTemplateCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EmailTemplateCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *EmailTemplateCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EmailTemplateCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter EmailTemplateCollectionIterator) Response() EmailTemplateCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter EmailTemplateCollectionIterator) Value() EmailTemplateContract { + if !iter.page.NotDone() { + return EmailTemplateContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EmailTemplateCollectionIterator type. +func NewEmailTemplateCollectionIterator(page EmailTemplateCollectionPage) EmailTemplateCollectionIterator { + return EmailTemplateCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (etc EmailTemplateCollection) IsEmpty() bool { + return etc.Value == nil || len(*etc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (etc EmailTemplateCollection) hasNextLink() bool { + return etc.NextLink != nil && len(*etc.NextLink) != 0 +} + +// emailTemplateCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (etc EmailTemplateCollection) emailTemplateCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !etc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(etc.NextLink))) +} + +// EmailTemplateCollectionPage contains a page of EmailTemplateContract values. +type EmailTemplateCollectionPage struct { + fn func(context.Context, EmailTemplateCollection) (EmailTemplateCollection, error) + etc EmailTemplateCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EmailTemplateCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EmailTemplateCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.etc) + if err != nil { + return err + } + page.etc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *EmailTemplateCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EmailTemplateCollectionPage) NotDone() bool { + return !page.etc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EmailTemplateCollectionPage) Response() EmailTemplateCollection { + return page.etc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EmailTemplateCollectionPage) Values() []EmailTemplateContract { + if page.etc.IsEmpty() { + return nil + } + return *page.etc.Value +} + +// Creates a new instance of the EmailTemplateCollectionPage type. +func NewEmailTemplateCollectionPage(cur EmailTemplateCollection, getNextPage func(context.Context, EmailTemplateCollection) (EmailTemplateCollection, error)) EmailTemplateCollectionPage { + return EmailTemplateCollectionPage{ + fn: getNextPage, + etc: cur, + } +} + +// EmailTemplateContract email Template details. +type EmailTemplateContract struct { + autorest.Response `json:"-"` + // EmailTemplateContractProperties - Email Template entity contract properties. + *EmailTemplateContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for EmailTemplateContract. +func (etc EmailTemplateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if etc.EmailTemplateContractProperties != nil { + objectMap["properties"] = etc.EmailTemplateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EmailTemplateContract struct. +func (etc *EmailTemplateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var emailTemplateContractProperties EmailTemplateContractProperties + err = json.Unmarshal(*v, &emailTemplateContractProperties) + if err != nil { + return err + } + etc.EmailTemplateContractProperties = &emailTemplateContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + etc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + etc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + etc.Type = &typeVar + } + } + } + + return nil +} + +// EmailTemplateContractProperties email Template Contract properties. +type EmailTemplateContractProperties struct { + // Subject - Subject of the Template. + Subject *string `json:"subject,omitempty"` + // Body - Email Template Body. This should be a valid XDocument + Body *string `json:"body,omitempty"` + // Title - Title of the Template. + Title *string `json:"title,omitempty"` + // Description - Description of the Email Template. + Description *string `json:"description,omitempty"` + // IsDefault - READ-ONLY; Whether the template is the default template provided by API Management or has been edited. + IsDefault *bool `json:"isDefault,omitempty"` + // Parameters - Email Template Parameter values. + Parameters *[]EmailTemplateParametersContractProperties `json:"parameters,omitempty"` +} + +// MarshalJSON is the custom marshaler for EmailTemplateContractProperties. +func (etcp EmailTemplateContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if etcp.Subject != nil { + objectMap["subject"] = etcp.Subject + } + if etcp.Body != nil { + objectMap["body"] = etcp.Body + } + if etcp.Title != nil { + objectMap["title"] = etcp.Title + } + if etcp.Description != nil { + objectMap["description"] = etcp.Description + } + if etcp.Parameters != nil { + objectMap["parameters"] = etcp.Parameters + } + return json.Marshal(objectMap) +} + +// EmailTemplateParametersContractProperties email Template Parameter contract. +type EmailTemplateParametersContractProperties struct { + // Name - Template parameter name. + Name *string `json:"name,omitempty"` + // Title - Template parameter title. + Title *string `json:"title,omitempty"` + // Description - Template parameter description. + Description *string `json:"description,omitempty"` +} + +// EmailTemplateUpdateParameterProperties email Template Update Contract properties. +type EmailTemplateUpdateParameterProperties struct { + // Subject - Subject of the Template. + Subject *string `json:"subject,omitempty"` + // Title - Title of the Template. + Title *string `json:"title,omitempty"` + // Description - Description of the Email Template. + Description *string `json:"description,omitempty"` + // Body - Email Template Body. This should be a valid XDocument + Body *string `json:"body,omitempty"` + // Parameters - Email Template Parameter values. + Parameters *[]EmailTemplateParametersContractProperties `json:"parameters,omitempty"` +} + +// EmailTemplateUpdateParameters email Template update Parameters. +type EmailTemplateUpdateParameters struct { + // EmailTemplateUpdateParameterProperties - Email Template Update contract properties. + *EmailTemplateUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for EmailTemplateUpdateParameters. +func (etup EmailTemplateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if etup.EmailTemplateUpdateParameterProperties != nil { + objectMap["properties"] = etup.EmailTemplateUpdateParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EmailTemplateUpdateParameters struct. +func (etup *EmailTemplateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var emailTemplateUpdateParameterProperties EmailTemplateUpdateParameterProperties + err = json.Unmarshal(*v, &emailTemplateUpdateParameterProperties) + if err != nil { + return err + } + etup.EmailTemplateUpdateParameterProperties = &emailTemplateUpdateParameterProperties + } + } + } + + return nil +} + +// ErrorFieldContract error Field contract. +type ErrorFieldContract struct { + // Code - Property level error code. + Code *string `json:"code,omitempty"` + // Message - Human-readable representation of property-level error. + Message *string `json:"message,omitempty"` + // Target - Property name. + Target *string `json:"target,omitempty"` +} + +// ErrorResponse error Response. +type ErrorResponse struct { + // ErrorResponseBody - Properties of the Error Response. + *ErrorResponseBody `json:"error,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorResponse. +func (er ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if er.ErrorResponseBody != nil { + objectMap["error"] = er.ErrorResponseBody + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ErrorResponse struct. +func (er *ErrorResponse) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "error": + if v != nil { + var errorResponseBody ErrorResponseBody + err = json.Unmarshal(*v, &errorResponseBody) + if err != nil { + return err + } + er.ErrorResponseBody = &errorResponseBody + } + } + } + + return nil +} + +// ErrorResponseBody error Body contract. +type ErrorResponseBody struct { + // Code - Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. + Code *string `json:"code,omitempty"` + // Message - Human-readable representation of the error. + Message *string `json:"message,omitempty"` + // Details - The list of invalid fields send in request, in case of validation error. + Details *[]ErrorFieldContract `json:"details,omitempty"` +} + +// GatewayCertificateAuthorityCollection paged Gateway certificate authority list representation. +type GatewayCertificateAuthorityCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]GatewayCertificateAuthorityContract `json:"value,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for GatewayCertificateAuthorityCollection. +func (gcac GatewayCertificateAuthorityCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// GatewayCertificateAuthorityCollectionIterator provides access to a complete listing of +// GatewayCertificateAuthorityContract values. +type GatewayCertificateAuthorityCollectionIterator struct { + i int + page GatewayCertificateAuthorityCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *GatewayCertificateAuthorityCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *GatewayCertificateAuthorityCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter GatewayCertificateAuthorityCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter GatewayCertificateAuthorityCollectionIterator) Response() GatewayCertificateAuthorityCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter GatewayCertificateAuthorityCollectionIterator) Value() GatewayCertificateAuthorityContract { + if !iter.page.NotDone() { + return GatewayCertificateAuthorityContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the GatewayCertificateAuthorityCollectionIterator type. +func NewGatewayCertificateAuthorityCollectionIterator(page GatewayCertificateAuthorityCollectionPage) GatewayCertificateAuthorityCollectionIterator { + return GatewayCertificateAuthorityCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (gcac GatewayCertificateAuthorityCollection) IsEmpty() bool { + return gcac.Value == nil || len(*gcac.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (gcac GatewayCertificateAuthorityCollection) hasNextLink() bool { + return gcac.NextLink != nil && len(*gcac.NextLink) != 0 +} + +// gatewayCertificateAuthorityCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (gcac GatewayCertificateAuthorityCollection) gatewayCertificateAuthorityCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !gcac.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(gcac.NextLink))) +} + +// GatewayCertificateAuthorityCollectionPage contains a page of GatewayCertificateAuthorityContract values. +type GatewayCertificateAuthorityCollectionPage struct { + fn func(context.Context, GatewayCertificateAuthorityCollection) (GatewayCertificateAuthorityCollection, error) + gcac GatewayCertificateAuthorityCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *GatewayCertificateAuthorityCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCertificateAuthorityCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.gcac) + if err != nil { + return err + } + page.gcac = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *GatewayCertificateAuthorityCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page GatewayCertificateAuthorityCollectionPage) NotDone() bool { + return !page.gcac.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page GatewayCertificateAuthorityCollectionPage) Response() GatewayCertificateAuthorityCollection { + return page.gcac +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page GatewayCertificateAuthorityCollectionPage) Values() []GatewayCertificateAuthorityContract { + if page.gcac.IsEmpty() { + return nil + } + return *page.gcac.Value +} + +// Creates a new instance of the GatewayCertificateAuthorityCollectionPage type. +func NewGatewayCertificateAuthorityCollectionPage(cur GatewayCertificateAuthorityCollection, getNextPage func(context.Context, GatewayCertificateAuthorityCollection) (GatewayCertificateAuthorityCollection, error)) GatewayCertificateAuthorityCollectionPage { + return GatewayCertificateAuthorityCollectionPage{ + fn: getNextPage, + gcac: cur, + } +} + +// GatewayCertificateAuthorityContract gateway certificate authority details. +type GatewayCertificateAuthorityContract struct { + autorest.Response `json:"-"` + // GatewayCertificateAuthorityContractProperties - Gateway certificate authority details. + *GatewayCertificateAuthorityContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GatewayCertificateAuthorityContract. +func (gcac GatewayCertificateAuthorityContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gcac.GatewayCertificateAuthorityContractProperties != nil { + objectMap["properties"] = gcac.GatewayCertificateAuthorityContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GatewayCertificateAuthorityContract struct. +func (gcac *GatewayCertificateAuthorityContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var gatewayCertificateAuthorityContractProperties GatewayCertificateAuthorityContractProperties + err = json.Unmarshal(*v, &gatewayCertificateAuthorityContractProperties) + if err != nil { + return err + } + gcac.GatewayCertificateAuthorityContractProperties = &gatewayCertificateAuthorityContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gcac.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gcac.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gcac.Type = &typeVar + } + } + } + + return nil +} + +// GatewayCertificateAuthorityContractProperties gateway certificate authority details. +type GatewayCertificateAuthorityContractProperties struct { + // IsTrusted - Determines whether certificate authority is trusted. + IsTrusted *bool `json:"isTrusted,omitempty"` +} + +// GatewayCollection paged Gateway list representation. +type GatewayCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]GatewayContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for GatewayCollection. +func (gc GatewayCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gc.Count != nil { + objectMap["count"] = gc.Count + } + return json.Marshal(objectMap) +} + +// GatewayCollectionIterator provides access to a complete listing of GatewayContract values. +type GatewayCollectionIterator struct { + i int + page GatewayCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *GatewayCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *GatewayCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter GatewayCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter GatewayCollectionIterator) Response() GatewayCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter GatewayCollectionIterator) Value() GatewayContract { + if !iter.page.NotDone() { + return GatewayContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the GatewayCollectionIterator type. +func NewGatewayCollectionIterator(page GatewayCollectionPage) GatewayCollectionIterator { + return GatewayCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (gc GatewayCollection) IsEmpty() bool { + return gc.Value == nil || len(*gc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (gc GatewayCollection) hasNextLink() bool { + return gc.NextLink != nil && len(*gc.NextLink) != 0 +} + +// gatewayCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (gc GatewayCollection) gatewayCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !gc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(gc.NextLink))) +} + +// GatewayCollectionPage contains a page of GatewayContract values. +type GatewayCollectionPage struct { + fn func(context.Context, GatewayCollection) (GatewayCollection, error) + gc GatewayCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *GatewayCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.gc) + if err != nil { + return err + } + page.gc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *GatewayCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page GatewayCollectionPage) NotDone() bool { + return !page.gc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page GatewayCollectionPage) Response() GatewayCollection { + return page.gc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page GatewayCollectionPage) Values() []GatewayContract { + if page.gc.IsEmpty() { + return nil + } + return *page.gc.Value +} + +// Creates a new instance of the GatewayCollectionPage type. +func NewGatewayCollectionPage(cur GatewayCollection, getNextPage func(context.Context, GatewayCollection) (GatewayCollection, error)) GatewayCollectionPage { + return GatewayCollectionPage{ + fn: getNextPage, + gc: cur, + } +} + +// GatewayContract gateway details. +type GatewayContract struct { + autorest.Response `json:"-"` + // GatewayContractProperties - Gateway details. + *GatewayContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GatewayContract. +func (gc GatewayContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gc.GatewayContractProperties != nil { + objectMap["properties"] = gc.GatewayContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GatewayContract struct. +func (gc *GatewayContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var gatewayContractProperties GatewayContractProperties + err = json.Unmarshal(*v, &gatewayContractProperties) + if err != nil { + return err + } + gc.GatewayContractProperties = &gatewayContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gc.Type = &typeVar + } + } + } + + return nil +} + +// GatewayContractProperties properties of the Gateway contract. +type GatewayContractProperties struct { + // LocationData - Gateway location. + LocationData *ResourceLocationDataContract `json:"locationData,omitempty"` + // Description - Gateway description + Description *string `json:"description,omitempty"` +} + +// GatewayHostnameConfigurationCollection paged Gateway hostname configuration list representation. +type GatewayHostnameConfigurationCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]GatewayHostnameConfigurationContract `json:"value,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for GatewayHostnameConfigurationCollection. +func (ghcc GatewayHostnameConfigurationCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// GatewayHostnameConfigurationCollectionIterator provides access to a complete listing of +// GatewayHostnameConfigurationContract values. +type GatewayHostnameConfigurationCollectionIterator struct { + i int + page GatewayHostnameConfigurationCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *GatewayHostnameConfigurationCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayHostnameConfigurationCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *GatewayHostnameConfigurationCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter GatewayHostnameConfigurationCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter GatewayHostnameConfigurationCollectionIterator) Response() GatewayHostnameConfigurationCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter GatewayHostnameConfigurationCollectionIterator) Value() GatewayHostnameConfigurationContract { + if !iter.page.NotDone() { + return GatewayHostnameConfigurationContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the GatewayHostnameConfigurationCollectionIterator type. +func NewGatewayHostnameConfigurationCollectionIterator(page GatewayHostnameConfigurationCollectionPage) GatewayHostnameConfigurationCollectionIterator { + return GatewayHostnameConfigurationCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ghcc GatewayHostnameConfigurationCollection) IsEmpty() bool { + return ghcc.Value == nil || len(*ghcc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ghcc GatewayHostnameConfigurationCollection) hasNextLink() bool { + return ghcc.NextLink != nil && len(*ghcc.NextLink) != 0 +} + +// gatewayHostnameConfigurationCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ghcc GatewayHostnameConfigurationCollection) gatewayHostnameConfigurationCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !ghcc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ghcc.NextLink))) +} + +// GatewayHostnameConfigurationCollectionPage contains a page of GatewayHostnameConfigurationContract +// values. +type GatewayHostnameConfigurationCollectionPage struct { + fn func(context.Context, GatewayHostnameConfigurationCollection) (GatewayHostnameConfigurationCollection, error) + ghcc GatewayHostnameConfigurationCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *GatewayHostnameConfigurationCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayHostnameConfigurationCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ghcc) + if err != nil { + return err + } + page.ghcc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *GatewayHostnameConfigurationCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page GatewayHostnameConfigurationCollectionPage) NotDone() bool { + return !page.ghcc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page GatewayHostnameConfigurationCollectionPage) Response() GatewayHostnameConfigurationCollection { + return page.ghcc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page GatewayHostnameConfigurationCollectionPage) Values() []GatewayHostnameConfigurationContract { + if page.ghcc.IsEmpty() { + return nil + } + return *page.ghcc.Value +} + +// Creates a new instance of the GatewayHostnameConfigurationCollectionPage type. +func NewGatewayHostnameConfigurationCollectionPage(cur GatewayHostnameConfigurationCollection, getNextPage func(context.Context, GatewayHostnameConfigurationCollection) (GatewayHostnameConfigurationCollection, error)) GatewayHostnameConfigurationCollectionPage { + return GatewayHostnameConfigurationCollectionPage{ + fn: getNextPage, + ghcc: cur, + } +} + +// GatewayHostnameConfigurationContract gateway hostname configuration details. +type GatewayHostnameConfigurationContract struct { + autorest.Response `json:"-"` + // GatewayHostnameConfigurationContractProperties - Gateway hostname configuration details. + *GatewayHostnameConfigurationContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GatewayHostnameConfigurationContract. +func (ghcc GatewayHostnameConfigurationContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ghcc.GatewayHostnameConfigurationContractProperties != nil { + objectMap["properties"] = ghcc.GatewayHostnameConfigurationContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GatewayHostnameConfigurationContract struct. +func (ghcc *GatewayHostnameConfigurationContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var gatewayHostnameConfigurationContractProperties GatewayHostnameConfigurationContractProperties + err = json.Unmarshal(*v, &gatewayHostnameConfigurationContractProperties) + if err != nil { + return err + } + ghcc.GatewayHostnameConfigurationContractProperties = &gatewayHostnameConfigurationContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ghcc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ghcc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ghcc.Type = &typeVar + } + } + } + + return nil +} + +// GatewayHostnameConfigurationContractProperties gateway hostname configuration details. +type GatewayHostnameConfigurationContractProperties struct { + // Hostname - Hostname value. Supports valid domain name, partial or full wildcard + Hostname *string `json:"hostname,omitempty"` + // CertificateID - Identifier of Certificate entity that will be used for TLS connection establishment + CertificateID *string `json:"certificateId,omitempty"` + // NegotiateClientCertificate - Determines whether gateway requests client certificate + NegotiateClientCertificate *bool `json:"negotiateClientCertificate,omitempty"` + // TLS10Enabled - Specifies if TLS 1.0 is supported + TLS10Enabled *bool `json:"tls10Enabled,omitempty"` + // TLS11Enabled - Specifies if TLS 1.1 is supported + TLS11Enabled *bool `json:"tls11Enabled,omitempty"` + // HTTP2Enabled - Specifies if HTTP/2.0 is supported + HTTP2Enabled *bool `json:"http2Enabled,omitempty"` +} + +// GatewayKeyRegenerationRequestContract gateway key regeneration request contract properties. +type GatewayKeyRegenerationRequestContract struct { + // KeyType - The Key being regenerated. Possible values include: 'KeyTypePrimary', 'KeyTypeSecondary' + KeyType KeyType `json:"keyType,omitempty"` +} + +// GatewayKeysContract gateway authentication keys. +type GatewayKeysContract struct { + autorest.Response `json:"-"` + // Primary - Primary gateway key. + Primary *string `json:"primary,omitempty"` + // Secondary - Secondary gateway key. + Secondary *string `json:"secondary,omitempty"` +} + +// GatewayTokenContract gateway access token. +type GatewayTokenContract struct { + autorest.Response `json:"-"` + // Value - Shared Access Authentication token value for the Gateway. + Value *string `json:"value,omitempty"` +} + +// GatewayTokenRequestContract gateway token request contract properties. +type GatewayTokenRequestContract struct { + // KeyType - The Key to be used to generate gateway token. Possible values include: 'KeyTypePrimary', 'KeyTypeSecondary' + KeyType KeyType `json:"keyType,omitempty"` + // Expiry - 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 *date.Time `json:"expiry,omitempty"` +} + +// GenerateSsoURLResult generate SSO Url operations response details. +type GenerateSsoURLResult struct { + autorest.Response `json:"-"` + // Value - Redirect Url containing the SSO URL value. + Value *string `json:"value,omitempty"` +} + +// GroupCollection paged Group list representation. +type GroupCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]GroupContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// GroupCollectionIterator provides access to a complete listing of GroupContract values. +type GroupCollectionIterator struct { + i int + page GroupCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *GroupCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *GroupCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter GroupCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter GroupCollectionIterator) Response() GroupCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter GroupCollectionIterator) Value() GroupContract { + if !iter.page.NotDone() { + return GroupContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the GroupCollectionIterator type. +func NewGroupCollectionIterator(page GroupCollectionPage) GroupCollectionIterator { + return GroupCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (gc GroupCollection) IsEmpty() bool { + return gc.Value == nil || len(*gc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (gc GroupCollection) hasNextLink() bool { + return gc.NextLink != nil && len(*gc.NextLink) != 0 +} + +// groupCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (gc GroupCollection) groupCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !gc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(gc.NextLink))) +} + +// GroupCollectionPage contains a page of GroupContract values. +type GroupCollectionPage struct { + fn func(context.Context, GroupCollection) (GroupCollection, error) + gc GroupCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *GroupCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GroupCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.gc) + if err != nil { + return err + } + page.gc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *GroupCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page GroupCollectionPage) NotDone() bool { + return !page.gc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page GroupCollectionPage) Response() GroupCollection { + return page.gc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page GroupCollectionPage) Values() []GroupContract { + if page.gc.IsEmpty() { + return nil + } + return *page.gc.Value +} + +// Creates a new instance of the GroupCollectionPage type. +func NewGroupCollectionPage(cur GroupCollection, getNextPage func(context.Context, GroupCollection) (GroupCollection, error)) GroupCollectionPage { + return GroupCollectionPage{ + fn: getNextPage, + gc: cur, + } +} + +// GroupContract contract details. +type GroupContract struct { + autorest.Response `json:"-"` + // GroupContractProperties - Group entity contract properties. + *GroupContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GroupContract. +func (gc GroupContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gc.GroupContractProperties != nil { + objectMap["properties"] = gc.GroupContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GroupContract struct. +func (gc *GroupContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var groupContractProperties GroupContractProperties + err = json.Unmarshal(*v, &groupContractProperties) + if err != nil { + return err + } + gc.GroupContractProperties = &groupContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gc.Type = &typeVar + } + } + } + + return nil +} + +// GroupContractProperties group contract Properties. +type GroupContractProperties struct { + // DisplayName - Group name. + DisplayName *string `json:"displayName,omitempty"` + // Description - Group description. Can contain HTML formatting tags. + Description *string `json:"description,omitempty"` + // BuiltIn - READ-ONLY; true if the group is one of the three system groups (Administrators, Developers, or Guests); otherwise false. + BuiltIn *bool `json:"builtIn,omitempty"` + // Type - Group type. Possible values include: 'GroupTypeCustom', 'GroupTypeSystem', 'GroupTypeExternal' + Type GroupType `json:"type,omitempty"` + // ExternalID - For external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory `aad://.onmicrosoft.com/groups/`; otherwise the value is null. + ExternalID *string `json:"externalId,omitempty"` +} + +// MarshalJSON is the custom marshaler for GroupContractProperties. +func (gcp GroupContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gcp.DisplayName != nil { + objectMap["displayName"] = gcp.DisplayName + } + if gcp.Description != nil { + objectMap["description"] = gcp.Description + } + if gcp.Type != "" { + objectMap["type"] = gcp.Type + } + if gcp.ExternalID != nil { + objectMap["externalId"] = gcp.ExternalID + } + return json.Marshal(objectMap) +} + +// GroupCreateParameters parameters supplied to the Create Group operation. +type GroupCreateParameters struct { + // GroupCreateParametersProperties - Properties supplied to Create Group operation. + *GroupCreateParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for GroupCreateParameters. +func (gcp GroupCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gcp.GroupCreateParametersProperties != nil { + objectMap["properties"] = gcp.GroupCreateParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GroupCreateParameters struct. +func (gcp *GroupCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var groupCreateParametersProperties GroupCreateParametersProperties + err = json.Unmarshal(*v, &groupCreateParametersProperties) + if err != nil { + return err + } + gcp.GroupCreateParametersProperties = &groupCreateParametersProperties + } + } + } + + return nil +} + +// GroupCreateParametersProperties parameters supplied to the Create Group operation. +type GroupCreateParametersProperties struct { + // DisplayName - Group name. + DisplayName *string `json:"displayName,omitempty"` + // Description - Group description. + Description *string `json:"description,omitempty"` + // Type - Group type. Possible values include: 'GroupTypeCustom', 'GroupTypeSystem', 'GroupTypeExternal' + Type GroupType `json:"type,omitempty"` + // ExternalID - Identifier of the external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory `aad://.onmicrosoft.com/groups/`; otherwise the value is null. + ExternalID *string `json:"externalId,omitempty"` +} + +// GroupUpdateParameters parameters supplied to the Update Group operation. +type GroupUpdateParameters struct { + // GroupUpdateParametersProperties - Group entity update contract properties. + *GroupUpdateParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for GroupUpdateParameters. +func (gup GroupUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gup.GroupUpdateParametersProperties != nil { + objectMap["properties"] = gup.GroupUpdateParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GroupUpdateParameters struct. +func (gup *GroupUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var groupUpdateParametersProperties GroupUpdateParametersProperties + err = json.Unmarshal(*v, &groupUpdateParametersProperties) + if err != nil { + return err + } + gup.GroupUpdateParametersProperties = &groupUpdateParametersProperties + } + } + } + + return nil +} + +// GroupUpdateParametersProperties parameters supplied to the Update Group operation. +type GroupUpdateParametersProperties struct { + // DisplayName - Group name. + DisplayName *string `json:"displayName,omitempty"` + // Description - Group description. + Description *string `json:"description,omitempty"` + // Type - Group type. Possible values include: 'GroupTypeCustom', 'GroupTypeSystem', 'GroupTypeExternal' + Type GroupType `json:"type,omitempty"` + // ExternalID - Identifier of the external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory `aad://.onmicrosoft.com/groups/`; otherwise the value is null. + ExternalID *string `json:"externalId,omitempty"` +} + +// HostnameConfiguration custom hostname configuration. +type HostnameConfiguration struct { + // Type - Hostname type. Possible values include: 'HostnameTypeProxy', 'HostnameTypePortal', 'HostnameTypeManagement', 'HostnameTypeScm', 'HostnameTypeDeveloperPortal' + Type HostnameType `json:"type,omitempty"` + // HostName - Hostname to configure on the Api Management service. + HostName *string `json:"hostName,omitempty"` + // KeyVaultID - Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url containing version is provided, auto-update of ssl certificate will not work. This requires Api Management service to be configured with aka.ms/apimmsi. The secret should be of type *application/x-pkcs12* + KeyVaultID *string `json:"keyVaultId,omitempty"` + // IdentityClientID - System or User Assigned Managed identity clientId as generated by Azure AD, which has GET access to the keyVault containing the SSL certificate. + IdentityClientID *string `json:"identityClientId,omitempty"` + // EncodedCertificate - Base64 Encoded certificate. + EncodedCertificate *string `json:"encodedCertificate,omitempty"` + // CertificatePassword - Certificate Password. + CertificatePassword *string `json:"certificatePassword,omitempty"` + // DefaultSslBinding - Specify true to setup the certificate associated with this Hostname as the Default SSL Certificate. If a client does not send the SNI header, then this will be the certificate that will be challenged. The property is useful if a service has multiple custom hostname enabled and it needs to decide on the default ssl certificate. The setting only applied to Proxy Hostname Type. + DefaultSslBinding *bool `json:"defaultSslBinding,omitempty"` + // NegotiateClientCertificate - Specify true to always negotiate client certificate on the hostname. Default Value is false. + NegotiateClientCertificate *bool `json:"negotiateClientCertificate,omitempty"` + // Certificate - Certificate information. + Certificate *CertificateInformation `json:"certificate,omitempty"` + // CertificateSource - Certificate Source. Possible values include: 'CertificateSourceManaged', 'CertificateSourceKeyVault', 'CertificateSourceCustom', 'CertificateSourceBuiltIn' + CertificateSource CertificateSource `json:"certificateSource,omitempty"` + // CertificateStatus - Certificate Status. Possible values include: 'CertificateStatusCompleted', 'CertificateStatusFailed', 'CertificateStatusInProgress' + CertificateStatus CertificateStatus `json:"certificateStatus,omitempty"` +} + +// HTTPMessageDiagnostic http message diagnostic settings. +type HTTPMessageDiagnostic struct { + // Headers - Array of HTTP Headers to log. + Headers *[]string `json:"headers,omitempty"` + // Body - Body logging settings. + Body *BodyDiagnosticSettings `json:"body,omitempty"` + // DataMasking - Data masking settings. + DataMasking *DataMasking `json:"dataMasking,omitempty"` +} + +// IdentityProviderBaseParameters identity Provider Base Parameter Properties. +type IdentityProviderBaseParameters struct { + // Type - Identity Provider Type identifier. Possible values include: 'IdentityProviderTypeFacebook', 'IdentityProviderTypeGoogle', 'IdentityProviderTypeMicrosoft', 'IdentityProviderTypeTwitter', 'IdentityProviderTypeAad', 'IdentityProviderTypeAadB2C' + Type IdentityProviderType `json:"type,omitempty"` + // SigninTenant - The TenantId to use instead of Common when logging into Active Directory + SigninTenant *string `json:"signinTenant,omitempty"` + // AllowedTenants - List of Allowed Tenants when configuring Azure Active Directory login. + AllowedTenants *[]string `json:"allowedTenants,omitempty"` + // Authority - OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + Authority *string `json:"authority,omitempty"` + // SignupPolicyName - Signup Policy Name. Only applies to AAD B2C Identity Provider. + SignupPolicyName *string `json:"signupPolicyName,omitempty"` + // SigninPolicyName - Signin Policy Name. Only applies to AAD B2C Identity Provider. + SigninPolicyName *string `json:"signinPolicyName,omitempty"` + // ProfileEditingPolicyName - Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. + ProfileEditingPolicyName *string `json:"profileEditingPolicyName,omitempty"` + // PasswordResetPolicyName - Password Reset Policy Name. Only applies to AAD B2C Identity Provider. + PasswordResetPolicyName *string `json:"passwordResetPolicyName,omitempty"` +} + +// IdentityProviderContract identity Provider details. +type IdentityProviderContract struct { + autorest.Response `json:"-"` + // IdentityProviderContractProperties - Identity Provider contract properties. + *IdentityProviderContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IdentityProviderContract. +func (ipc IdentityProviderContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipc.IdentityProviderContractProperties != nil { + objectMap["properties"] = ipc.IdentityProviderContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IdentityProviderContract struct. +func (ipc *IdentityProviderContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var identityProviderContractProperties IdentityProviderContractProperties + err = json.Unmarshal(*v, &identityProviderContractProperties) + if err != nil { + return err + } + ipc.IdentityProviderContractProperties = &identityProviderContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ipc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ipc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ipc.Type = &typeVar + } + } + } + + return nil +} + +// IdentityProviderContractProperties the external Identity Providers like Facebook, Google, Microsoft, +// Twitter or Azure Active Directory which can be used to enable access to the API Management service +// developer portal for all users. +type IdentityProviderContractProperties struct { + // ClientID - Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + ClientSecret *string `json:"clientSecret,omitempty"` + // Type - Identity Provider Type identifier. Possible values include: 'IdentityProviderTypeFacebook', 'IdentityProviderTypeGoogle', 'IdentityProviderTypeMicrosoft', 'IdentityProviderTypeTwitter', 'IdentityProviderTypeAad', 'IdentityProviderTypeAadB2C' + Type IdentityProviderType `json:"type,omitempty"` + // SigninTenant - The TenantId to use instead of Common when logging into Active Directory + SigninTenant *string `json:"signinTenant,omitempty"` + // AllowedTenants - List of Allowed Tenants when configuring Azure Active Directory login. + AllowedTenants *[]string `json:"allowedTenants,omitempty"` + // Authority - OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + Authority *string `json:"authority,omitempty"` + // SignupPolicyName - Signup Policy Name. Only applies to AAD B2C Identity Provider. + SignupPolicyName *string `json:"signupPolicyName,omitempty"` + // SigninPolicyName - Signin Policy Name. Only applies to AAD B2C Identity Provider. + SigninPolicyName *string `json:"signinPolicyName,omitempty"` + // ProfileEditingPolicyName - Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. + ProfileEditingPolicyName *string `json:"profileEditingPolicyName,omitempty"` + // PasswordResetPolicyName - Password Reset Policy Name. Only applies to AAD B2C Identity Provider. + PasswordResetPolicyName *string `json:"passwordResetPolicyName,omitempty"` +} + +// IdentityProviderCreateContract identity Provider details. +type IdentityProviderCreateContract struct { + // IdentityProviderCreateContractProperties - Identity Provider contract properties. + *IdentityProviderCreateContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IdentityProviderCreateContract. +func (ipcc IdentityProviderCreateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipcc.IdentityProviderCreateContractProperties != nil { + objectMap["properties"] = ipcc.IdentityProviderCreateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IdentityProviderCreateContract struct. +func (ipcc *IdentityProviderCreateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var identityProviderCreateContractProperties IdentityProviderCreateContractProperties + err = json.Unmarshal(*v, &identityProviderCreateContractProperties) + if err != nil { + return err + } + ipcc.IdentityProviderCreateContractProperties = &identityProviderCreateContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ipcc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ipcc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ipcc.Type = &typeVar + } + } + } + + return nil +} + +// IdentityProviderCreateContractProperties the external Identity Providers like Facebook, Google, +// Microsoft, Twitter or Azure Active Directory which can be used to enable access to the API Management +// service developer portal for all users. +type IdentityProviderCreateContractProperties struct { + // ClientID - Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + ClientSecret *string `json:"clientSecret,omitempty"` + // Type - Identity Provider Type identifier. Possible values include: 'IdentityProviderTypeFacebook', 'IdentityProviderTypeGoogle', 'IdentityProviderTypeMicrosoft', 'IdentityProviderTypeTwitter', 'IdentityProviderTypeAad', 'IdentityProviderTypeAadB2C' + Type IdentityProviderType `json:"type,omitempty"` + // SigninTenant - The TenantId to use instead of Common when logging into Active Directory + SigninTenant *string `json:"signinTenant,omitempty"` + // AllowedTenants - List of Allowed Tenants when configuring Azure Active Directory login. + AllowedTenants *[]string `json:"allowedTenants,omitempty"` + // Authority - OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + Authority *string `json:"authority,omitempty"` + // SignupPolicyName - Signup Policy Name. Only applies to AAD B2C Identity Provider. + SignupPolicyName *string `json:"signupPolicyName,omitempty"` + // SigninPolicyName - Signin Policy Name. Only applies to AAD B2C Identity Provider. + SigninPolicyName *string `json:"signinPolicyName,omitempty"` + // ProfileEditingPolicyName - Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. + ProfileEditingPolicyName *string `json:"profileEditingPolicyName,omitempty"` + // PasswordResetPolicyName - Password Reset Policy Name. Only applies to AAD B2C Identity Provider. + PasswordResetPolicyName *string `json:"passwordResetPolicyName,omitempty"` +} + +// IdentityProviderList list of all the Identity Providers configured on the service instance. +type IdentityProviderList struct { + autorest.Response `json:"-"` + // Value - Identity Provider configuration values. + Value *[]IdentityProviderContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// IdentityProviderListIterator provides access to a complete listing of IdentityProviderContract values. +type IdentityProviderListIterator struct { + i int + page IdentityProviderListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IdentityProviderListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IdentityProviderListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IdentityProviderListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IdentityProviderListIterator) Response() IdentityProviderList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IdentityProviderListIterator) Value() IdentityProviderContract { + if !iter.page.NotDone() { + return IdentityProviderContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IdentityProviderListIterator type. +func NewIdentityProviderListIterator(page IdentityProviderListPage) IdentityProviderListIterator { + return IdentityProviderListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ipl IdentityProviderList) IsEmpty() bool { + return ipl.Value == nil || len(*ipl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ipl IdentityProviderList) hasNextLink() bool { + return ipl.NextLink != nil && len(*ipl.NextLink) != 0 +} + +// identityProviderListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ipl IdentityProviderList) identityProviderListPreparer(ctx context.Context) (*http.Request, error) { + if !ipl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ipl.NextLink))) +} + +// IdentityProviderListPage contains a page of IdentityProviderContract values. +type IdentityProviderListPage struct { + fn func(context.Context, IdentityProviderList) (IdentityProviderList, error) + ipl IdentityProviderList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IdentityProviderListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IdentityProviderListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ipl) + if err != nil { + return err + } + page.ipl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IdentityProviderListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IdentityProviderListPage) NotDone() bool { + return !page.ipl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IdentityProviderListPage) Response() IdentityProviderList { + return page.ipl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IdentityProviderListPage) Values() []IdentityProviderContract { + if page.ipl.IsEmpty() { + return nil + } + return *page.ipl.Value +} + +// Creates a new instance of the IdentityProviderListPage type. +func NewIdentityProviderListPage(cur IdentityProviderList, getNextPage func(context.Context, IdentityProviderList) (IdentityProviderList, error)) IdentityProviderListPage { + return IdentityProviderListPage{ + fn: getNextPage, + ipl: cur, + } +} + +// IdentityProviderUpdateParameters parameters supplied to update Identity Provider +type IdentityProviderUpdateParameters struct { + // IdentityProviderUpdateProperties - Identity Provider update properties. + *IdentityProviderUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IdentityProviderUpdateParameters. +func (ipup IdentityProviderUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipup.IdentityProviderUpdateProperties != nil { + objectMap["properties"] = ipup.IdentityProviderUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IdentityProviderUpdateParameters struct. +func (ipup *IdentityProviderUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var identityProviderUpdateProperties IdentityProviderUpdateProperties + err = json.Unmarshal(*v, &identityProviderUpdateProperties) + if err != nil { + return err + } + ipup.IdentityProviderUpdateProperties = &identityProviderUpdateProperties + } + } + } + + return nil +} + +// IdentityProviderUpdateProperties parameters supplied to the Update Identity Provider operation. +type IdentityProviderUpdateProperties struct { + // ClientID - Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key for Microsoft. + ClientSecret *string `json:"clientSecret,omitempty"` + // Type - Identity Provider Type identifier. Possible values include: 'IdentityProviderTypeFacebook', 'IdentityProviderTypeGoogle', 'IdentityProviderTypeMicrosoft', 'IdentityProviderTypeTwitter', 'IdentityProviderTypeAad', 'IdentityProviderTypeAadB2C' + Type IdentityProviderType `json:"type,omitempty"` + // SigninTenant - The TenantId to use instead of Common when logging into Active Directory + SigninTenant *string `json:"signinTenant,omitempty"` + // AllowedTenants - List of Allowed Tenants when configuring Azure Active Directory login. + AllowedTenants *[]string `json:"allowedTenants,omitempty"` + // Authority - OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + Authority *string `json:"authority,omitempty"` + // SignupPolicyName - Signup Policy Name. Only applies to AAD B2C Identity Provider. + SignupPolicyName *string `json:"signupPolicyName,omitempty"` + // SigninPolicyName - Signin Policy Name. Only applies to AAD B2C Identity Provider. + SigninPolicyName *string `json:"signinPolicyName,omitempty"` + // ProfileEditingPolicyName - Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. + ProfileEditingPolicyName *string `json:"profileEditingPolicyName,omitempty"` + // PasswordResetPolicyName - Password Reset Policy Name. Only applies to AAD B2C Identity Provider. + PasswordResetPolicyName *string `json:"passwordResetPolicyName,omitempty"` +} + +// IssueAttachmentCollection paged Issue Attachment list representation. +type IssueAttachmentCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Issue Attachment values. + Value *[]IssueAttachmentContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IssueAttachmentCollection. +func (iac IssueAttachmentCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if iac.Count != nil { + objectMap["count"] = iac.Count + } + return json.Marshal(objectMap) +} + +// IssueAttachmentCollectionIterator provides access to a complete listing of IssueAttachmentContract +// values. +type IssueAttachmentCollectionIterator struct { + i int + page IssueAttachmentCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IssueAttachmentCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IssueAttachmentCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IssueAttachmentCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IssueAttachmentCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IssueAttachmentCollectionIterator) Response() IssueAttachmentCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IssueAttachmentCollectionIterator) Value() IssueAttachmentContract { + if !iter.page.NotDone() { + return IssueAttachmentContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IssueAttachmentCollectionIterator type. +func NewIssueAttachmentCollectionIterator(page IssueAttachmentCollectionPage) IssueAttachmentCollectionIterator { + return IssueAttachmentCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (iac IssueAttachmentCollection) IsEmpty() bool { + return iac.Value == nil || len(*iac.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (iac IssueAttachmentCollection) hasNextLink() bool { + return iac.NextLink != nil && len(*iac.NextLink) != 0 +} + +// issueAttachmentCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (iac IssueAttachmentCollection) issueAttachmentCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !iac.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(iac.NextLink))) +} + +// IssueAttachmentCollectionPage contains a page of IssueAttachmentContract values. +type IssueAttachmentCollectionPage struct { + fn func(context.Context, IssueAttachmentCollection) (IssueAttachmentCollection, error) + iac IssueAttachmentCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IssueAttachmentCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IssueAttachmentCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.iac) + if err != nil { + return err + } + page.iac = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IssueAttachmentCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IssueAttachmentCollectionPage) NotDone() bool { + return !page.iac.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IssueAttachmentCollectionPage) Response() IssueAttachmentCollection { + return page.iac +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IssueAttachmentCollectionPage) Values() []IssueAttachmentContract { + if page.iac.IsEmpty() { + return nil + } + return *page.iac.Value +} + +// Creates a new instance of the IssueAttachmentCollectionPage type. +func NewIssueAttachmentCollectionPage(cur IssueAttachmentCollection, getNextPage func(context.Context, IssueAttachmentCollection) (IssueAttachmentCollection, error)) IssueAttachmentCollectionPage { + return IssueAttachmentCollectionPage{ + fn: getNextPage, + iac: cur, + } +} + +// IssueAttachmentContract issue Attachment Contract details. +type IssueAttachmentContract struct { + autorest.Response `json:"-"` + // IssueAttachmentContractProperties - Properties of the Issue Attachment. + *IssueAttachmentContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IssueAttachmentContract. +func (iac IssueAttachmentContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if iac.IssueAttachmentContractProperties != nil { + objectMap["properties"] = iac.IssueAttachmentContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IssueAttachmentContract struct. +func (iac *IssueAttachmentContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var issueAttachmentContractProperties IssueAttachmentContractProperties + err = json.Unmarshal(*v, &issueAttachmentContractProperties) + if err != nil { + return err + } + iac.IssueAttachmentContractProperties = &issueAttachmentContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + iac.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + iac.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + iac.Type = &typeVar + } + } + } + + return nil +} + +// IssueAttachmentContractProperties issue Attachment contract Properties. +type IssueAttachmentContractProperties struct { + // Title - Filename by which the binary data will be saved. + Title *string `json:"title,omitempty"` + // ContentFormat - Either 'link' if content is provided via an HTTP link or the MIME type of the Base64-encoded binary data provided in the 'content' property. + ContentFormat *string `json:"contentFormat,omitempty"` + // Content - An HTTP link or Base64-encoded binary data. + Content *string `json:"content,omitempty"` +} + +// IssueCollection paged Issue list representation. +type IssueCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Issue values. + Value *[]IssueContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IssueCollection. +func (ic IssueCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ic.Count != nil { + objectMap["count"] = ic.Count + } + return json.Marshal(objectMap) +} + +// IssueCollectionIterator provides access to a complete listing of IssueContract values. +type IssueCollectionIterator struct { + i int + page IssueCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IssueCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IssueCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IssueCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IssueCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IssueCollectionIterator) Response() IssueCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IssueCollectionIterator) Value() IssueContract { + if !iter.page.NotDone() { + return IssueContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IssueCollectionIterator type. +func NewIssueCollectionIterator(page IssueCollectionPage) IssueCollectionIterator { + return IssueCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ic IssueCollection) IsEmpty() bool { + return ic.Value == nil || len(*ic.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ic IssueCollection) hasNextLink() bool { + return ic.NextLink != nil && len(*ic.NextLink) != 0 +} + +// issueCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ic IssueCollection) issueCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !ic.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ic.NextLink))) +} + +// IssueCollectionPage contains a page of IssueContract values. +type IssueCollectionPage struct { + fn func(context.Context, IssueCollection) (IssueCollection, error) + ic IssueCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IssueCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IssueCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ic) + if err != nil { + return err + } + page.ic = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IssueCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IssueCollectionPage) NotDone() bool { + return !page.ic.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IssueCollectionPage) Response() IssueCollection { + return page.ic +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IssueCollectionPage) Values() []IssueContract { + if page.ic.IsEmpty() { + return nil + } + return *page.ic.Value +} + +// Creates a new instance of the IssueCollectionPage type. +func NewIssueCollectionPage(cur IssueCollection, getNextPage func(context.Context, IssueCollection) (IssueCollection, error)) IssueCollectionPage { + return IssueCollectionPage{ + fn: getNextPage, + ic: cur, + } +} + +// IssueCommentCollection paged Issue Comment list representation. +type IssueCommentCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Issue Comment values. + Value *[]IssueCommentContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IssueCommentCollection. +func (icc IssueCommentCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if icc.Count != nil { + objectMap["count"] = icc.Count + } + return json.Marshal(objectMap) +} + +// IssueCommentCollectionIterator provides access to a complete listing of IssueCommentContract values. +type IssueCommentCollectionIterator struct { + i int + page IssueCommentCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IssueCommentCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IssueCommentCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IssueCommentCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IssueCommentCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IssueCommentCollectionIterator) Response() IssueCommentCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IssueCommentCollectionIterator) Value() IssueCommentContract { + if !iter.page.NotDone() { + return IssueCommentContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IssueCommentCollectionIterator type. +func NewIssueCommentCollectionIterator(page IssueCommentCollectionPage) IssueCommentCollectionIterator { + return IssueCommentCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (icc IssueCommentCollection) IsEmpty() bool { + return icc.Value == nil || len(*icc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (icc IssueCommentCollection) hasNextLink() bool { + return icc.NextLink != nil && len(*icc.NextLink) != 0 +} + +// issueCommentCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (icc IssueCommentCollection) issueCommentCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !icc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(icc.NextLink))) +} + +// IssueCommentCollectionPage contains a page of IssueCommentContract values. +type IssueCommentCollectionPage struct { + fn func(context.Context, IssueCommentCollection) (IssueCommentCollection, error) + icc IssueCommentCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IssueCommentCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IssueCommentCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.icc) + if err != nil { + return err + } + page.icc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IssueCommentCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IssueCommentCollectionPage) NotDone() bool { + return !page.icc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IssueCommentCollectionPage) Response() IssueCommentCollection { + return page.icc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IssueCommentCollectionPage) Values() []IssueCommentContract { + if page.icc.IsEmpty() { + return nil + } + return *page.icc.Value +} + +// Creates a new instance of the IssueCommentCollectionPage type. +func NewIssueCommentCollectionPage(cur IssueCommentCollection, getNextPage func(context.Context, IssueCommentCollection) (IssueCommentCollection, error)) IssueCommentCollectionPage { + return IssueCommentCollectionPage{ + fn: getNextPage, + icc: cur, + } +} + +// IssueCommentContract issue Comment Contract details. +type IssueCommentContract struct { + autorest.Response `json:"-"` + // IssueCommentContractProperties - Properties of the Issue Comment. + *IssueCommentContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IssueCommentContract. +func (icc IssueCommentContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if icc.IssueCommentContractProperties != nil { + objectMap["properties"] = icc.IssueCommentContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IssueCommentContract struct. +func (icc *IssueCommentContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var issueCommentContractProperties IssueCommentContractProperties + err = json.Unmarshal(*v, &issueCommentContractProperties) + if err != nil { + return err + } + icc.IssueCommentContractProperties = &issueCommentContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + icc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + icc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + icc.Type = &typeVar + } + } + } + + return nil +} + +// IssueCommentContractProperties issue Comment contract Properties. +type IssueCommentContractProperties struct { + // Text - Comment text. + Text *string `json:"text,omitempty"` + // CreatedDate - Date and time when the comment was created. + CreatedDate *date.Time `json:"createdDate,omitempty"` + // UserID - A resource identifier for the user who left the comment. + UserID *string `json:"userId,omitempty"` +} + +// IssueContract issue Contract details. +type IssueContract struct { + autorest.Response `json:"-"` + // IssueContractProperties - Properties of the Issue. + *IssueContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IssueContract. +func (ic IssueContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ic.IssueContractProperties != nil { + objectMap["properties"] = ic.IssueContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IssueContract struct. +func (ic *IssueContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var issueContractProperties IssueContractProperties + err = json.Unmarshal(*v, &issueContractProperties) + if err != nil { + return err + } + ic.IssueContractProperties = &issueContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ic.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ic.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ic.Type = &typeVar + } + } + } + + return nil +} + +// IssueContractBaseProperties issue contract Base Properties. +type IssueContractBaseProperties struct { + // CreatedDate - Date and time when the issue was created. + CreatedDate *date.Time `json:"createdDate,omitempty"` + // State - Status of the issue. Possible values include: 'StateProposed', 'StateOpen', 'StateRemoved', 'StateResolved', 'StateClosed' + State State `json:"state,omitempty"` + // APIID - A resource identifier for the API the issue was created for. + APIID *string `json:"apiId,omitempty"` +} + +// IssueContractProperties issue contract Properties. +type IssueContractProperties struct { + // Title - The issue title. + Title *string `json:"title,omitempty"` + // Description - Text describing the issue. + Description *string `json:"description,omitempty"` + // UserID - A resource identifier for the user created the issue. + UserID *string `json:"userId,omitempty"` + // CreatedDate - Date and time when the issue was created. + CreatedDate *date.Time `json:"createdDate,omitempty"` + // State - Status of the issue. Possible values include: 'StateProposed', 'StateOpen', 'StateRemoved', 'StateResolved', 'StateClosed' + State State `json:"state,omitempty"` + // APIID - A resource identifier for the API the issue was created for. + APIID *string `json:"apiId,omitempty"` +} + +// IssueUpdateContract issue update Parameters. +type IssueUpdateContract struct { + // IssueUpdateContractProperties - Issue entity Update contract properties. + *IssueUpdateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IssueUpdateContract. +func (iuc IssueUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if iuc.IssueUpdateContractProperties != nil { + objectMap["properties"] = iuc.IssueUpdateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IssueUpdateContract struct. +func (iuc *IssueUpdateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var issueUpdateContractProperties IssueUpdateContractProperties + err = json.Unmarshal(*v, &issueUpdateContractProperties) + if err != nil { + return err + } + iuc.IssueUpdateContractProperties = &issueUpdateContractProperties + } + } + } + + return nil +} + +// IssueUpdateContractProperties issue contract Update Properties. +type IssueUpdateContractProperties struct { + // Title - The issue title. + Title *string `json:"title,omitempty"` + // Description - Text describing the issue. + Description *string `json:"description,omitempty"` + // UserID - A resource identifier for the user created the issue. + UserID *string `json:"userId,omitempty"` + // CreatedDate - Date and time when the issue was created. + CreatedDate *date.Time `json:"createdDate,omitempty"` + // State - Status of the issue. Possible values include: 'StateProposed', 'StateOpen', 'StateRemoved', 'StateResolved', 'StateClosed' + State State `json:"state,omitempty"` + // APIID - A resource identifier for the API the issue was created for. + APIID *string `json:"apiId,omitempty"` +} + +// KeyVaultContractCreateProperties create keyVault contract details. +type KeyVaultContractCreateProperties struct { + // SecretIdentifier - Key vault secret identifier for fetching secret. Providing a versioned secret will prevent auto-refresh. This requires API Management service to be configured with aka.ms/apimmsi + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + // IdentityClientID - SystemAssignedIdentity or UserAssignedIdentity Client Id which will be used to access key vault secret. + IdentityClientID *string `json:"identityClientId,omitempty"` +} + +// KeyVaultContractProperties keyVault contract details. +type KeyVaultContractProperties struct { + // LastStatus - Last time sync and refresh status of secret from key vault. + LastStatus *KeyVaultLastAccessStatusContractProperties `json:"lastStatus,omitempty"` + // SecretIdentifier - Key vault secret identifier for fetching secret. Providing a versioned secret will prevent auto-refresh. This requires API Management service to be configured with aka.ms/apimmsi + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + // IdentityClientID - SystemAssignedIdentity or UserAssignedIdentity Client Id which will be used to access key vault secret. + IdentityClientID *string `json:"identityClientId,omitempty"` +} + +// KeyVaultLastAccessStatusContractProperties issue contract Update Properties. +type KeyVaultLastAccessStatusContractProperties struct { + // Code - Last status code for sync and refresh of secret from key vault. + Code *string `json:"code,omitempty"` + // Message - Details of the error else empty. + Message *string `json:"message,omitempty"` + // TimeStampUtc - Last time secret was accessed. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + TimeStampUtc *date.Time `json:"timeStampUtc,omitempty"` +} + +// ListNetworkStatusContractByLocation ... +type ListNetworkStatusContractByLocation struct { + autorest.Response `json:"-"` + Value *[]NetworkStatusContractByLocation `json:"value,omitempty"` +} + +// LoggerCollection paged Logger list representation. +type LoggerCollection struct { + autorest.Response `json:"-"` + // Value - Logger values. + Value *[]LoggerContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// LoggerCollectionIterator provides access to a complete listing of LoggerContract values. +type LoggerCollectionIterator struct { + i int + page LoggerCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *LoggerCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LoggerCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LoggerCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LoggerCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter LoggerCollectionIterator) Response() LoggerCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter LoggerCollectionIterator) Value() LoggerContract { + if !iter.page.NotDone() { + return LoggerContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LoggerCollectionIterator type. +func NewLoggerCollectionIterator(page LoggerCollectionPage) LoggerCollectionIterator { + return LoggerCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (lc LoggerCollection) IsEmpty() bool { + return lc.Value == nil || len(*lc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (lc LoggerCollection) hasNextLink() bool { + return lc.NextLink != nil && len(*lc.NextLink) != 0 +} + +// loggerCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lc LoggerCollection) loggerCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !lc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lc.NextLink))) +} + +// LoggerCollectionPage contains a page of LoggerContract values. +type LoggerCollectionPage struct { + fn func(context.Context, LoggerCollection) (LoggerCollection, error) + lc LoggerCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *LoggerCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LoggerCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.lc) + if err != nil { + return err + } + page.lc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *LoggerCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LoggerCollectionPage) NotDone() bool { + return !page.lc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LoggerCollectionPage) Response() LoggerCollection { + return page.lc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LoggerCollectionPage) Values() []LoggerContract { + if page.lc.IsEmpty() { + return nil + } + return *page.lc.Value +} + +// Creates a new instance of the LoggerCollectionPage type. +func NewLoggerCollectionPage(cur LoggerCollection, getNextPage func(context.Context, LoggerCollection) (LoggerCollection, error)) LoggerCollectionPage { + return LoggerCollectionPage{ + fn: getNextPage, + lc: cur, + } +} + +// LoggerContract logger details. +type LoggerContract struct { + autorest.Response `json:"-"` + // LoggerContractProperties - Logger entity contract properties. + *LoggerContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LoggerContract. +func (lc LoggerContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lc.LoggerContractProperties != nil { + objectMap["properties"] = lc.LoggerContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LoggerContract struct. +func (lc *LoggerContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var loggerContractProperties LoggerContractProperties + err = json.Unmarshal(*v, &loggerContractProperties) + if err != nil { + return err + } + lc.LoggerContractProperties = &loggerContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + lc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + lc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + lc.Type = &typeVar + } + } + } + + return nil +} + +// LoggerContractProperties the Logger entity in API Management represents an event sink that you can use +// to log API Management events. Currently the Logger entity supports logging API Management events to +// Azure Event Hubs. +type LoggerContractProperties struct { + // LoggerType - Logger type. Possible values include: 'LoggerTypeAzureEventHub', 'LoggerTypeApplicationInsights', 'LoggerTypeAzureMonitor' + LoggerType LoggerType `json:"loggerType,omitempty"` + // Description - Logger description. + Description *string `json:"description,omitempty"` + // Credentials - The name and SendRule connection string of the event hub for azureEventHub logger. + // Instrumentation key for applicationInsights logger. + Credentials map[string]*string `json:"credentials"` + // IsBuffered - Whether records are buffered in the logger before publishing. Default is assumed to be true. + IsBuffered *bool `json:"isBuffered,omitempty"` + // ResourceID - Azure Resource Id of a log target (either Azure Event Hub resource or Azure Application Insights resource). + ResourceID *string `json:"resourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for LoggerContractProperties. +func (lcp LoggerContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lcp.LoggerType != "" { + objectMap["loggerType"] = lcp.LoggerType + } + if lcp.Description != nil { + objectMap["description"] = lcp.Description + } + if lcp.Credentials != nil { + objectMap["credentials"] = lcp.Credentials + } + if lcp.IsBuffered != nil { + objectMap["isBuffered"] = lcp.IsBuffered + } + if lcp.ResourceID != nil { + objectMap["resourceId"] = lcp.ResourceID + } + return json.Marshal(objectMap) +} + +// LoggerUpdateContract logger update contract. +type LoggerUpdateContract struct { + // LoggerUpdateParameters - Logger entity update contract properties. + *LoggerUpdateParameters `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for LoggerUpdateContract. +func (luc LoggerUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if luc.LoggerUpdateParameters != nil { + objectMap["properties"] = luc.LoggerUpdateParameters + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LoggerUpdateContract struct. +func (luc *LoggerUpdateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var loggerUpdateParameters LoggerUpdateParameters + err = json.Unmarshal(*v, &loggerUpdateParameters) + if err != nil { + return err + } + luc.LoggerUpdateParameters = &loggerUpdateParameters + } + } + } + + return nil +} + +// LoggerUpdateParameters parameters supplied to the Update Logger operation. +type LoggerUpdateParameters struct { + // LoggerType - Logger type. Possible values include: 'LoggerTypeAzureEventHub', 'LoggerTypeApplicationInsights', 'LoggerTypeAzureMonitor' + LoggerType LoggerType `json:"loggerType,omitempty"` + // Description - Logger description. + Description *string `json:"description,omitempty"` + // Credentials - Logger credentials. + Credentials map[string]*string `json:"credentials"` + // IsBuffered - Whether records are buffered in the logger before publishing. Default is assumed to be true. + IsBuffered *bool `json:"isBuffered,omitempty"` +} + +// MarshalJSON is the custom marshaler for LoggerUpdateParameters. +func (lup LoggerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lup.LoggerType != "" { + objectMap["loggerType"] = lup.LoggerType + } + if lup.Description != nil { + objectMap["description"] = lup.Description + } + if lup.Credentials != nil { + objectMap["credentials"] = lup.Credentials + } + if lup.IsBuffered != nil { + objectMap["isBuffered"] = lup.IsBuffered + } + return json.Marshal(objectMap) +} + +// NamedValueCollection paged NamedValue list representation. +type NamedValueCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]NamedValueContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// NamedValueCollectionIterator provides access to a complete listing of NamedValueContract values. +type NamedValueCollectionIterator struct { + i int + page NamedValueCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *NamedValueCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *NamedValueCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter NamedValueCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter NamedValueCollectionIterator) Response() NamedValueCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter NamedValueCollectionIterator) Value() NamedValueContract { + if !iter.page.NotDone() { + return NamedValueContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the NamedValueCollectionIterator type. +func NewNamedValueCollectionIterator(page NamedValueCollectionPage) NamedValueCollectionIterator { + return NamedValueCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (nvc NamedValueCollection) IsEmpty() bool { + return nvc.Value == nil || len(*nvc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (nvc NamedValueCollection) hasNextLink() bool { + return nvc.NextLink != nil && len(*nvc.NextLink) != 0 +} + +// namedValueCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (nvc NamedValueCollection) namedValueCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !nvc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(nvc.NextLink))) +} + +// NamedValueCollectionPage contains a page of NamedValueContract values. +type NamedValueCollectionPage struct { + fn func(context.Context, NamedValueCollection) (NamedValueCollection, error) + nvc NamedValueCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *NamedValueCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.nvc) + if err != nil { + return err + } + page.nvc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *NamedValueCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page NamedValueCollectionPage) NotDone() bool { + return !page.nvc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page NamedValueCollectionPage) Response() NamedValueCollection { + return page.nvc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page NamedValueCollectionPage) Values() []NamedValueContract { + if page.nvc.IsEmpty() { + return nil + } + return *page.nvc.Value +} + +// Creates a new instance of the NamedValueCollectionPage type. +func NewNamedValueCollectionPage(cur NamedValueCollection, getNextPage func(context.Context, NamedValueCollection) (NamedValueCollection, error)) NamedValueCollectionPage { + return NamedValueCollectionPage{ + fn: getNextPage, + nvc: cur, + } +} + +// NamedValueContract namedValue details. +type NamedValueContract struct { + autorest.Response `json:"-"` + // NamedValueContractProperties - NamedValue entity contract properties. + *NamedValueContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for NamedValueContract. +func (nvc NamedValueContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if nvc.NamedValueContractProperties != nil { + objectMap["properties"] = nvc.NamedValueContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for NamedValueContract struct. +func (nvc *NamedValueContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var namedValueContractProperties NamedValueContractProperties + err = json.Unmarshal(*v, &namedValueContractProperties) + if err != nil { + return err + } + nvc.NamedValueContractProperties = &namedValueContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + nvc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + nvc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + nvc.Type = &typeVar + } + } + } + + return nil +} + +// NamedValueContractProperties namedValue Contract properties. +type NamedValueContractProperties struct { + // DisplayName - Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. + DisplayName *string `json:"displayName,omitempty"` + // Value - Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of whitespace. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + Value *string `json:"value,omitempty"` + // KeyVault - KeyVault location details of the namedValue. + KeyVault *KeyVaultContractProperties `json:"keyVault,omitempty"` + // Tags - Optional tags that when provided can be used to filter the NamedValue list. + Tags *[]string `json:"tags,omitempty"` + // Secret - Determines whether the value is a secret and should be encrypted or not. Default value is false. + Secret *bool `json:"secret,omitempty"` +} + +// NamedValueCreateContract namedValue details. +type NamedValueCreateContract struct { + // NamedValueCreateContractProperties - NamedValue entity contract properties for PUT operation. + *NamedValueCreateContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for NamedValueCreateContract. +func (nvcc NamedValueCreateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if nvcc.NamedValueCreateContractProperties != nil { + objectMap["properties"] = nvcc.NamedValueCreateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for NamedValueCreateContract struct. +func (nvcc *NamedValueCreateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var namedValueCreateContractProperties NamedValueCreateContractProperties + err = json.Unmarshal(*v, &namedValueCreateContractProperties) + if err != nil { + return err + } + nvcc.NamedValueCreateContractProperties = &namedValueCreateContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + nvcc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + nvcc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + nvcc.Type = &typeVar + } + } + } + + return nil +} + +// NamedValueCreateContractProperties namedValue Contract properties. +type NamedValueCreateContractProperties struct { + // DisplayName - Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. + DisplayName *string `json:"displayName,omitempty"` + // Value - Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of whitespace. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + Value *string `json:"value,omitempty"` + // KeyVault - KeyVault location details of the namedValue. + KeyVault *KeyVaultContractCreateProperties `json:"keyVault,omitempty"` + // Tags - Optional tags that when provided can be used to filter the NamedValue list. + Tags *[]string `json:"tags,omitempty"` + // Secret - Determines whether the value is a secret and should be encrypted or not. Default value is false. + Secret *bool `json:"secret,omitempty"` +} + +// NamedValueCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type NamedValueCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NamedValueClient) (NamedValueContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *NamedValueCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for NamedValueCreateOrUpdateFuture.Result. +func (future *NamedValueCreateOrUpdateFuture) result(client NamedValueClient) (nvc NamedValueContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + nvc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.NamedValueCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if nvc.Response.Response, err = future.GetResult(sender); err == nil && nvc.Response.Response.StatusCode != http.StatusNoContent { + nvc, err = client.CreateOrUpdateResponder(nvc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueCreateOrUpdateFuture", "Result", nvc.Response.Response, "Failure responding to request") + } + } + return +} + +// NamedValueEntityBaseParameters namedValue Entity Base Parameters set. +type NamedValueEntityBaseParameters struct { + // Tags - Optional tags that when provided can be used to filter the NamedValue list. + Tags *[]string `json:"tags,omitempty"` + // Secret - Determines whether the value is a secret and should be encrypted or not. Default value is false. + Secret *bool `json:"secret,omitempty"` +} + +// NamedValueRefreshSecretFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type NamedValueRefreshSecretFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NamedValueClient) (NamedValueContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *NamedValueRefreshSecretFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for NamedValueRefreshSecretFuture.Result. +func (future *NamedValueRefreshSecretFuture) result(client NamedValueClient) (nvc NamedValueContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueRefreshSecretFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + nvc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.NamedValueRefreshSecretFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if nvc.Response.Response, err = future.GetResult(sender); err == nil && nvc.Response.Response.StatusCode != http.StatusNoContent { + nvc, err = client.RefreshSecretResponder(nvc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueRefreshSecretFuture", "Result", nvc.Response.Response, "Failure responding to request") + } + } + return +} + +// NamedValueSecretContract client or app secret used in IdentityProviders, Aad, OpenID or OAuth. +type NamedValueSecretContract struct { + autorest.Response `json:"-"` + // Value - This is secret value of the NamedValue entity. + Value *string `json:"value,omitempty"` +} + +// NamedValueUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type NamedValueUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NamedValueClient) (NamedValueContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *NamedValueUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for NamedValueUpdateFuture.Result. +func (future *NamedValueUpdateFuture) result(client NamedValueClient) (nvc NamedValueContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + nvc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.NamedValueUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if nvc.Response.Response, err = future.GetResult(sender); err == nil && nvc.Response.Response.StatusCode != http.StatusNoContent { + nvc, err = client.UpdateResponder(nvc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueUpdateFuture", "Result", nvc.Response.Response, "Failure responding to request") + } + } + return +} + +// NamedValueUpdateParameterProperties namedValue Contract properties. +type NamedValueUpdateParameterProperties struct { + // DisplayName - Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. + DisplayName *string `json:"displayName,omitempty"` + // Value - Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of whitespace. + Value *string `json:"value,omitempty"` + // KeyVault - KeyVault location details of the namedValue. + KeyVault *KeyVaultContractCreateProperties `json:"keyVault,omitempty"` + // Tags - Optional tags that when provided can be used to filter the NamedValue list. + Tags *[]string `json:"tags,omitempty"` + // Secret - Determines whether the value is a secret and should be encrypted or not. Default value is false. + Secret *bool `json:"secret,omitempty"` +} + +// NamedValueUpdateParameters namedValue update Parameters. +type NamedValueUpdateParameters struct { + // NamedValueUpdateParameterProperties - NamedValue entity Update contract properties. + *NamedValueUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for NamedValueUpdateParameters. +func (nvup NamedValueUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if nvup.NamedValueUpdateParameterProperties != nil { + objectMap["properties"] = nvup.NamedValueUpdateParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for NamedValueUpdateParameters struct. +func (nvup *NamedValueUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var namedValueUpdateParameterProperties NamedValueUpdateParameterProperties + err = json.Unmarshal(*v, &namedValueUpdateParameterProperties) + if err != nil { + return err + } + nvup.NamedValueUpdateParameterProperties = &namedValueUpdateParameterProperties + } + } + } + + return nil +} + +// NetworkStatusContract network Status details. +type NetworkStatusContract struct { + autorest.Response `json:"-"` + // DNSServers - Gets the list of DNS servers IPV4 addresses. + DNSServers *[]string `json:"dnsServers,omitempty"` + // ConnectivityStatus - Gets the list of Connectivity Status to the Resources on which the service depends upon. + ConnectivityStatus *[]ConnectivityStatusContract `json:"connectivityStatus,omitempty"` +} + +// NetworkStatusContractByLocation network Status in the Location +type NetworkStatusContractByLocation struct { + // Location - Location of service + Location *string `json:"location,omitempty"` + // NetworkStatus - Network status in Location + NetworkStatus *NetworkStatusContract `json:"networkStatus,omitempty"` +} + +// NotificationCollection paged Notification list representation. +type NotificationCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]NotificationContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// NotificationCollectionIterator provides access to a complete listing of NotificationContract values. +type NotificationCollectionIterator struct { + i int + page NotificationCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *NotificationCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *NotificationCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter NotificationCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter NotificationCollectionIterator) Response() NotificationCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter NotificationCollectionIterator) Value() NotificationContract { + if !iter.page.NotDone() { + return NotificationContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the NotificationCollectionIterator type. +func NewNotificationCollectionIterator(page NotificationCollectionPage) NotificationCollectionIterator { + return NotificationCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (nc NotificationCollection) IsEmpty() bool { + return nc.Value == nil || len(*nc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (nc NotificationCollection) hasNextLink() bool { + return nc.NextLink != nil && len(*nc.NextLink) != 0 +} + +// notificationCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (nc NotificationCollection) notificationCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !nc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(nc.NextLink))) +} + +// NotificationCollectionPage contains a page of NotificationContract values. +type NotificationCollectionPage struct { + fn func(context.Context, NotificationCollection) (NotificationCollection, error) + nc NotificationCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *NotificationCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.nc) + if err != nil { + return err + } + page.nc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *NotificationCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page NotificationCollectionPage) NotDone() bool { + return !page.nc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page NotificationCollectionPage) Response() NotificationCollection { + return page.nc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page NotificationCollectionPage) Values() []NotificationContract { + if page.nc.IsEmpty() { + return nil + } + return *page.nc.Value +} + +// Creates a new instance of the NotificationCollectionPage type. +func NewNotificationCollectionPage(cur NotificationCollection, getNextPage func(context.Context, NotificationCollection) (NotificationCollection, error)) NotificationCollectionPage { + return NotificationCollectionPage{ + fn: getNextPage, + nc: cur, + } +} + +// NotificationContract notification details. +type NotificationContract struct { + autorest.Response `json:"-"` + // NotificationContractProperties - Notification entity contract properties. + *NotificationContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for NotificationContract. +func (nc NotificationContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if nc.NotificationContractProperties != nil { + objectMap["properties"] = nc.NotificationContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for NotificationContract struct. +func (nc *NotificationContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var notificationContractProperties NotificationContractProperties + err = json.Unmarshal(*v, ¬ificationContractProperties) + if err != nil { + return err + } + nc.NotificationContractProperties = ¬ificationContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + nc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + nc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + nc.Type = &typeVar + } + } + } + + return nil +} + +// NotificationContractProperties notification Contract properties. +type NotificationContractProperties struct { + // Title - Title of the Notification. + Title *string `json:"title,omitempty"` + // Description - Description of the Notification. + Description *string `json:"description,omitempty"` + // Recipients - Recipient Parameter values. + Recipients *RecipientsContractProperties `json:"recipients,omitempty"` +} + +// OAuth2AuthenticationSettingsContract API OAuth2 Authentication settings details. +type OAuth2AuthenticationSettingsContract struct { + // AuthorizationServerID - OAuth authorization server identifier. + AuthorizationServerID *string `json:"authorizationServerId,omitempty"` + // Scope - operations scope. + Scope *string `json:"scope,omitempty"` +} + +// OpenIDAuthenticationSettingsContract API OAuth2 Authentication settings details. +type OpenIDAuthenticationSettingsContract struct { + // OpenidProviderID - OAuth authorization server identifier. + OpenidProviderID *string `json:"openidProviderId,omitempty"` + // BearerTokenSendingMethods - How to send token to the server. + BearerTokenSendingMethods *[]BearerTokenSendingMethods `json:"bearerTokenSendingMethods,omitempty"` +} + +// OpenIDConnectProviderCollection paged OpenIdProviders list representation. +type OpenIDConnectProviderCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]OpenidConnectProviderContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OpenIDConnectProviderCollectionIterator provides access to a complete listing of +// OpenidConnectProviderContract values. +type OpenIDConnectProviderCollectionIterator struct { + i int + page OpenIDConnectProviderCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OpenIDConnectProviderCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OpenIDConnectProviderCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OpenIDConnectProviderCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OpenIDConnectProviderCollectionIterator) Response() OpenIDConnectProviderCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OpenIDConnectProviderCollectionIterator) Value() OpenidConnectProviderContract { + if !iter.page.NotDone() { + return OpenidConnectProviderContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OpenIDConnectProviderCollectionIterator type. +func NewOpenIDConnectProviderCollectionIterator(page OpenIDConnectProviderCollectionPage) OpenIDConnectProviderCollectionIterator { + return OpenIDConnectProviderCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (oicpc OpenIDConnectProviderCollection) IsEmpty() bool { + return oicpc.Value == nil || len(*oicpc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (oicpc OpenIDConnectProviderCollection) hasNextLink() bool { + return oicpc.NextLink != nil && len(*oicpc.NextLink) != 0 +} + +// openIDConnectProviderCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (oicpc OpenIDConnectProviderCollection) openIDConnectProviderCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !oicpc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(oicpc.NextLink))) +} + +// OpenIDConnectProviderCollectionPage contains a page of OpenidConnectProviderContract values. +type OpenIDConnectProviderCollectionPage struct { + fn func(context.Context, OpenIDConnectProviderCollection) (OpenIDConnectProviderCollection, error) + oicpc OpenIDConnectProviderCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OpenIDConnectProviderCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.oicpc) + if err != nil { + return err + } + page.oicpc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OpenIDConnectProviderCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OpenIDConnectProviderCollectionPage) NotDone() bool { + return !page.oicpc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OpenIDConnectProviderCollectionPage) Response() OpenIDConnectProviderCollection { + return page.oicpc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OpenIDConnectProviderCollectionPage) Values() []OpenidConnectProviderContract { + if page.oicpc.IsEmpty() { + return nil + } + return *page.oicpc.Value +} + +// Creates a new instance of the OpenIDConnectProviderCollectionPage type. +func NewOpenIDConnectProviderCollectionPage(cur OpenIDConnectProviderCollection, getNextPage func(context.Context, OpenIDConnectProviderCollection) (OpenIDConnectProviderCollection, error)) OpenIDConnectProviderCollectionPage { + return OpenIDConnectProviderCollectionPage{ + fn: getNextPage, + oicpc: cur, + } +} + +// OpenidConnectProviderContract openId Connect Provider details. +type OpenidConnectProviderContract struct { + autorest.Response `json:"-"` + // OpenidConnectProviderContractProperties - OpenId Connect Provider contract properties. + *OpenidConnectProviderContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for OpenidConnectProviderContract. +func (ocpc OpenidConnectProviderContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ocpc.OpenidConnectProviderContractProperties != nil { + objectMap["properties"] = ocpc.OpenidConnectProviderContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OpenidConnectProviderContract struct. +func (ocpc *OpenidConnectProviderContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var openidConnectProviderContractProperties OpenidConnectProviderContractProperties + err = json.Unmarshal(*v, &openidConnectProviderContractProperties) + if err != nil { + return err + } + ocpc.OpenidConnectProviderContractProperties = &openidConnectProviderContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ocpc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ocpc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ocpc.Type = &typeVar + } + } + } + + return nil +} + +// OpenidConnectProviderContractProperties openID Connect Providers Contract. +type OpenidConnectProviderContractProperties struct { + // DisplayName - User-friendly OpenID Connect Provider name. + DisplayName *string `json:"displayName,omitempty"` + // Description - User-friendly description of OpenID Connect Provider. + Description *string `json:"description,omitempty"` + // MetadataEndpoint - Metadata endpoint URI. + MetadataEndpoint *string `json:"metadataEndpoint,omitempty"` + // ClientID - Client ID of developer console which is the client application. + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - Client Secret of developer console which is the client application. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// OpenidConnectProviderUpdateContract parameters supplied to the Update OpenID Connect Provider operation. +type OpenidConnectProviderUpdateContract struct { + // OpenidConnectProviderUpdateContractProperties - OpenId Connect Provider Update contract properties. + *OpenidConnectProviderUpdateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for OpenidConnectProviderUpdateContract. +func (ocpuc OpenidConnectProviderUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ocpuc.OpenidConnectProviderUpdateContractProperties != nil { + objectMap["properties"] = ocpuc.OpenidConnectProviderUpdateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OpenidConnectProviderUpdateContract struct. +func (ocpuc *OpenidConnectProviderUpdateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var openidConnectProviderUpdateContractProperties OpenidConnectProviderUpdateContractProperties + err = json.Unmarshal(*v, &openidConnectProviderUpdateContractProperties) + if err != nil { + return err + } + ocpuc.OpenidConnectProviderUpdateContractProperties = &openidConnectProviderUpdateContractProperties + } + } + } + + return nil +} + +// OpenidConnectProviderUpdateContractProperties parameters supplied to the Update OpenID Connect Provider +// operation. +type OpenidConnectProviderUpdateContractProperties struct { + // DisplayName - User-friendly OpenID Connect Provider name. + DisplayName *string `json:"displayName,omitempty"` + // Description - User-friendly description of OpenID Connect Provider. + Description *string `json:"description,omitempty"` + // MetadataEndpoint - Metadata endpoint URI. + MetadataEndpoint *string `json:"metadataEndpoint,omitempty"` + // ClientID - Client ID of developer console which is the client application. + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - Client Secret of developer console which is the client application. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// Operation REST API operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that describes the operation. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - The operation origin. + Origin *string `json:"origin,omitempty"` + // Properties - The operation properties. + Properties interface{} `json:"properties,omitempty"` +} + +// OperationCollection paged Operation list representation. +type OperationCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]OperationContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationCollection. +func (oc OperationCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oc.Count != nil { + objectMap["count"] = oc.Count + } + return json.Marshal(objectMap) +} + +// OperationCollectionIterator provides access to a complete listing of OperationContract values. +type OperationCollectionIterator struct { + i int + page OperationCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationCollectionIterator) Response() OperationCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationCollectionIterator) Value() OperationContract { + if !iter.page.NotDone() { + return OperationContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationCollectionIterator type. +func NewOperationCollectionIterator(page OperationCollectionPage) OperationCollectionIterator { + return OperationCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (oc OperationCollection) IsEmpty() bool { + return oc.Value == nil || len(*oc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (oc OperationCollection) hasNextLink() bool { + return oc.NextLink != nil && len(*oc.NextLink) != 0 +} + +// operationCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (oc OperationCollection) operationCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !oc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(oc.NextLink))) +} + +// OperationCollectionPage contains a page of OperationContract values. +type OperationCollectionPage struct { + fn func(context.Context, OperationCollection) (OperationCollection, error) + oc OperationCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.oc) + if err != nil { + return err + } + page.oc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationCollectionPage) NotDone() bool { + return !page.oc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationCollectionPage) Response() OperationCollection { + return page.oc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationCollectionPage) Values() []OperationContract { + if page.oc.IsEmpty() { + return nil + } + return *page.oc.Value +} + +// Creates a new instance of the OperationCollectionPage type. +func NewOperationCollectionPage(cur OperationCollection, getNextPage func(context.Context, OperationCollection) (OperationCollection, error)) OperationCollectionPage { + return OperationCollectionPage{ + fn: getNextPage, + oc: cur, + } +} + +// OperationContract API Operation details. +type OperationContract struct { + autorest.Response `json:"-"` + // OperationContractProperties - Properties of the Operation Contract. + *OperationContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationContract. +func (oc OperationContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oc.OperationContractProperties != nil { + objectMap["properties"] = oc.OperationContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OperationContract struct. +func (oc *OperationContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var operationContractProperties OperationContractProperties + err = json.Unmarshal(*v, &operationContractProperties) + if err != nil { + return err + } + oc.OperationContractProperties = &operationContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + oc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + oc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + oc.Type = &typeVar + } + } + } + + return nil +} + +// OperationContractProperties operation Contract Properties +type OperationContractProperties struct { + // DisplayName - Operation Name. + DisplayName *string `json:"displayName,omitempty"` + // Method - A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them. + Method *string `json:"method,omitempty"` + // URLTemplate - Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date} + URLTemplate *string `json:"urlTemplate,omitempty"` + // TemplateParameters - Collection of URL template parameters. + TemplateParameters *[]ParameterContract `json:"templateParameters,omitempty"` + // Description - Description of the operation. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // Request - An entity containing request details. + Request *RequestContract `json:"request,omitempty"` + // Responses - Array of Operation responses. + Responses *[]ResponseContract `json:"responses,omitempty"` + // Policies - Operation Policies + Policies *string `json:"policies,omitempty"` +} + +// OperationDisplay the object that describes the operation. +type OperationDisplay struct { + // Provider - Friendly name of the resource provider + Provider *string `json:"provider,omitempty"` + // Operation - Operation type: read, write, delete, listKeys/action, etc. + Operation *string `json:"operation,omitempty"` + // Resource - Resource type on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Description - Friendly name of the operation + Description *string `json:"description,omitempty"` +} + +// OperationEntityBaseContract API Operation Entity Base Contract details. +type OperationEntityBaseContract struct { + // TemplateParameters - Collection of URL template parameters. + TemplateParameters *[]ParameterContract `json:"templateParameters,omitempty"` + // Description - Description of the operation. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // Request - An entity containing request details. + Request *RequestContract `json:"request,omitempty"` + // Responses - Array of Operation responses. + Responses *[]ResponseContract `json:"responses,omitempty"` + // Policies - Operation Policies + Policies *string `json:"policies,omitempty"` +} + +// OperationListResult result of the request to list REST API operations. It contains a list of operations +// and a URL nextLink to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// OperationResultContract long Running Git Operation Results. +type OperationResultContract struct { + autorest.Response `json:"-"` + // OperationResultContractProperties - Properties of the Operation Contract. + *OperationResultContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationResultContract. +func (orc OperationResultContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if orc.OperationResultContractProperties != nil { + objectMap["properties"] = orc.OperationResultContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OperationResultContract struct. +func (orc *OperationResultContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var operationResultContractProperties OperationResultContractProperties + err = json.Unmarshal(*v, &operationResultContractProperties) + if err != nil { + return err + } + orc.OperationResultContractProperties = &operationResultContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + orc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + orc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + orc.Type = &typeVar + } + } + } + + return nil +} + +// OperationResultContractProperties operation Result. +type OperationResultContractProperties struct { + // ID - Operation result identifier. + ID *string `json:"id,omitempty"` + // Status - Status of an async operation. Possible values include: 'AsyncOperationStatusStarted', 'AsyncOperationStatusInProgress', 'AsyncOperationStatusSucceeded', 'AsyncOperationStatusFailed' + Status AsyncOperationStatus `json:"status,omitempty"` + // Started - Start time of an async operation. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + Started *date.Time `json:"started,omitempty"` + // Updated - Last update time of an async operation. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + Updated *date.Time `json:"updated,omitempty"` + // ResultInfo - Optional result info. + ResultInfo *string `json:"resultInfo,omitempty"` + // Error - Error Body Contract + Error *ErrorResponseBody `json:"error,omitempty"` + // ActionLog - READ-ONLY; This property if only provided as part of the TenantConfiguration_Validate operation. It contains the log the entities which will be updated/created/deleted as part of the TenantConfiguration_Deploy operation. + ActionLog *[]OperationResultLogItemContract `json:"actionLog,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationResultContractProperties. +func (orcp OperationResultContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if orcp.ID != nil { + objectMap["id"] = orcp.ID + } + if orcp.Status != "" { + objectMap["status"] = orcp.Status + } + if orcp.Started != nil { + objectMap["started"] = orcp.Started + } + if orcp.Updated != nil { + objectMap["updated"] = orcp.Updated + } + if orcp.ResultInfo != nil { + objectMap["resultInfo"] = orcp.ResultInfo + } + if orcp.Error != nil { + objectMap["error"] = orcp.Error + } + return json.Marshal(objectMap) +} + +// OperationResultLogItemContract log of the entity being created, updated or deleted. +type OperationResultLogItemContract struct { + // ObjectType - The type of entity contract. + ObjectType *string `json:"objectType,omitempty"` + // Action - Action like create/update/delete. + Action *string `json:"action,omitempty"` + // ObjectKey - Identifier of the entity being created/updated/deleted. + ObjectKey *string `json:"objectKey,omitempty"` +} + +// OperationTagResourceContractProperties operation Entity contract Properties. +type OperationTagResourceContractProperties struct { + // ID - Identifier of the operation in form /operations/{operationId}. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Operation name. + Name *string `json:"name,omitempty"` + // APIName - READ-ONLY; API Name. + APIName *string `json:"apiName,omitempty"` + // APIRevision - READ-ONLY; API Revision. + APIRevision *string `json:"apiRevision,omitempty"` + // APIVersion - READ-ONLY; API Version. + APIVersion *string `json:"apiVersion,omitempty"` + // Description - READ-ONLY; Operation Description. + Description *string `json:"description,omitempty"` + // Method - READ-ONLY; A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them. + Method *string `json:"method,omitempty"` + // URLTemplate - READ-ONLY; Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date} + URLTemplate *string `json:"urlTemplate,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationTagResourceContractProperties. +func (otrcp OperationTagResourceContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if otrcp.ID != nil { + objectMap["id"] = otrcp.ID + } + return json.Marshal(objectMap) +} + +// OperationUpdateContract API Operation Update Contract details. +type OperationUpdateContract struct { + // OperationUpdateContractProperties - Properties of the API Operation entity that can be updated. + *OperationUpdateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationUpdateContract. +func (ouc OperationUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ouc.OperationUpdateContractProperties != nil { + objectMap["properties"] = ouc.OperationUpdateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OperationUpdateContract struct. +func (ouc *OperationUpdateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var operationUpdateContractProperties OperationUpdateContractProperties + err = json.Unmarshal(*v, &operationUpdateContractProperties) + if err != nil { + return err + } + ouc.OperationUpdateContractProperties = &operationUpdateContractProperties + } + } + } + + return nil +} + +// OperationUpdateContractProperties operation Update Contract Properties. +type OperationUpdateContractProperties struct { + // DisplayName - Operation Name. + DisplayName *string `json:"displayName,omitempty"` + // Method - A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them. + Method *string `json:"method,omitempty"` + // URLTemplate - Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date} + URLTemplate *string `json:"urlTemplate,omitempty"` + // TemplateParameters - Collection of URL template parameters. + TemplateParameters *[]ParameterContract `json:"templateParameters,omitempty"` + // Description - Description of the operation. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // Request - An entity containing request details. + Request *RequestContract `json:"request,omitempty"` + // Responses - Array of Operation responses. + Responses *[]ResponseContract `json:"responses,omitempty"` + // Policies - Operation Policies + Policies *string `json:"policies,omitempty"` +} + +// ParameterContract operation parameters details. +type ParameterContract struct { + // Name - Parameter name. + Name *string `json:"name,omitempty"` + // Description - Parameter description. + Description *string `json:"description,omitempty"` + // Type - Parameter type. + Type *string `json:"type,omitempty"` + // DefaultValue - Default parameter value. + DefaultValue *string `json:"defaultValue,omitempty"` + // Required - Specifies whether parameter is required or not. + Required *bool `json:"required,omitempty"` + // Values - Parameter values. + Values *[]string `json:"values,omitempty"` + // SchemaID - Schema identifier. + SchemaID *string `json:"schemaId,omitempty"` + // TypeName - Type name defined by the schema. + TypeName *string `json:"typeName,omitempty"` +} + +// PipelineDiagnosticSettings diagnostic settings for incoming/outgoing HTTP messages to the Gateway. +type PipelineDiagnosticSettings struct { + // Request - Diagnostic settings for request. + Request *HTTPMessageDiagnostic `json:"request,omitempty"` + // Response - Diagnostic settings for response. + Response *HTTPMessageDiagnostic `json:"response,omitempty"` +} + +// PolicyCollection the response of the list policy operation. +type PolicyCollection struct { + autorest.Response `json:"-"` + // Value - Policy Contract value. + Value *[]PolicyContract `json:"value,omitempty"` + // Count - Total record count number. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// PolicyContract policy Contract details. +type PolicyContract struct { + autorest.Response `json:"-"` + // PolicyContractProperties - Properties of the Policy. + *PolicyContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PolicyContract. +func (pc PolicyContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pc.PolicyContractProperties != nil { + objectMap["properties"] = pc.PolicyContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PolicyContract struct. +func (pc *PolicyContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var policyContractProperties PolicyContractProperties + err = json.Unmarshal(*v, &policyContractProperties) + if err != nil { + return err + } + pc.PolicyContractProperties = &policyContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pc.Type = &typeVar + } + } + } + + return nil +} + +// PolicyContractProperties policy contract Properties. +type PolicyContractProperties struct { + // Value - Contents of the Policy as defined by the format. + Value *string `json:"value,omitempty"` + // Format - Format of the policyContent. Possible values include: 'PolicyContentFormatXML', 'PolicyContentFormatXMLLink', 'PolicyContentFormatRawxml', 'PolicyContentFormatRawxmlLink' + Format PolicyContentFormat `json:"format,omitempty"` +} + +// PolicyDescriptionCollection descriptions of APIM policies. +type PolicyDescriptionCollection struct { + autorest.Response `json:"-"` + // Value - Descriptions of APIM policies. + Value *[]PolicyDescriptionContract `json:"value,omitempty"` + // Count - Total record count number. + Count *int64 `json:"count,omitempty"` +} + +// PolicyDescriptionContract policy description details. +type PolicyDescriptionContract struct { + // PolicyDescriptionContractProperties - Policy description contract properties. + *PolicyDescriptionContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PolicyDescriptionContract. +func (pdc PolicyDescriptionContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pdc.PolicyDescriptionContractProperties != nil { + objectMap["properties"] = pdc.PolicyDescriptionContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PolicyDescriptionContract struct. +func (pdc *PolicyDescriptionContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var policyDescriptionContractProperties PolicyDescriptionContractProperties + err = json.Unmarshal(*v, &policyDescriptionContractProperties) + if err != nil { + return err + } + pdc.PolicyDescriptionContractProperties = &policyDescriptionContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pdc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pdc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pdc.Type = &typeVar + } + } + } + + return nil +} + +// PolicyDescriptionContractProperties policy description properties. +type PolicyDescriptionContractProperties struct { + // Description - READ-ONLY; Policy description. + Description *string `json:"description,omitempty"` + // Scope - READ-ONLY; Binary OR value of the Snippet scope. + Scope *int64 `json:"scope,omitempty"` +} + +// MarshalJSON is the custom marshaler for PolicyDescriptionContractProperties. +func (pdcp PolicyDescriptionContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PortalDelegationSettings delegation settings for a developer portal. +type PortalDelegationSettings struct { + autorest.Response `json:"-"` + // PortalDelegationSettingsProperties - Delegation settings contract properties. + *PortalDelegationSettingsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalDelegationSettings. +func (pds PortalDelegationSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pds.PortalDelegationSettingsProperties != nil { + objectMap["properties"] = pds.PortalDelegationSettingsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PortalDelegationSettings struct. +func (pds *PortalDelegationSettings) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var portalDelegationSettingsProperties PortalDelegationSettingsProperties + err = json.Unmarshal(*v, &portalDelegationSettingsProperties) + if err != nil { + return err + } + pds.PortalDelegationSettingsProperties = &portalDelegationSettingsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pds.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pds.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pds.Type = &typeVar + } + } + } + + return nil +} + +// PortalDelegationSettingsProperties delegation settings contract properties. +type PortalDelegationSettingsProperties struct { + // URL - A delegation Url. + URL *string `json:"url,omitempty"` + // ValidationKey - A base64-encoded validation key to validate, that a request is coming from Azure API Management. + ValidationKey *string `json:"validationKey,omitempty"` + // Subscriptions - Subscriptions delegation settings. + Subscriptions *SubscriptionsDelegationSettingsProperties `json:"subscriptions,omitempty"` + // UserRegistration - User registration delegation settings. + UserRegistration *RegistrationDelegationSettingsProperties `json:"userRegistration,omitempty"` +} + +// PortalRevisionCollection paged list of portal revisions. +type PortalRevisionCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of portal revisions. + Value *[]PortalRevisionContract `json:"value,omitempty"` + // NextLink - READ-ONLY; Next page link, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalRevisionCollection. +func (prc PortalRevisionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PortalRevisionCollectionIterator provides access to a complete listing of PortalRevisionContract values. +type PortalRevisionCollectionIterator struct { + i int + page PortalRevisionCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PortalRevisionCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PortalRevisionCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PortalRevisionCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PortalRevisionCollectionIterator) Response() PortalRevisionCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PortalRevisionCollectionIterator) Value() PortalRevisionContract { + if !iter.page.NotDone() { + return PortalRevisionContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PortalRevisionCollectionIterator type. +func NewPortalRevisionCollectionIterator(page PortalRevisionCollectionPage) PortalRevisionCollectionIterator { + return PortalRevisionCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (prc PortalRevisionCollection) IsEmpty() bool { + return prc.Value == nil || len(*prc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (prc PortalRevisionCollection) hasNextLink() bool { + return prc.NextLink != nil && len(*prc.NextLink) != 0 +} + +// portalRevisionCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (prc PortalRevisionCollection) portalRevisionCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !prc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(prc.NextLink))) +} + +// PortalRevisionCollectionPage contains a page of PortalRevisionContract values. +type PortalRevisionCollectionPage struct { + fn func(context.Context, PortalRevisionCollection) (PortalRevisionCollection, error) + prc PortalRevisionCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PortalRevisionCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.prc) + if err != nil { + return err + } + page.prc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PortalRevisionCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PortalRevisionCollectionPage) NotDone() bool { + return !page.prc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PortalRevisionCollectionPage) Response() PortalRevisionCollection { + return page.prc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PortalRevisionCollectionPage) Values() []PortalRevisionContract { + if page.prc.IsEmpty() { + return nil + } + return *page.prc.Value +} + +// Creates a new instance of the PortalRevisionCollectionPage type. +func NewPortalRevisionCollectionPage(cur PortalRevisionCollection, getNextPage func(context.Context, PortalRevisionCollection) (PortalRevisionCollection, error)) PortalRevisionCollectionPage { + return PortalRevisionCollectionPage{ + fn: getNextPage, + prc: cur, + } +} + +// PortalRevisionContract portal Revision's contract details. +type PortalRevisionContract struct { + autorest.Response `json:"-"` + // PortalRevisionContractProperties - Properties of the portal revisions. + *PortalRevisionContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalRevisionContract. +func (prc PortalRevisionContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if prc.PortalRevisionContractProperties != nil { + objectMap["properties"] = prc.PortalRevisionContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PortalRevisionContract struct. +func (prc *PortalRevisionContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var portalRevisionContractProperties PortalRevisionContractProperties + err = json.Unmarshal(*v, &portalRevisionContractProperties) + if err != nil { + return err + } + prc.PortalRevisionContractProperties = &portalRevisionContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + prc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + prc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + prc.Type = &typeVar + } + } + } + + return nil +} + +// PortalRevisionContractProperties ... +type PortalRevisionContractProperties struct { + // Description - Portal revision description. + Description *string `json:"description,omitempty"` + // StatusDetails - READ-ONLY; Portal revision publishing status details. + StatusDetails *string `json:"statusDetails,omitempty"` + // Status - READ-ONLY; Status of the portal's revision. Possible values include: 'PortalRevisionStatusPending', 'PortalRevisionStatusPublishing', 'PortalRevisionStatusCompleted', 'PortalRevisionStatusFailed' + Status PortalRevisionStatus `json:"status,omitempty"` + // IsCurrent - Indicates if the portal's revision is public. + IsCurrent *bool `json:"isCurrent,omitempty"` + // CreatedDateTime - READ-ONLY; Portal's revision creation date and time. + CreatedDateTime *date.Time `json:"createdDateTime,omitempty"` + // UpdatedDateTime - READ-ONLY; Last updated date and time. + UpdatedDateTime *date.Time `json:"updatedDateTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalRevisionContractProperties. +func (prcp PortalRevisionContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if prcp.Description != nil { + objectMap["description"] = prcp.Description + } + if prcp.IsCurrent != nil { + objectMap["isCurrent"] = prcp.IsCurrent + } + return json.Marshal(objectMap) +} + +// PortalRevisionCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PortalRevisionCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PortalRevisionClient) (PortalRevisionContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PortalRevisionCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PortalRevisionCreateOrUpdateFuture.Result. +func (future *PortalRevisionCreateOrUpdateFuture) result(client PortalRevisionClient) (prc PortalRevisionContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + prc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.PortalRevisionCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if prc.Response.Response, err = future.GetResult(sender); err == nil && prc.Response.Response.StatusCode != http.StatusNoContent { + prc, err = client.CreateOrUpdateResponder(prc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionCreateOrUpdateFuture", "Result", prc.Response.Response, "Failure responding to request") + } + } + return +} + +// PortalRevisionUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PortalRevisionUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PortalRevisionClient) (PortalRevisionContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PortalRevisionUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PortalRevisionUpdateFuture.Result. +func (future *PortalRevisionUpdateFuture) result(client PortalRevisionClient) (prc PortalRevisionContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + prc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.PortalRevisionUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if prc.Response.Response, err = future.GetResult(sender); err == nil && prc.Response.Response.StatusCode != http.StatusNoContent { + prc, err = client.UpdateResponder(prc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionUpdateFuture", "Result", prc.Response.Response, "Failure responding to request") + } + } + return +} + +// PortalSettingsCollection descriptions of APIM policies. +type PortalSettingsCollection struct { + autorest.Response `json:"-"` + // Value - Descriptions of APIM policies. + Value *[]PortalSettingsContract `json:"value,omitempty"` + // Count - Total record count number. + Count *int64 `json:"count,omitempty"` +} + +// PortalSettingsContract portal Settings for the Developer Portal. +type PortalSettingsContract struct { + // PortalSettingsContractProperties - Portal Settings contract properties. + *PortalSettingsContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalSettingsContract. +func (psc PortalSettingsContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if psc.PortalSettingsContractProperties != nil { + objectMap["properties"] = psc.PortalSettingsContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PortalSettingsContract struct. +func (psc *PortalSettingsContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var portalSettingsContractProperties PortalSettingsContractProperties + err = json.Unmarshal(*v, &portalSettingsContractProperties) + if err != nil { + return err + } + psc.PortalSettingsContractProperties = &portalSettingsContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + psc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + psc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + psc.Type = &typeVar + } + } + } + + return nil +} + +// PortalSettingsContractProperties sign-in settings contract properties. +type PortalSettingsContractProperties struct { + // URL - A delegation Url. + URL *string `json:"url,omitempty"` + // ValidationKey - A base64-encoded validation key to validate, that a request is coming from Azure API Management. + ValidationKey *string `json:"validationKey,omitempty"` + // Subscriptions - Subscriptions delegation settings. + Subscriptions *SubscriptionsDelegationSettingsProperties `json:"subscriptions,omitempty"` + // UserRegistration - User registration delegation settings. + UserRegistration *RegistrationDelegationSettingsProperties `json:"userRegistration,omitempty"` + // Enabled - Redirect Anonymous users to the Sign-In page. + Enabled *bool `json:"enabled,omitempty"` + // TermsOfService - Terms of service contract properties. + TermsOfService *TermsOfServiceProperties `json:"termsOfService,omitempty"` +} + +// PortalSettingValidationKeyContract client or app secret used in IdentityProviders, Aad, OpenID or OAuth. +type PortalSettingValidationKeyContract struct { + autorest.Response `json:"-"` + // ValidationKey - This is secret value of the validation key in portal settings. + ValidationKey *string `json:"validationKey,omitempty"` +} + +// PortalSigninSettingProperties sign-in settings contract properties. +type PortalSigninSettingProperties struct { + // Enabled - Redirect Anonymous users to the Sign-In page. + Enabled *bool `json:"enabled,omitempty"` +} + +// PortalSigninSettings sign-In settings for the Developer Portal. +type PortalSigninSettings struct { + autorest.Response `json:"-"` + // PortalSigninSettingProperties - Sign-in settings contract properties. + *PortalSigninSettingProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalSigninSettings. +func (pss PortalSigninSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pss.PortalSigninSettingProperties != nil { + objectMap["properties"] = pss.PortalSigninSettingProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PortalSigninSettings struct. +func (pss *PortalSigninSettings) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var portalSigninSettingProperties PortalSigninSettingProperties + err = json.Unmarshal(*v, &portalSigninSettingProperties) + if err != nil { + return err + } + pss.PortalSigninSettingProperties = &portalSigninSettingProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pss.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pss.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pss.Type = &typeVar + } + } + } + + return nil +} + +// PortalSignupSettings sign-Up settings for a developer portal. +type PortalSignupSettings struct { + autorest.Response `json:"-"` + // PortalSignupSettingsProperties - Sign-up settings contract properties. + *PortalSignupSettingsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PortalSignupSettings. +func (pss PortalSignupSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pss.PortalSignupSettingsProperties != nil { + objectMap["properties"] = pss.PortalSignupSettingsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PortalSignupSettings struct. +func (pss *PortalSignupSettings) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var portalSignupSettingsProperties PortalSignupSettingsProperties + err = json.Unmarshal(*v, &portalSignupSettingsProperties) + if err != nil { + return err + } + pss.PortalSignupSettingsProperties = &portalSignupSettingsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pss.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pss.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pss.Type = &typeVar + } + } + } + + return nil +} + +// PortalSignupSettingsProperties sign-up settings contract properties. +type PortalSignupSettingsProperties struct { + // Enabled - Allow users to sign up on a developer portal. + Enabled *bool `json:"enabled,omitempty"` + // TermsOfService - Terms of service contract properties. + TermsOfService *TermsOfServiceProperties `json:"termsOfService,omitempty"` +} + +// ProductCollection paged Products list representation. +type ProductCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]ProductContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// ProductCollectionIterator provides access to a complete listing of ProductContract values. +type ProductCollectionIterator struct { + i int + page ProductCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ProductCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ProductCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ProductCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ProductCollectionIterator) Response() ProductCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ProductCollectionIterator) Value() ProductContract { + if !iter.page.NotDone() { + return ProductContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ProductCollectionIterator type. +func NewProductCollectionIterator(page ProductCollectionPage) ProductCollectionIterator { + return ProductCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pc ProductCollection) IsEmpty() bool { + return pc.Value == nil || len(*pc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pc ProductCollection) hasNextLink() bool { + return pc.NextLink != nil && len(*pc.NextLink) != 0 +} + +// productCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pc ProductCollection) productCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !pc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pc.NextLink))) +} + +// ProductCollectionPage contains a page of ProductContract values. +type ProductCollectionPage struct { + fn func(context.Context, ProductCollection) (ProductCollection, error) + pc ProductCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ProductCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.pc) + if err != nil { + return err + } + page.pc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ProductCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ProductCollectionPage) NotDone() bool { + return !page.pc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ProductCollectionPage) Response() ProductCollection { + return page.pc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ProductCollectionPage) Values() []ProductContract { + if page.pc.IsEmpty() { + return nil + } + return *page.pc.Value +} + +// Creates a new instance of the ProductCollectionPage type. +func NewProductCollectionPage(cur ProductCollection, getNextPage func(context.Context, ProductCollection) (ProductCollection, error)) ProductCollectionPage { + return ProductCollectionPage{ + fn: getNextPage, + pc: cur, + } +} + +// ProductContract product details. +type ProductContract struct { + autorest.Response `json:"-"` + // ProductContractProperties - Product entity contract properties. + *ProductContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProductContract. +func (pc ProductContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pc.ProductContractProperties != nil { + objectMap["properties"] = pc.ProductContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ProductContract struct. +func (pc *ProductContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var productContractProperties ProductContractProperties + err = json.Unmarshal(*v, &productContractProperties) + if err != nil { + return err + } + pc.ProductContractProperties = &productContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pc.Type = &typeVar + } + } + } + + return nil +} + +// ProductContractProperties product profile. +type ProductContractProperties struct { + // DisplayName - Product name. + DisplayName *string `json:"displayName,omitempty"` + // Description - Product description. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // Terms - Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. + Terms *string `json:"terms,omitempty"` + // SubscriptionRequired - Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + // ApprovalRequired - whether subscription approval is required. If false, new subscriptions will be approved automatically enabling developers to call the product’s APIs immediately after subscribing. If true, administrators must manually approve the subscription before the developer can any of the product’s APIs. Can be present only if subscriptionRequired property is present and has a value of false. + ApprovalRequired *bool `json:"approvalRequired,omitempty"` + // SubscriptionsLimit - Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. + SubscriptionsLimit *int32 `json:"subscriptionsLimit,omitempty"` + // State - whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state of Product is notPublished. Possible values include: 'ProductStateNotPublished', 'ProductStatePublished' + State ProductState `json:"state,omitempty"` +} + +// ProductEntityBaseParameters product Entity Base Parameters +type ProductEntityBaseParameters struct { + // Description - Product description. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // Terms - Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. + Terms *string `json:"terms,omitempty"` + // SubscriptionRequired - Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + // ApprovalRequired - whether subscription approval is required. If false, new subscriptions will be approved automatically enabling developers to call the product’s APIs immediately after subscribing. If true, administrators must manually approve the subscription before the developer can any of the product’s APIs. Can be present only if subscriptionRequired property is present and has a value of false. + ApprovalRequired *bool `json:"approvalRequired,omitempty"` + // SubscriptionsLimit - Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. + SubscriptionsLimit *int32 `json:"subscriptionsLimit,omitempty"` + // State - whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state of Product is notPublished. Possible values include: 'ProductStateNotPublished', 'ProductStatePublished' + State ProductState `json:"state,omitempty"` +} + +// ProductTagResourceContractProperties product profile. +type ProductTagResourceContractProperties struct { + // ID - Identifier of the product in the form of /products/{productId} + ID *string `json:"id,omitempty"` + // Name - Product name. + Name *string `json:"name,omitempty"` + // Description - Product description. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // Terms - Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. + Terms *string `json:"terms,omitempty"` + // SubscriptionRequired - Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + // ApprovalRequired - whether subscription approval is required. If false, new subscriptions will be approved automatically enabling developers to call the product’s APIs immediately after subscribing. If true, administrators must manually approve the subscription before the developer can any of the product’s APIs. Can be present only if subscriptionRequired property is present and has a value of false. + ApprovalRequired *bool `json:"approvalRequired,omitempty"` + // SubscriptionsLimit - Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. + SubscriptionsLimit *int32 `json:"subscriptionsLimit,omitempty"` + // State - whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state of Product is notPublished. Possible values include: 'ProductStateNotPublished', 'ProductStatePublished' + State ProductState `json:"state,omitempty"` +} + +// ProductUpdateParameters product Update parameters. +type ProductUpdateParameters struct { + // ProductUpdateProperties - Product entity Update contract properties. + *ProductUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProductUpdateParameters. +func (pup ProductUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pup.ProductUpdateProperties != nil { + objectMap["properties"] = pup.ProductUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ProductUpdateParameters struct. +func (pup *ProductUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var productUpdateProperties ProductUpdateProperties + err = json.Unmarshal(*v, &productUpdateProperties) + if err != nil { + return err + } + pup.ProductUpdateProperties = &productUpdateProperties + } + } + } + + return nil +} + +// ProductUpdateProperties parameters supplied to the Update Product operation. +type ProductUpdateProperties struct { + // DisplayName - Product name. + DisplayName *string `json:"displayName,omitempty"` + // Description - Product description. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + // Terms - Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. + Terms *string `json:"terms,omitempty"` + // SubscriptionRequired - Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + // ApprovalRequired - whether subscription approval is required. If false, new subscriptions will be approved automatically enabling developers to call the product’s APIs immediately after subscribing. If true, administrators must manually approve the subscription before the developer can any of the product’s APIs. Can be present only if subscriptionRequired property is present and has a value of false. + ApprovalRequired *bool `json:"approvalRequired,omitempty"` + // SubscriptionsLimit - Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. + SubscriptionsLimit *int32 `json:"subscriptionsLimit,omitempty"` + // State - whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state of Product is notPublished. Possible values include: 'ProductStateNotPublished', 'ProductStatePublished' + State ProductState `json:"state,omitempty"` +} + +// QuotaCounterCollection paged Quota Counter list representation. +type QuotaCounterCollection struct { + autorest.Response `json:"-"` + // Value - Quota counter values. + Value *[]QuotaCounterContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// QuotaCounterContract quota counter details. +type QuotaCounterContract struct { + autorest.Response `json:"-"` + // CounterKey - The Key value of the Counter. Must not be empty. + CounterKey *string `json:"counterKey,omitempty"` + // PeriodKey - Identifier of the Period for which the counter was collected. Must not be empty. + PeriodKey *string `json:"periodKey,omitempty"` + // PeriodStartTime - The date of the start of Counter Period. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + PeriodStartTime *date.Time `json:"periodStartTime,omitempty"` + // PeriodEndTime - The date of the end of Counter Period. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + PeriodEndTime *date.Time `json:"periodEndTime,omitempty"` + // Value - Quota Value Properties + Value *QuotaCounterValueContractProperties `json:"value,omitempty"` +} + +// QuotaCounterValueContract quota counter value details. +type QuotaCounterValueContract struct { + // QuotaCounterValueContractProperties - Quota counter Value Properties. + *QuotaCounterValueContractProperties `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for QuotaCounterValueContract. +func (qcvc QuotaCounterValueContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qcvc.QuotaCounterValueContractProperties != nil { + objectMap["value"] = qcvc.QuotaCounterValueContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QuotaCounterValueContract struct. +func (qcvc *QuotaCounterValueContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "value": + if v != nil { + var quotaCounterValueContractProperties QuotaCounterValueContractProperties + err = json.Unmarshal(*v, "aCounterValueContractProperties) + if err != nil { + return err + } + qcvc.QuotaCounterValueContractProperties = "aCounterValueContractProperties + } + } + } + + return nil +} + +// QuotaCounterValueContractProperties quota counter value details. +type QuotaCounterValueContractProperties struct { + // CallsCount - Number of times Counter was called. + CallsCount *int32 `json:"callsCount,omitempty"` + // KbTransferred - Data Transferred in KiloBytes. + KbTransferred *float64 `json:"kbTransferred,omitempty"` +} + +// QuotaCounterValueUpdateContract quota counter value details. +type QuotaCounterValueUpdateContract struct { + // QuotaCounterValueContractProperties - Quota counter value details. + *QuotaCounterValueContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for QuotaCounterValueUpdateContract. +func (qcvuc QuotaCounterValueUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qcvuc.QuotaCounterValueContractProperties != nil { + objectMap["properties"] = qcvuc.QuotaCounterValueContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QuotaCounterValueUpdateContract struct. +func (qcvuc *QuotaCounterValueUpdateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var quotaCounterValueContractProperties QuotaCounterValueContractProperties + err = json.Unmarshal(*v, "aCounterValueContractProperties) + if err != nil { + return err + } + qcvuc.QuotaCounterValueContractProperties = "aCounterValueContractProperties + } + } + } + + return nil +} + +// RecipientEmailCollection paged Recipient User list representation. +type RecipientEmailCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]RecipientEmailContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// RecipientEmailContract recipient Email details. +type RecipientEmailContract struct { + autorest.Response `json:"-"` + // RecipientEmailContractProperties - Recipient Email contract properties. + *RecipientEmailContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecipientEmailContract. +func (rec RecipientEmailContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rec.RecipientEmailContractProperties != nil { + objectMap["properties"] = rec.RecipientEmailContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecipientEmailContract struct. +func (rec *RecipientEmailContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recipientEmailContractProperties RecipientEmailContractProperties + err = json.Unmarshal(*v, &recipientEmailContractProperties) + if err != nil { + return err + } + rec.RecipientEmailContractProperties = &recipientEmailContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rec.Type = &typeVar + } + } + } + + return nil +} + +// RecipientEmailContractProperties recipient Email Contract Properties. +type RecipientEmailContractProperties struct { + // Email - User Email subscribed to notification. + Email *string `json:"email,omitempty"` +} + +// RecipientsContractProperties notification Parameter contract. +type RecipientsContractProperties struct { + // Emails - List of Emails subscribed for the notification. + Emails *[]string `json:"emails,omitempty"` + // Users - List of Users subscribed for the notification. + Users *[]string `json:"users,omitempty"` +} + +// RecipientUserCollection paged Recipient User list representation. +type RecipientUserCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]RecipientUserContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// RecipientUserContract recipient User details. +type RecipientUserContract struct { + autorest.Response `json:"-"` + // RecipientUsersContractProperties - Recipient User entity contract properties. + *RecipientUsersContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecipientUserContract. +func (ruc RecipientUserContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ruc.RecipientUsersContractProperties != nil { + objectMap["properties"] = ruc.RecipientUsersContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecipientUserContract struct. +func (ruc *RecipientUserContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recipientUsersContractProperties RecipientUsersContractProperties + err = json.Unmarshal(*v, &recipientUsersContractProperties) + if err != nil { + return err + } + ruc.RecipientUsersContractProperties = &recipientUsersContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ruc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ruc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ruc.Type = &typeVar + } + } + } + + return nil +} + +// RecipientUsersContractProperties recipient User Contract Properties. +type RecipientUsersContractProperties struct { + // UserID - API Management UserId subscribed to notification. + UserID *string `json:"userId,omitempty"` +} + +// RegionContract region profile. +type RegionContract struct { + // Name - READ-ONLY; Region name. + Name *string `json:"name,omitempty"` + // IsMasterRegion - whether Region is the master region. + IsMasterRegion *bool `json:"isMasterRegion,omitempty"` + // IsDeleted - whether Region is deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegionContract. +func (rc RegionContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rc.IsMasterRegion != nil { + objectMap["isMasterRegion"] = rc.IsMasterRegion + } + if rc.IsDeleted != nil { + objectMap["isDeleted"] = rc.IsDeleted + } + return json.Marshal(objectMap) +} + +// RegionListResult lists Regions operation response details. +type RegionListResult struct { + autorest.Response `json:"-"` + // Value - Lists of Regions. + Value *[]RegionContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// RegionListResultIterator provides access to a complete listing of RegionContract values. +type RegionListResultIterator struct { + i int + page RegionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegionListResultIterator) Response() RegionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegionListResultIterator) Value() RegionContract { + if !iter.page.NotDone() { + return RegionContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegionListResultIterator type. +func NewRegionListResultIterator(page RegionListResultPage) RegionListResultIterator { + return RegionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rlr RegionListResult) IsEmpty() bool { + return rlr.Value == nil || len(*rlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rlr RegionListResult) hasNextLink() bool { + return rlr.NextLink != nil && len(*rlr.NextLink) != 0 +} + +// regionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rlr RegionListResult) regionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rlr.NextLink))) +} + +// RegionListResultPage contains a page of RegionContract values. +type RegionListResultPage struct { + fn func(context.Context, RegionListResult) (RegionListResult, error) + rlr RegionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rlr) + if err != nil { + return err + } + page.rlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegionListResultPage) NotDone() bool { + return !page.rlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegionListResultPage) Response() RegionListResult { + return page.rlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegionListResultPage) Values() []RegionContract { + if page.rlr.IsEmpty() { + return nil + } + return *page.rlr.Value +} + +// Creates a new instance of the RegionListResultPage type. +func NewRegionListResultPage(cur RegionListResult, getNextPage func(context.Context, RegionListResult) (RegionListResult, error)) RegionListResultPage { + return RegionListResultPage{ + fn: getNextPage, + rlr: cur, + } +} + +// RegistrationDelegationSettingsProperties user registration delegation settings properties. +type RegistrationDelegationSettingsProperties struct { + // Enabled - Enable or disable delegation for user registration. + Enabled *bool `json:"enabled,omitempty"` +} + +// ReportCollection paged Report records list representation. +type ReportCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]ReportRecordContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// ReportCollectionIterator provides access to a complete listing of ReportRecordContract values. +type ReportCollectionIterator struct { + i int + page ReportCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ReportCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ReportCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ReportCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ReportCollectionIterator) Response() ReportCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ReportCollectionIterator) Value() ReportRecordContract { + if !iter.page.NotDone() { + return ReportRecordContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ReportCollectionIterator type. +func NewReportCollectionIterator(page ReportCollectionPage) ReportCollectionIterator { + return ReportCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rc ReportCollection) IsEmpty() bool { + return rc.Value == nil || len(*rc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rc ReportCollection) hasNextLink() bool { + return rc.NextLink != nil && len(*rc.NextLink) != 0 +} + +// reportCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rc ReportCollection) reportCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !rc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rc.NextLink))) +} + +// ReportCollectionPage contains a page of ReportRecordContract values. +type ReportCollectionPage struct { + fn func(context.Context, ReportCollection) (ReportCollection, error) + rc ReportCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ReportCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rc) + if err != nil { + return err + } + page.rc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ReportCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ReportCollectionPage) NotDone() bool { + return !page.rc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ReportCollectionPage) Response() ReportCollection { + return page.rc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ReportCollectionPage) Values() []ReportRecordContract { + if page.rc.IsEmpty() { + return nil + } + return *page.rc.Value +} + +// Creates a new instance of the ReportCollectionPage type. +func NewReportCollectionPage(cur ReportCollection, getNextPage func(context.Context, ReportCollection) (ReportCollection, error)) ReportCollectionPage { + return ReportCollectionPage{ + fn: getNextPage, + rc: cur, + } +} + +// ReportRecordContract report data. +type ReportRecordContract struct { + // Name - Name depending on report endpoint specifies product, API, operation or developer name. + Name *string `json:"name,omitempty"` + // Timestamp - Start of aggregation period. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Interval - Length of aggregation period. Interval must be multiple of 15 minutes and may not be zero. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations). + Interval *string `json:"interval,omitempty"` + // Country - Country to which this record data is related. + Country *string `json:"country,omitempty"` + // Region - Country region to which this record data is related. + Region *string `json:"region,omitempty"` + // Zip - Zip code to which this record data is related. + Zip *string `json:"zip,omitempty"` + // UserID - READ-ONLY; User identifier path. /users/{userId} + UserID *string `json:"userId,omitempty"` + // ProductID - READ-ONLY; Product identifier path. /products/{productId} + ProductID *string `json:"productId,omitempty"` + // APIID - API identifier path. /apis/{apiId} + APIID *string `json:"apiId,omitempty"` + // OperationID - Operation identifier path. /apis/{apiId}/operations/{operationId} + OperationID *string `json:"operationId,omitempty"` + // APIRegion - API region identifier. + APIRegion *string `json:"apiRegion,omitempty"` + // SubscriptionID - Subscription identifier path. /subscriptions/{subscriptionId} + SubscriptionID *string `json:"subscriptionId,omitempty"` + // CallCountSuccess - Number of successful calls. This includes calls returning HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect + CallCountSuccess *int32 `json:"callCountSuccess,omitempty"` + // CallCountBlocked - Number of calls blocked due to invalid credentials. This includes calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and HttpStatusCode.TooManyRequests + CallCountBlocked *int32 `json:"callCountBlocked,omitempty"` + // CallCountFailed - Number of calls failed due to proxy or backend errors. This includes calls returning HttpStatusCode.BadRequest(400) and any Code between HttpStatusCode.InternalServerError (500) and 600 + CallCountFailed *int32 `json:"callCountFailed,omitempty"` + // CallCountOther - Number of other calls. + CallCountOther *int32 `json:"callCountOther,omitempty"` + // CallCountTotal - Total number of calls. + CallCountTotal *int32 `json:"callCountTotal,omitempty"` + // Bandwidth - Bandwidth consumed. + Bandwidth *int64 `json:"bandwidth,omitempty"` + // CacheHitCount - Number of times when content was served from cache policy. + CacheHitCount *int32 `json:"cacheHitCount,omitempty"` + // CacheMissCount - Number of times content was fetched from backend. + CacheMissCount *int32 `json:"cacheMissCount,omitempty"` + // APITimeAvg - Average time it took to process request. + APITimeAvg *float64 `json:"apiTimeAvg,omitempty"` + // APITimeMin - Minimum time it took to process request. + APITimeMin *float64 `json:"apiTimeMin,omitempty"` + // APITimeMax - Maximum time it took to process request. + APITimeMax *float64 `json:"apiTimeMax,omitempty"` + // ServiceTimeAvg - Average time it took to process request on backend. + ServiceTimeAvg *float64 `json:"serviceTimeAvg,omitempty"` + // ServiceTimeMin - Minimum time it took to process request on backend. + ServiceTimeMin *float64 `json:"serviceTimeMin,omitempty"` + // ServiceTimeMax - Maximum time it took to process request on backend. + ServiceTimeMax *float64 `json:"serviceTimeMax,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReportRecordContract. +func (rrc ReportRecordContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rrc.Name != nil { + objectMap["name"] = rrc.Name + } + if rrc.Timestamp != nil { + objectMap["timestamp"] = rrc.Timestamp + } + if rrc.Interval != nil { + objectMap["interval"] = rrc.Interval + } + if rrc.Country != nil { + objectMap["country"] = rrc.Country + } + if rrc.Region != nil { + objectMap["region"] = rrc.Region + } + if rrc.Zip != nil { + objectMap["zip"] = rrc.Zip + } + if rrc.APIID != nil { + objectMap["apiId"] = rrc.APIID + } + if rrc.OperationID != nil { + objectMap["operationId"] = rrc.OperationID + } + if rrc.APIRegion != nil { + objectMap["apiRegion"] = rrc.APIRegion + } + if rrc.SubscriptionID != nil { + objectMap["subscriptionId"] = rrc.SubscriptionID + } + if rrc.CallCountSuccess != nil { + objectMap["callCountSuccess"] = rrc.CallCountSuccess + } + if rrc.CallCountBlocked != nil { + objectMap["callCountBlocked"] = rrc.CallCountBlocked + } + if rrc.CallCountFailed != nil { + objectMap["callCountFailed"] = rrc.CallCountFailed + } + if rrc.CallCountOther != nil { + objectMap["callCountOther"] = rrc.CallCountOther + } + if rrc.CallCountTotal != nil { + objectMap["callCountTotal"] = rrc.CallCountTotal + } + if rrc.Bandwidth != nil { + objectMap["bandwidth"] = rrc.Bandwidth + } + if rrc.CacheHitCount != nil { + objectMap["cacheHitCount"] = rrc.CacheHitCount + } + if rrc.CacheMissCount != nil { + objectMap["cacheMissCount"] = rrc.CacheMissCount + } + if rrc.APITimeAvg != nil { + objectMap["apiTimeAvg"] = rrc.APITimeAvg + } + if rrc.APITimeMin != nil { + objectMap["apiTimeMin"] = rrc.APITimeMin + } + if rrc.APITimeMax != nil { + objectMap["apiTimeMax"] = rrc.APITimeMax + } + if rrc.ServiceTimeAvg != nil { + objectMap["serviceTimeAvg"] = rrc.ServiceTimeAvg + } + if rrc.ServiceTimeMin != nil { + objectMap["serviceTimeMin"] = rrc.ServiceTimeMin + } + if rrc.ServiceTimeMax != nil { + objectMap["serviceTimeMax"] = rrc.ServiceTimeMax + } + return json.Marshal(objectMap) +} + +// RepresentationContract operation request/response representation details. +type RepresentationContract struct { + // ContentType - Specifies a registered or custom content type for this representation, e.g. application/xml. + ContentType *string `json:"contentType,omitempty"` + // Sample - An example of the representation. + Sample *string `json:"sample,omitempty"` + // SchemaID - Schema identifier. Applicable only if 'contentType' value is neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. + SchemaID *string `json:"schemaId,omitempty"` + // TypeName - Type name defined by the schema. Applicable only if 'contentType' value is neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. + TypeName *string `json:"typeName,omitempty"` + // FormParameters - Collection of form parameters. Required if 'contentType' value is either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. + FormParameters *[]ParameterContract `json:"formParameters,omitempty"` +} + +// RequestContract operation request details. +type RequestContract struct { + // Description - Operation request description. + Description *string `json:"description,omitempty"` + // QueryParameters - Collection of operation request query parameters. + QueryParameters *[]ParameterContract `json:"queryParameters,omitempty"` + // Headers - Collection of operation request headers. + Headers *[]ParameterContract `json:"headers,omitempty"` + // Representations - Collection of operation request representations. + Representations *[]RepresentationContract `json:"representations,omitempty"` +} + +// RequestReportCollection paged Report records list representation. +type RequestReportCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]RequestReportRecordContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` +} + +// RequestReportRecordContract request Report data. +type RequestReportRecordContract struct { + // APIID - API identifier path. /apis/{apiId} + APIID *string `json:"apiId,omitempty"` + // OperationID - Operation identifier path. /apis/{apiId}/operations/{operationId} + OperationID *string `json:"operationId,omitempty"` + // ProductID - READ-ONLY; Product identifier path. /products/{productId} + ProductID *string `json:"productId,omitempty"` + // UserID - READ-ONLY; User identifier path. /users/{userId} + UserID *string `json:"userId,omitempty"` + // Method - The HTTP method associated with this request.. + Method *string `json:"method,omitempty"` + // URL - The full URL associated with this request. + URL *string `json:"url,omitempty"` + // IPAddress - The client IP address associated with this request. + IPAddress *string `json:"ipAddress,omitempty"` + // BackendResponseCode - The HTTP status code received by the gateway as a result of forwarding this request to the backend. + BackendResponseCode *string `json:"backendResponseCode,omitempty"` + // ResponseCode - The HTTP status code returned by the gateway. + ResponseCode *int32 `json:"responseCode,omitempty"` + // ResponseSize - The size of the response returned by the gateway. + ResponseSize *int32 `json:"responseSize,omitempty"` + // Timestamp - The date and time when this request was received by the gateway in ISO 8601 format. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Cache - Specifies if response cache was involved in generating the response. If the value is none, the cache was not used. If the value is hit, cached response was returned. If the value is miss, the cache was used but lookup resulted in a miss and request was fulfilled by the backend. + Cache *string `json:"cache,omitempty"` + // APITime - The total time it took to process this request. + APITime *float64 `json:"apiTime,omitempty"` + // ServiceTime - he time it took to forward this request to the backend and get the response back. + ServiceTime *float64 `json:"serviceTime,omitempty"` + // APIRegion - Azure region where the gateway that processed this request is located. + APIRegion *string `json:"apiRegion,omitempty"` + // SubscriptionID - Subscription identifier path. /subscriptions/{subscriptionId} + SubscriptionID *string `json:"subscriptionId,omitempty"` + // RequestID - Request Identifier. + RequestID *string `json:"requestId,omitempty"` + // RequestSize - The size of this request.. + RequestSize *int32 `json:"requestSize,omitempty"` +} + +// MarshalJSON is the custom marshaler for RequestReportRecordContract. +func (rrrc RequestReportRecordContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rrrc.APIID != nil { + objectMap["apiId"] = rrrc.APIID + } + if rrrc.OperationID != nil { + objectMap["operationId"] = rrrc.OperationID + } + if rrrc.Method != nil { + objectMap["method"] = rrrc.Method + } + if rrrc.URL != nil { + objectMap["url"] = rrrc.URL + } + if rrrc.IPAddress != nil { + objectMap["ipAddress"] = rrrc.IPAddress + } + if rrrc.BackendResponseCode != nil { + objectMap["backendResponseCode"] = rrrc.BackendResponseCode + } + if rrrc.ResponseCode != nil { + objectMap["responseCode"] = rrrc.ResponseCode + } + if rrrc.ResponseSize != nil { + objectMap["responseSize"] = rrrc.ResponseSize + } + if rrrc.Timestamp != nil { + objectMap["timestamp"] = rrrc.Timestamp + } + if rrrc.Cache != nil { + objectMap["cache"] = rrrc.Cache + } + if rrrc.APITime != nil { + objectMap["apiTime"] = rrrc.APITime + } + if rrrc.ServiceTime != nil { + objectMap["serviceTime"] = rrrc.ServiceTime + } + if rrrc.APIRegion != nil { + objectMap["apiRegion"] = rrrc.APIRegion + } + if rrrc.SubscriptionID != nil { + objectMap["subscriptionId"] = rrrc.SubscriptionID + } + if rrrc.RequestID != nil { + objectMap["requestId"] = rrrc.RequestID + } + if rrrc.RequestSize != nil { + objectMap["requestSize"] = rrrc.RequestSize + } + return json.Marshal(objectMap) +} + +// Resource the Resource definition. +type Resource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceLocationDataContract resource location data properties. +type ResourceLocationDataContract struct { + // Name - A canonical name for the geographic or physical location. + Name *string `json:"name,omitempty"` + // City - The city or locality where the resource is located. + City *string `json:"city,omitempty"` + // District - The district, state, or province where the resource is located. + District *string `json:"district,omitempty"` + // CountryOrRegion - The country or region where the resource is located. + CountryOrRegion *string `json:"countryOrRegion,omitempty"` +} + +// ResourceSku describes an available API Management SKU. +type ResourceSku struct { + // Name - Name of the Sku. Possible values include: 'SkuTypeDeveloper', 'SkuTypeStandard', 'SkuTypePremium', 'SkuTypeBasic', 'SkuTypeConsumption', 'SkuTypeIsolated' + Name SkuType `json:"name,omitempty"` +} + +// ResourceSkuCapacity describes scaling information of a SKU. +type ResourceSkuCapacity struct { + // Minimum - READ-ONLY; The minimum capacity. + Minimum *int32 `json:"minimum,omitempty"` + // Maximum - READ-ONLY; The maximum capacity that can be set. + Maximum *int32 `json:"maximum,omitempty"` + // Default - READ-ONLY; The default capacity. + Default *int32 `json:"default,omitempty"` + // ScaleType - READ-ONLY; The scale type applicable to the sku. Possible values include: 'ResourceSkuCapacityScaleTypeAutomatic', 'ResourceSkuCapacityScaleTypeManual', 'ResourceSkuCapacityScaleTypeNone' + ScaleType ResourceSkuCapacityScaleType `json:"scaleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceSkuCapacity. +func (rsc ResourceSkuCapacity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceSkuResult describes an available API Management service SKU. +type ResourceSkuResult struct { + // ResourceType - READ-ONLY; The type of resource the SKU applies to. + ResourceType *string `json:"resourceType,omitempty"` + // Sku - READ-ONLY; Specifies API Management SKU. + Sku *ResourceSku `json:"sku,omitempty"` + // Capacity - READ-ONLY; Specifies the number of API Management units. + Capacity *ResourceSkuCapacity `json:"capacity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceSkuResult. +func (rsr ResourceSkuResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceSkuResults the API Management service SKUs operation response. +type ResourceSkuResults struct { + autorest.Response `json:"-"` + // Value - The list of skus available for the service. + Value *[]ResourceSkuResult `json:"value,omitempty"` + // NextLink - The uri to fetch the next page of API Management service Skus. + NextLink *string `json:"nextLink,omitempty"` +} + +// ResourceSkuResultsIterator provides access to a complete listing of ResourceSkuResult values. +type ResourceSkuResultsIterator struct { + i int + page ResourceSkuResultsPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ResourceSkuResultsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkuResultsIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ResourceSkuResultsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceSkuResultsIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ResourceSkuResultsIterator) Response() ResourceSkuResults { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ResourceSkuResultsIterator) Value() ResourceSkuResult { + if !iter.page.NotDone() { + return ResourceSkuResult{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ResourceSkuResultsIterator type. +func NewResourceSkuResultsIterator(page ResourceSkuResultsPage) ResourceSkuResultsIterator { + return ResourceSkuResultsIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rsr ResourceSkuResults) IsEmpty() bool { + return rsr.Value == nil || len(*rsr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rsr ResourceSkuResults) hasNextLink() bool { + return rsr.NextLink != nil && len(*rsr.NextLink) != 0 +} + +// resourceSkuResultsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rsr ResourceSkuResults) resourceSkuResultsPreparer(ctx context.Context) (*http.Request, error) { + if !rsr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rsr.NextLink))) +} + +// ResourceSkuResultsPage contains a page of ResourceSkuResult values. +type ResourceSkuResultsPage struct { + fn func(context.Context, ResourceSkuResults) (ResourceSkuResults, error) + rsr ResourceSkuResults +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ResourceSkuResultsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkuResultsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rsr) + if err != nil { + return err + } + page.rsr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ResourceSkuResultsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceSkuResultsPage) NotDone() bool { + return !page.rsr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceSkuResultsPage) Response() ResourceSkuResults { + return page.rsr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceSkuResultsPage) Values() []ResourceSkuResult { + if page.rsr.IsEmpty() { + return nil + } + return *page.rsr.Value +} + +// Creates a new instance of the ResourceSkuResultsPage type. +func NewResourceSkuResultsPage(cur ResourceSkuResults, getNextPage func(context.Context, ResourceSkuResults) (ResourceSkuResults, error)) ResourceSkuResultsPage { + return ResourceSkuResultsPage{ + fn: getNextPage, + rsr: cur, + } +} + +// ResponseContract operation response details. +type ResponseContract struct { + // StatusCode - Operation response HTTP status code. + StatusCode *int32 `json:"statusCode,omitempty"` + // Description - Operation response description. + Description *string `json:"description,omitempty"` + // Representations - Collection of operation response representations. + Representations *[]RepresentationContract `json:"representations,omitempty"` + // Headers - Collection of operation response headers. + Headers *[]ParameterContract `json:"headers,omitempty"` +} + +// SamplingSettings sampling settings for Diagnostic. +type SamplingSettings struct { + // SamplingType - Sampling type. Possible values include: 'SamplingTypeFixed' + SamplingType SamplingType `json:"samplingType,omitempty"` + // Percentage - Rate of sampling for fixed-rate sampling. + Percentage *float64 `json:"percentage,omitempty"` +} + +// SaveConfigurationParameter save Tenant Configuration Contract details. +type SaveConfigurationParameter struct { + // SaveConfigurationParameterProperties - Properties of the Save Configuration Parameters. + *SaveConfigurationParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SaveConfigurationParameter. +func (scp SaveConfigurationParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scp.SaveConfigurationParameterProperties != nil { + objectMap["properties"] = scp.SaveConfigurationParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SaveConfigurationParameter struct. +func (scp *SaveConfigurationParameter) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var saveConfigurationParameterProperties SaveConfigurationParameterProperties + err = json.Unmarshal(*v, &saveConfigurationParameterProperties) + if err != nil { + return err + } + scp.SaveConfigurationParameterProperties = &saveConfigurationParameterProperties + } + } + } + + return nil +} + +// SaveConfigurationParameterProperties parameters supplied to the Save Tenant Configuration operation. +type SaveConfigurationParameterProperties struct { + // Branch - The name of the Git branch in which to commit the current configuration snapshot. + Branch *string `json:"branch,omitempty"` + // Force - The value if true, the current configuration database is committed to the Git repository, even if the Git repository has newer changes that would be overwritten. + Force *bool `json:"force,omitempty"` +} + +// SchemaCollection the response of the list schema operation. +type SchemaCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; API Schema Contract value. + Value *[]SchemaContract `json:"value,omitempty"` + // Count - Total record count number. + Count *int64 `json:"count,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SchemaCollection. +func (sc SchemaCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sc.Count != nil { + objectMap["count"] = sc.Count + } + return json.Marshal(objectMap) +} + +// SchemaCollectionIterator provides access to a complete listing of SchemaContract values. +type SchemaCollectionIterator struct { + i int + page SchemaCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SchemaCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SchemaCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SchemaCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SchemaCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SchemaCollectionIterator) Response() SchemaCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SchemaCollectionIterator) Value() SchemaContract { + if !iter.page.NotDone() { + return SchemaContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SchemaCollectionIterator type. +func NewSchemaCollectionIterator(page SchemaCollectionPage) SchemaCollectionIterator { + return SchemaCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sc SchemaCollection) IsEmpty() bool { + return sc.Value == nil || len(*sc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sc SchemaCollection) hasNextLink() bool { + return sc.NextLink != nil && len(*sc.NextLink) != 0 +} + +// schemaCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sc SchemaCollection) schemaCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !sc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sc.NextLink))) +} + +// SchemaCollectionPage contains a page of SchemaContract values. +type SchemaCollectionPage struct { + fn func(context.Context, SchemaCollection) (SchemaCollection, error) + sc SchemaCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SchemaCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SchemaCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sc) + if err != nil { + return err + } + page.sc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SchemaCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SchemaCollectionPage) NotDone() bool { + return !page.sc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SchemaCollectionPage) Response() SchemaCollection { + return page.sc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SchemaCollectionPage) Values() []SchemaContract { + if page.sc.IsEmpty() { + return nil + } + return *page.sc.Value +} + +// Creates a new instance of the SchemaCollectionPage type. +func NewSchemaCollectionPage(cur SchemaCollection, getNextPage func(context.Context, SchemaCollection) (SchemaCollection, error)) SchemaCollectionPage { + return SchemaCollectionPage{ + fn: getNextPage, + sc: cur, + } +} + +// SchemaContract schema Contract details. +type SchemaContract struct { + autorest.Response `json:"-"` + // SchemaContractProperties - Properties of the Schema. + *SchemaContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SchemaContract. +func (sc SchemaContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sc.SchemaContractProperties != nil { + objectMap["properties"] = sc.SchemaContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SchemaContract struct. +func (sc *SchemaContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var schemaContractProperties SchemaContractProperties + err = json.Unmarshal(*v, &schemaContractProperties) + if err != nil { + return err + } + sc.SchemaContractProperties = &schemaContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sc.Type = &typeVar + } + } + } + + return nil +} + +// SchemaContractProperties API Schema create or update contract Properties. +type SchemaContractProperties struct { + // ContentType - Must be a valid a media type used in a Content-Type header as defined in the RFC 2616. Media type of the schema document (e.g. application/json, application/xml).
- `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`. + ContentType *string `json:"contentType,omitempty"` + // Document - Create or update Properties of the Schema Document. + Document interface{} `json:"document,omitempty"` +} + +// ServiceApplyNetworkConfigurationParameters parameter supplied to the Apply Network configuration +// operation. +type ServiceApplyNetworkConfigurationParameters struct { + // Location - Location of the Api Management service to update for a multi-region service. For a service deployed in a single region, this parameter is not required. + Location *string `json:"location,omitempty"` +} + +// ServiceApplyNetworkConfigurationUpdatesFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServiceApplyNetworkConfigurationUpdatesFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServiceClient) (ServiceResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServiceApplyNetworkConfigurationUpdatesFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServiceApplyNetworkConfigurationUpdatesFuture.Result. +func (future *ServiceApplyNetworkConfigurationUpdatesFuture) result(client ServiceClient) (sr ServiceResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceApplyNetworkConfigurationUpdatesFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.ServiceApplyNetworkConfigurationUpdatesFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sr.Response.Response, err = future.GetResult(sender); err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { + sr, err = client.ApplyNetworkConfigurationUpdatesResponder(sr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceApplyNetworkConfigurationUpdatesFuture", "Result", sr.Response.Response, "Failure responding to request") + } + } + return +} + +// ServiceBackupFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServiceBackupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServiceClient) (ServiceResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServiceBackupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServiceBackupFuture.Result. +func (future *ServiceBackupFuture) result(client ServiceClient) (sr ServiceResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceBackupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.ServiceBackupFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sr.Response.Response, err = future.GetResult(sender); err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { + sr, err = client.BackupResponder(sr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceBackupFuture", "Result", sr.Response.Response, "Failure responding to request") + } + } + return +} + +// ServiceBackupRestoreParameters parameters supplied to the Backup/Restore of an API Management service +// operation. +type ServiceBackupRestoreParameters struct { + // StorageAccount - Azure Cloud Storage account (used to place/retrieve the backup) name. + StorageAccount *string `json:"storageAccount,omitempty"` + // AccessKey - Azure Cloud Storage account (used to place/retrieve the backup) access key. + AccessKey *string `json:"accessKey,omitempty"` + // ContainerName - Azure Cloud Storage blob container name used to place/retrieve the backup. + ContainerName *string `json:"containerName,omitempty"` + // BackupName - The name of the backup file to create. + BackupName *string `json:"backupName,omitempty"` +} + +// ServiceBaseProperties base Properties of an API Management service resource description. +type ServiceBaseProperties struct { + // NotificationSenderEmail - Email address from which the notification will be sent. + NotificationSenderEmail *string `json:"notificationSenderEmail,omitempty"` + // ProvisioningState - READ-ONLY; The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + ProvisioningState *string `json:"provisioningState,omitempty"` + // TargetProvisioningState - READ-ONLY; The provisioning state of the API Management service, which is targeted by the long running operation started on the service. + TargetProvisioningState *string `json:"targetProvisioningState,omitempty"` + // CreatedAtUtc - READ-ONLY; Creation UTC date of the API Management service.The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + CreatedAtUtc *date.Time `json:"createdAtUtc,omitempty"` + // GatewayURL - READ-ONLY; Gateway URL of the API Management service. + GatewayURL *string `json:"gatewayUrl,omitempty"` + // GatewayRegionalURL - READ-ONLY; Gateway URL of the API Management service in the Default Region. + GatewayRegionalURL *string `json:"gatewayRegionalUrl,omitempty"` + // PortalURL - READ-ONLY; Publisher portal endpoint Url of the API Management service. + PortalURL *string `json:"portalUrl,omitempty"` + // ManagementAPIURL - READ-ONLY; Management API endpoint URL of the API Management service. + ManagementAPIURL *string `json:"managementApiUrl,omitempty"` + // ScmURL - READ-ONLY; SCM endpoint URL of the API Management service. + ScmURL *string `json:"scmUrl,omitempty"` + // DeveloperPortalURL - READ-ONLY; DEveloper Portal endpoint URL of the API Management service. + DeveloperPortalURL *string `json:"developerPortalUrl,omitempty"` + // HostnameConfigurations - Custom hostname configuration of the API Management service. + HostnameConfigurations *[]HostnameConfiguration `json:"hostnameConfigurations,omitempty"` + // PublicIPAddresses - READ-ONLY; Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. + PublicIPAddresses *[]string `json:"publicIPAddresses,omitempty"` + // PrivateIPAddresses - READ-ONLY; Private Static Load Balanced IP addresses of the API Management service in Primary region which is deployed in an Internal Virtual Network. Available only for Basic, Standard, Premium and Isolated SKU. + PrivateIPAddresses *[]string `json:"privateIPAddresses,omitempty"` + // PublicIPAddressID - Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the region. Supported only for Developer and Premium SKU being deployed in Virtual Network. + PublicIPAddressID *string `json:"publicIpAddressId,omitempty"` + // VirtualNetworkConfiguration - Virtual network configuration of the API Management service. + VirtualNetworkConfiguration *VirtualNetworkConfiguration `json:"virtualNetworkConfiguration,omitempty"` + // AdditionalLocations - Additional datacenter locations of the API Management service. + AdditionalLocations *[]AdditionalLocation `json:"additionalLocations,omitempty"` + // CustomProperties - Custom properties of the API Management service.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11` can be used to disable just TLS 1.1.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10` can be used to disable TLS 1.0 on an API Management service.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11` can be used to disable just TLS 1.1 for communications with backends.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10` can be used to disable TLS 1.0 for communications with backends.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2` can be used to enable HTTP2 protocol on an API Management service.
Not specifying any of these properties on PATCH operation will reset omitted properties' values to their defaults. For all the settings except Http2 the default value is `True` if the service was created on or before April 1st 2018 and `False` otherwise. Http2 setting's default value is `False`.

You can disable any of next ciphers by using settings `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:`false`. The default value is `true` for them. Note: next ciphers can't be disabled since they are required by Azure CloudService internal components: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384 + CustomProperties map[string]*string `json:"customProperties"` + // Certificates - List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. + Certificates *[]CertificateConfiguration `json:"certificates,omitempty"` + // EnableClientCertificate - Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. + EnableClientCertificate *bool `json:"enableClientCertificate,omitempty"` + // DisableGateway - 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 `json:"disableGateway,omitempty"` + // 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. Possible values include: 'VirtualNetworkTypeNone', 'VirtualNetworkTypeExternal', 'VirtualNetworkTypeInternal' + VirtualNetworkType VirtualNetworkType `json:"virtualNetworkType,omitempty"` + // APIVersionConstraint - Control Plane Apis version constraint for the API Management service. + APIVersionConstraint *APIVersionConstraint `json:"apiVersionConstraint,omitempty"` + // Restore - Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. + Restore *bool `json:"restore,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceBaseProperties. +func (sbp ServiceBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sbp.NotificationSenderEmail != nil { + objectMap["notificationSenderEmail"] = sbp.NotificationSenderEmail + } + if sbp.HostnameConfigurations != nil { + objectMap["hostnameConfigurations"] = sbp.HostnameConfigurations + } + if sbp.PublicIPAddressID != nil { + objectMap["publicIpAddressId"] = sbp.PublicIPAddressID + } + if sbp.VirtualNetworkConfiguration != nil { + objectMap["virtualNetworkConfiguration"] = sbp.VirtualNetworkConfiguration + } + if sbp.AdditionalLocations != nil { + objectMap["additionalLocations"] = sbp.AdditionalLocations + } + if sbp.CustomProperties != nil { + objectMap["customProperties"] = sbp.CustomProperties + } + if sbp.Certificates != nil { + objectMap["certificates"] = sbp.Certificates + } + if sbp.EnableClientCertificate != nil { + objectMap["enableClientCertificate"] = sbp.EnableClientCertificate + } + if sbp.DisableGateway != nil { + objectMap["disableGateway"] = sbp.DisableGateway + } + if sbp.VirtualNetworkType != "" { + objectMap["virtualNetworkType"] = sbp.VirtualNetworkType + } + if sbp.APIVersionConstraint != nil { + objectMap["apiVersionConstraint"] = sbp.APIVersionConstraint + } + if sbp.Restore != nil { + objectMap["restore"] = sbp.Restore + } + return json.Marshal(objectMap) +} + +// ServiceCheckNameAvailabilityParameters parameters supplied to the CheckNameAvailability operation. +type ServiceCheckNameAvailabilityParameters struct { + // Name - The name to check for availability. + Name *string `json:"name,omitempty"` +} + +// ServiceCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServiceCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServiceClient) (ServiceResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServiceCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServiceCreateOrUpdateFuture.Result. +func (future *ServiceCreateOrUpdateFuture) result(client ServiceClient) (sr ServiceResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.ServiceCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sr.Response.Response, err = future.GetResult(sender); err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { + sr, err = client.CreateOrUpdateResponder(sr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceCreateOrUpdateFuture", "Result", sr.Response.Response, "Failure responding to request") + } + } + return +} + +// ServiceDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServiceDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServiceClient) (ServiceResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServiceDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServiceDeleteFuture.Result. +func (future *ServiceDeleteFuture) result(client ServiceClient) (sr ServiceResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.ServiceDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sr.Response.Response, err = future.GetResult(sender); err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { + sr, err = client.DeleteResponder(sr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceDeleteFuture", "Result", sr.Response.Response, "Failure responding to request") + } + } + return +} + +// ServiceGetDomainOwnershipIdentifierResult response of the GetDomainOwnershipIdentifier operation. +type ServiceGetDomainOwnershipIdentifierResult struct { + autorest.Response `json:"-"` + // DomainOwnershipIdentifier - READ-ONLY; The domain ownership identifier value. + DomainOwnershipIdentifier *string `json:"domainOwnershipIdentifier,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceGetDomainOwnershipIdentifierResult. +func (sgdoir ServiceGetDomainOwnershipIdentifierResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServiceGetSsoTokenResult the response of the GetSsoToken operation. +type ServiceGetSsoTokenResult struct { + autorest.Response `json:"-"` + // RedirectURI - Redirect URL to the Publisher Portal containing the SSO token. + RedirectURI *string `json:"redirectUri,omitempty"` +} + +// ServiceIdentity identity properties of the Api Management service resource. +type ServiceIdentity struct { + // Type - The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. Possible values include: 'ApimIdentityTypeSystemAssigned', 'ApimIdentityTypeUserAssigned', 'ApimIdentityTypeSystemAssignedUserAssigned', 'ApimIdentityTypeNone' + Type ApimIdentityType `json:"type,omitempty"` + // PrincipalID - READ-ONLY; The principal id of the identity. + PrincipalID *uuid.UUID `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The client tenant id of the identity. + TenantID *uuid.UUID `json:"tenantId,omitempty"` + // UserAssignedIdentities - The list of user identities associated with the resource. The user identity + // dictionary key references will be ARM resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + // providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*UserIdentityProperties `json:"userAssignedIdentities"` +} + +// MarshalJSON is the custom marshaler for ServiceIdentity. +func (si ServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if si.Type != "" { + objectMap["type"] = si.Type + } + if si.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = si.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// ServiceListResult the response of the List API Management services operation. +type ServiceListResult struct { + autorest.Response `json:"-"` + // Value - Result of the List API Management services operation. + Value *[]ServiceResource `json:"value,omitempty"` + // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of API Management services. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceListResultIterator provides access to a complete listing of ServiceResource values. +type ServiceListResultIterator struct { + i int + page ServiceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServiceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServiceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServiceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServiceListResultIterator) Response() ServiceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServiceListResultIterator) Value() ServiceResource { + if !iter.page.NotDone() { + return ServiceResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServiceListResultIterator type. +func NewServiceListResultIterator(page ServiceListResultPage) ServiceListResultIterator { + return ServiceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServiceListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServiceListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 0 +} + +// serviceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServiceListResult) serviceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !slr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ServiceListResultPage contains a page of ServiceResource values. +type ServiceListResultPage struct { + fn func(context.Context, ServiceListResult) (ServiceListResult, error) + slr ServiceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServiceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServiceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServiceListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServiceListResultPage) Response() ServiceListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServiceListResultPage) Values() []ServiceResource { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the ServiceListResultPage type. +func NewServiceListResultPage(cur ServiceListResult, getNextPage func(context.Context, ServiceListResult) (ServiceListResult, error)) ServiceListResultPage { + return ServiceListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// ServiceNameAvailabilityResult response of the CheckNameAvailability operation. +type ServiceNameAvailabilityResult struct { + autorest.Response `json:"-"` + // NameAvailable - READ-ONLY; True if the name is available and can be used to create a new API Management service; otherwise false. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Message - READ-ONLY; If reason == invalid, provide the user with the reason why the given name is invalid, and provide the resource naming requirements so that the user can select a valid name. If reason == AlreadyExists, explain that is already in use, and direct them to select a different name. + Message *string `json:"message,omitempty"` + // Reason - 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. Possible values include: 'NameAvailabilityReasonValid', 'NameAvailabilityReasonInvalid', 'NameAvailabilityReasonAlreadyExists' + Reason NameAvailabilityReason `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceNameAvailabilityResult. +func (snar ServiceNameAvailabilityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if snar.Reason != "" { + objectMap["reason"] = snar.Reason + } + return json.Marshal(objectMap) +} + +// ServiceProperties properties of an API Management service resource description. +type ServiceProperties struct { + // PublisherEmail - Publisher email. + PublisherEmail *string `json:"publisherEmail,omitempty"` + // PublisherName - Publisher name. + PublisherName *string `json:"publisherName,omitempty"` + // NotificationSenderEmail - Email address from which the notification will be sent. + NotificationSenderEmail *string `json:"notificationSenderEmail,omitempty"` + // ProvisioningState - READ-ONLY; The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + ProvisioningState *string `json:"provisioningState,omitempty"` + // TargetProvisioningState - READ-ONLY; The provisioning state of the API Management service, which is targeted by the long running operation started on the service. + TargetProvisioningState *string `json:"targetProvisioningState,omitempty"` + // CreatedAtUtc - READ-ONLY; Creation UTC date of the API Management service.The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + CreatedAtUtc *date.Time `json:"createdAtUtc,omitempty"` + // GatewayURL - READ-ONLY; Gateway URL of the API Management service. + GatewayURL *string `json:"gatewayUrl,omitempty"` + // GatewayRegionalURL - READ-ONLY; Gateway URL of the API Management service in the Default Region. + GatewayRegionalURL *string `json:"gatewayRegionalUrl,omitempty"` + // PortalURL - READ-ONLY; Publisher portal endpoint Url of the API Management service. + PortalURL *string `json:"portalUrl,omitempty"` + // ManagementAPIURL - READ-ONLY; Management API endpoint URL of the API Management service. + ManagementAPIURL *string `json:"managementApiUrl,omitempty"` + // ScmURL - READ-ONLY; SCM endpoint URL of the API Management service. + ScmURL *string `json:"scmUrl,omitempty"` + // DeveloperPortalURL - READ-ONLY; DEveloper Portal endpoint URL of the API Management service. + DeveloperPortalURL *string `json:"developerPortalUrl,omitempty"` + // HostnameConfigurations - Custom hostname configuration of the API Management service. + HostnameConfigurations *[]HostnameConfiguration `json:"hostnameConfigurations,omitempty"` + // PublicIPAddresses - READ-ONLY; Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. + PublicIPAddresses *[]string `json:"publicIPAddresses,omitempty"` + // PrivateIPAddresses - READ-ONLY; Private Static Load Balanced IP addresses of the API Management service in Primary region which is deployed in an Internal Virtual Network. Available only for Basic, Standard, Premium and Isolated SKU. + PrivateIPAddresses *[]string `json:"privateIPAddresses,omitempty"` + // PublicIPAddressID - Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the region. Supported only for Developer and Premium SKU being deployed in Virtual Network. + PublicIPAddressID *string `json:"publicIpAddressId,omitempty"` + // VirtualNetworkConfiguration - Virtual network configuration of the API Management service. + VirtualNetworkConfiguration *VirtualNetworkConfiguration `json:"virtualNetworkConfiguration,omitempty"` + // AdditionalLocations - Additional datacenter locations of the API Management service. + AdditionalLocations *[]AdditionalLocation `json:"additionalLocations,omitempty"` + // CustomProperties - Custom properties of the API Management service.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11` can be used to disable just TLS 1.1.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10` can be used to disable TLS 1.0 on an API Management service.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11` can be used to disable just TLS 1.1 for communications with backends.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10` can be used to disable TLS 1.0 for communications with backends.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2` can be used to enable HTTP2 protocol on an API Management service.
Not specifying any of these properties on PATCH operation will reset omitted properties' values to their defaults. For all the settings except Http2 the default value is `True` if the service was created on or before April 1st 2018 and `False` otherwise. Http2 setting's default value is `False`.

You can disable any of next ciphers by using settings `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:`false`. The default value is `true` for them. Note: next ciphers can't be disabled since they are required by Azure CloudService internal components: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384 + CustomProperties map[string]*string `json:"customProperties"` + // Certificates - List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. + Certificates *[]CertificateConfiguration `json:"certificates,omitempty"` + // EnableClientCertificate - Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. + EnableClientCertificate *bool `json:"enableClientCertificate,omitempty"` + // DisableGateway - 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 `json:"disableGateway,omitempty"` + // 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. Possible values include: 'VirtualNetworkTypeNone', 'VirtualNetworkTypeExternal', 'VirtualNetworkTypeInternal' + VirtualNetworkType VirtualNetworkType `json:"virtualNetworkType,omitempty"` + // APIVersionConstraint - Control Plane Apis version constraint for the API Management service. + APIVersionConstraint *APIVersionConstraint `json:"apiVersionConstraint,omitempty"` + // Restore - Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. + Restore *bool `json:"restore,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceProperties. +func (sp ServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.PublisherEmail != nil { + objectMap["publisherEmail"] = sp.PublisherEmail + } + if sp.PublisherName != nil { + objectMap["publisherName"] = sp.PublisherName + } + if sp.NotificationSenderEmail != nil { + objectMap["notificationSenderEmail"] = sp.NotificationSenderEmail + } + if sp.HostnameConfigurations != nil { + objectMap["hostnameConfigurations"] = sp.HostnameConfigurations + } + if sp.PublicIPAddressID != nil { + objectMap["publicIpAddressId"] = sp.PublicIPAddressID + } + if sp.VirtualNetworkConfiguration != nil { + objectMap["virtualNetworkConfiguration"] = sp.VirtualNetworkConfiguration + } + if sp.AdditionalLocations != nil { + objectMap["additionalLocations"] = sp.AdditionalLocations + } + if sp.CustomProperties != nil { + objectMap["customProperties"] = sp.CustomProperties + } + if sp.Certificates != nil { + objectMap["certificates"] = sp.Certificates + } + if sp.EnableClientCertificate != nil { + objectMap["enableClientCertificate"] = sp.EnableClientCertificate + } + if sp.DisableGateway != nil { + objectMap["disableGateway"] = sp.DisableGateway + } + if sp.VirtualNetworkType != "" { + objectMap["virtualNetworkType"] = sp.VirtualNetworkType + } + if sp.APIVersionConstraint != nil { + objectMap["apiVersionConstraint"] = sp.APIVersionConstraint + } + if sp.Restore != nil { + objectMap["restore"] = sp.Restore + } + return json.Marshal(objectMap) +} + +// ServiceResource a single API Management service resource in List or Get response. +type ServiceResource struct { + autorest.Response `json:"-"` + // ServiceProperties - Properties of the API Management service. + *ServiceProperties `json:"properties,omitempty"` + // Sku - SKU properties of the API Management service. + Sku *ServiceSkuProperties `json:"sku,omitempty"` + // Identity - Managed service identity of the Api Management service. + Identity *ServiceIdentity `json:"identity,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Etag - READ-ONLY; ETag of the resource. + Etag *string `json:"etag,omitempty"` + // Zones - A list of availability zones denoting where the resource needs to come from. + Zones *[]string `json:"zones,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource is set to Microsoft.ApiManagement. + Type *string `json:"type,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServiceResource. +func (sr ServiceResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.ServiceProperties != nil { + objectMap["properties"] = sr.ServiceProperties + } + if sr.Sku != nil { + objectMap["sku"] = sr.Sku + } + if sr.Identity != nil { + objectMap["identity"] = sr.Identity + } + if sr.Location != nil { + objectMap["location"] = sr.Location + } + if sr.Zones != nil { + objectMap["zones"] = sr.Zones + } + if sr.Tags != nil { + objectMap["tags"] = sr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceResource struct. +func (sr *ServiceResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serviceProperties ServiceProperties + err = json.Unmarshal(*v, &serviceProperties) + if err != nil { + return err + } + sr.ServiceProperties = &serviceProperties + } + case "sku": + if v != nil { + var sku ServiceSkuProperties + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + sr.Sku = &sku + } + case "identity": + if v != nil { + var identity ServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + sr.Identity = &identity + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sr.Location = &location + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + sr.Etag = &etag + } + case "zones": + if v != nil { + var zones []string + err = json.Unmarshal(*v, &zones) + if err != nil { + return err + } + sr.Zones = &zones + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sr.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sr.Tags = tags + } + } + } + + return nil +} + +// ServiceRestoreFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServiceRestoreFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServiceClient) (ServiceResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServiceRestoreFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServiceRestoreFuture.Result. +func (future *ServiceRestoreFuture) result(client ServiceClient) (sr ServiceResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceRestoreFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.ServiceRestoreFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sr.Response.Response, err = future.GetResult(sender); err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { + sr, err = client.RestoreResponder(sr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceRestoreFuture", "Result", sr.Response.Response, "Failure responding to request") + } + } + return +} + +// ServiceSkuProperties API Management service resource SKU properties. +type ServiceSkuProperties struct { + // Name - Name of the Sku. Possible values include: 'SkuTypeDeveloper', 'SkuTypeStandard', 'SkuTypePremium', 'SkuTypeBasic', 'SkuTypeConsumption', 'SkuTypeIsolated' + Name SkuType `json:"name,omitempty"` + // Capacity - Capacity of the SKU (number of deployed units of the SKU). For Consumption SKU capacity must be specified as 0. + Capacity *int32 `json:"capacity,omitempty"` +} + +// ServiceUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServiceUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServiceClient) (ServiceResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServiceUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServiceUpdateFuture.Result. +func (future *ServiceUpdateFuture) result(client ServiceClient) (sr ServiceResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.ServiceUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sr.Response.Response, err = future.GetResult(sender); err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { + sr, err = client.UpdateResponder(sr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceUpdateFuture", "Result", sr.Response.Response, "Failure responding to request") + } + } + return +} + +// ServiceUpdateParameters parameter supplied to Update Api Management Service. +type ServiceUpdateParameters struct { + // ServiceUpdateProperties - Properties of the API Management service. + *ServiceUpdateProperties `json:"properties,omitempty"` + // Sku - SKU properties of the API Management service. + Sku *ServiceSkuProperties `json:"sku,omitempty"` + // Identity - Managed service identity of the Api Management service. + Identity *ServiceIdentity `json:"identity,omitempty"` + // Etag - READ-ONLY; ETag of the resource. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource is set to Microsoft.ApiManagement. + Type *string `json:"type,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServiceUpdateParameters. +func (sup ServiceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sup.ServiceUpdateProperties != nil { + objectMap["properties"] = sup.ServiceUpdateProperties + } + if sup.Sku != nil { + objectMap["sku"] = sup.Sku + } + if sup.Identity != nil { + objectMap["identity"] = sup.Identity + } + if sup.Tags != nil { + objectMap["tags"] = sup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceUpdateParameters struct. +func (sup *ServiceUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serviceUpdateProperties ServiceUpdateProperties + err = json.Unmarshal(*v, &serviceUpdateProperties) + if err != nil { + return err + } + sup.ServiceUpdateProperties = &serviceUpdateProperties + } + case "sku": + if v != nil { + var sku ServiceSkuProperties + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + sup.Sku = &sku + } + case "identity": + if v != nil { + var identity ServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + sup.Identity = &identity + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + sup.Etag = &etag + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sup.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sup.Tags = tags + } + } + } + + return nil +} + +// ServiceUpdateProperties properties of an API Management service resource description. +type ServiceUpdateProperties struct { + // PublisherEmail - Publisher email. + PublisherEmail *string `json:"publisherEmail,omitempty"` + // PublisherName - Publisher name. + PublisherName *string `json:"publisherName,omitempty"` + // NotificationSenderEmail - Email address from which the notification will be sent. + NotificationSenderEmail *string `json:"notificationSenderEmail,omitempty"` + // ProvisioningState - READ-ONLY; The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + ProvisioningState *string `json:"provisioningState,omitempty"` + // TargetProvisioningState - READ-ONLY; The provisioning state of the API Management service, which is targeted by the long running operation started on the service. + TargetProvisioningState *string `json:"targetProvisioningState,omitempty"` + // CreatedAtUtc - READ-ONLY; Creation UTC date of the API Management service.The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + CreatedAtUtc *date.Time `json:"createdAtUtc,omitempty"` + // GatewayURL - READ-ONLY; Gateway URL of the API Management service. + GatewayURL *string `json:"gatewayUrl,omitempty"` + // GatewayRegionalURL - READ-ONLY; Gateway URL of the API Management service in the Default Region. + GatewayRegionalURL *string `json:"gatewayRegionalUrl,omitempty"` + // PortalURL - READ-ONLY; Publisher portal endpoint Url of the API Management service. + PortalURL *string `json:"portalUrl,omitempty"` + // ManagementAPIURL - READ-ONLY; Management API endpoint URL of the API Management service. + ManagementAPIURL *string `json:"managementApiUrl,omitempty"` + // ScmURL - READ-ONLY; SCM endpoint URL of the API Management service. + ScmURL *string `json:"scmUrl,omitempty"` + // DeveloperPortalURL - READ-ONLY; DEveloper Portal endpoint URL of the API Management service. + DeveloperPortalURL *string `json:"developerPortalUrl,omitempty"` + // HostnameConfigurations - Custom hostname configuration of the API Management service. + HostnameConfigurations *[]HostnameConfiguration `json:"hostnameConfigurations,omitempty"` + // PublicIPAddresses - READ-ONLY; Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. + PublicIPAddresses *[]string `json:"publicIPAddresses,omitempty"` + // PrivateIPAddresses - READ-ONLY; Private Static Load Balanced IP addresses of the API Management service in Primary region which is deployed in an Internal Virtual Network. Available only for Basic, Standard, Premium and Isolated SKU. + PrivateIPAddresses *[]string `json:"privateIPAddresses,omitempty"` + // PublicIPAddressID - Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the region. Supported only for Developer and Premium SKU being deployed in Virtual Network. + PublicIPAddressID *string `json:"publicIpAddressId,omitempty"` + // VirtualNetworkConfiguration - Virtual network configuration of the API Management service. + VirtualNetworkConfiguration *VirtualNetworkConfiguration `json:"virtualNetworkConfiguration,omitempty"` + // AdditionalLocations - Additional datacenter locations of the API Management service. + AdditionalLocations *[]AdditionalLocation `json:"additionalLocations,omitempty"` + // CustomProperties - Custom properties of the API Management service.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11` can be used to disable just TLS 1.1.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10` can be used to disable TLS 1.0 on an API Management service.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11` can be used to disable just TLS 1.1 for communications with backends.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10` can be used to disable TLS 1.0 for communications with backends.
Setting `Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2` can be used to enable HTTP2 protocol on an API Management service.
Not specifying any of these properties on PATCH operation will reset omitted properties' values to their defaults. For all the settings except Http2 the default value is `True` if the service was created on or before April 1st 2018 and `False` otherwise. Http2 setting's default value is `False`.

You can disable any of next ciphers by using settings `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:`false`. The default value is `true` for them. Note: next ciphers can't be disabled since they are required by Azure CloudService internal components: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384 + CustomProperties map[string]*string `json:"customProperties"` + // Certificates - List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. + Certificates *[]CertificateConfiguration `json:"certificates,omitempty"` + // EnableClientCertificate - Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. + EnableClientCertificate *bool `json:"enableClientCertificate,omitempty"` + // DisableGateway - 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 `json:"disableGateway,omitempty"` + // 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. Possible values include: 'VirtualNetworkTypeNone', 'VirtualNetworkTypeExternal', 'VirtualNetworkTypeInternal' + VirtualNetworkType VirtualNetworkType `json:"virtualNetworkType,omitempty"` + // APIVersionConstraint - Control Plane Apis version constraint for the API Management service. + APIVersionConstraint *APIVersionConstraint `json:"apiVersionConstraint,omitempty"` + // Restore - Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. + Restore *bool `json:"restore,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceUpdateProperties. +func (sup ServiceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sup.PublisherEmail != nil { + objectMap["publisherEmail"] = sup.PublisherEmail + } + if sup.PublisherName != nil { + objectMap["publisherName"] = sup.PublisherName + } + if sup.NotificationSenderEmail != nil { + objectMap["notificationSenderEmail"] = sup.NotificationSenderEmail + } + if sup.HostnameConfigurations != nil { + objectMap["hostnameConfigurations"] = sup.HostnameConfigurations + } + if sup.PublicIPAddressID != nil { + objectMap["publicIpAddressId"] = sup.PublicIPAddressID + } + if sup.VirtualNetworkConfiguration != nil { + objectMap["virtualNetworkConfiguration"] = sup.VirtualNetworkConfiguration + } + if sup.AdditionalLocations != nil { + objectMap["additionalLocations"] = sup.AdditionalLocations + } + if sup.CustomProperties != nil { + objectMap["customProperties"] = sup.CustomProperties + } + if sup.Certificates != nil { + objectMap["certificates"] = sup.Certificates + } + if sup.EnableClientCertificate != nil { + objectMap["enableClientCertificate"] = sup.EnableClientCertificate + } + if sup.DisableGateway != nil { + objectMap["disableGateway"] = sup.DisableGateway + } + if sup.VirtualNetworkType != "" { + objectMap["virtualNetworkType"] = sup.VirtualNetworkType + } + if sup.APIVersionConstraint != nil { + objectMap["apiVersionConstraint"] = sup.APIVersionConstraint + } + if sup.Restore != nil { + objectMap["restore"] = sup.Restore + } + return json.Marshal(objectMap) +} + +// Sku describes an available ApiManagement SKU. +type Sku struct { + // ResourceType - READ-ONLY; The type of resource the SKU applies to. + ResourceType *string `json:"resourceType,omitempty"` + // Name - READ-ONLY; The name of SKU. + Name *string `json:"name,omitempty"` + // Tier - READ-ONLY; Specifies the tier of virtual machines in a scale set.

Possible Values:

**Standard**

**Basic** + Tier *string `json:"tier,omitempty"` + // Size - READ-ONLY; The Size of the SKU. + Size *string `json:"size,omitempty"` + // Family - READ-ONLY; The Family of this particular SKU. + Family *string `json:"family,omitempty"` + // Kind - READ-ONLY; The Kind of resources that are supported in this SKU. + Kind *string `json:"kind,omitempty"` + // Capacity - READ-ONLY; Specifies the number of virtual machines in the scale set. + Capacity *SkuCapacity `json:"capacity,omitempty"` + // Locations - READ-ONLY; The set of locations that the SKU is available. + Locations *[]string `json:"locations,omitempty"` + // LocationInfo - READ-ONLY; A list of locations and availability zones in those locations where the SKU is available. + LocationInfo *[]SkuLocationInfo `json:"locationInfo,omitempty"` + // APIVersions - READ-ONLY; The api versions that support this SKU. + APIVersions *[]string `json:"apiVersions,omitempty"` + // Costs - READ-ONLY; Metadata for retrieving price info. + Costs *[]SkuCosts `json:"costs,omitempty"` + // Capabilities - READ-ONLY; A name value pair to describe the capability. + Capabilities *[]SkuCapabilities `json:"capabilities,omitempty"` + // Restrictions - READ-ONLY; The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. + Restrictions *[]SkuRestrictions `json:"restrictions,omitempty"` +} + +// MarshalJSON is the custom marshaler for Sku. +func (s Sku) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SkuCapabilities describes The SKU capabilities object. +type SkuCapabilities struct { + // Name - READ-ONLY; An invariant to describe the feature. + Name *string `json:"name,omitempty"` + // Value - READ-ONLY; An invariant if the feature is measured by quantity. + Value *string `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for SkuCapabilities. +func (sc SkuCapabilities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SkuCapacity describes scaling information of a SKU. +type SkuCapacity struct { + // Minimum - READ-ONLY; The minimum capacity. + Minimum *int32 `json:"minimum,omitempty"` + // Maximum - READ-ONLY; The maximum capacity that can be set. + Maximum *int32 `json:"maximum,omitempty"` + // Default - READ-ONLY; The default capacity. + Default *int32 `json:"default,omitempty"` + // ScaleType - READ-ONLY; The scale type applicable to the sku. Possible values include: 'SkuCapacityScaleTypeAutomatic', 'SkuCapacityScaleTypeManual', 'SkuCapacityScaleTypeNone' + ScaleType SkuCapacityScaleType `json:"scaleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for SkuCapacity. +func (sc SkuCapacity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SkuCosts describes metadata for retrieving price info. +type SkuCosts struct { + // MeterID - READ-ONLY; Used for querying price from commerce. + MeterID *string `json:"meterID,omitempty"` + // Quantity - READ-ONLY; The multiplier is needed to extend the base metered cost. + Quantity *int64 `json:"quantity,omitempty"` + // ExtendedUnit - READ-ONLY; An invariant to show the extended unit. + ExtendedUnit *string `json:"extendedUnit,omitempty"` +} + +// MarshalJSON is the custom marshaler for SkuCosts. +func (sc SkuCosts) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SkuLocationInfo ... +type SkuLocationInfo struct { + // Location - READ-ONLY; Location of the SKU + Location *string `json:"location,omitempty"` + // Zones - READ-ONLY; List of availability zones where the SKU is supported. + Zones *[]string `json:"zones,omitempty"` + // ZoneDetails - READ-ONLY; Details of capabilities available to a SKU in specific zones. + ZoneDetails *[]SkuZoneDetails `json:"zoneDetails,omitempty"` +} + +// MarshalJSON is the custom marshaler for SkuLocationInfo. +func (sli SkuLocationInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SkuRestrictionInfo ... +type SkuRestrictionInfo struct { + // Locations - READ-ONLY; Locations where the SKU is restricted + Locations *[]string `json:"locations,omitempty"` + // Zones - READ-ONLY; List of availability zones where the SKU is restricted. + Zones *[]string `json:"zones,omitempty"` +} + +// MarshalJSON is the custom marshaler for SkuRestrictionInfo. +func (sri SkuRestrictionInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SkuRestrictions describes scaling information of a SKU. +type SkuRestrictions struct { + // Type - READ-ONLY; The type of restrictions. Possible values include: 'SkuRestrictionsTypeLocation', 'SkuRestrictionsTypeZone' + Type SkuRestrictionsType `json:"type,omitempty"` + // Values - READ-ONLY; The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. + Values *[]string `json:"values,omitempty"` + // RestrictionInfo - READ-ONLY; The information about the restriction where the SKU cannot be used. + RestrictionInfo *SkuRestrictionInfo `json:"restrictionInfo,omitempty"` + // ReasonCode - READ-ONLY; The reason for restriction. Possible values include: 'SkuRestrictionsReasonCodeQuotaID', 'SkuRestrictionsReasonCodeNotAvailableForSubscription' + ReasonCode SkuRestrictionsReasonCode `json:"reasonCode,omitempty"` +} + +// MarshalJSON is the custom marshaler for SkuRestrictions. +func (sr SkuRestrictions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SkusResult the List Resource Skus operation response. +type SkusResult struct { + autorest.Response `json:"-"` + // Value - The list of skus available for the subscription. + Value *[]Sku `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page of Resource Skus. Call ListNext() with this URI to fetch the next page of Resource Skus + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SkusResult. +func (sr SkusResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.Value != nil { + objectMap["value"] = sr.Value + } + return json.Marshal(objectMap) +} + +// SkusResultIterator provides access to a complete listing of Sku values. +type SkusResultIterator struct { + i int + page SkusResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SkusResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SkusResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SkusResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SkusResultIterator) Response() SkusResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SkusResultIterator) Value() Sku { + if !iter.page.NotDone() { + return Sku{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SkusResultIterator type. +func NewSkusResultIterator(page SkusResultPage) SkusResultIterator { + return SkusResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sr SkusResult) IsEmpty() bool { + return sr.Value == nil || len(*sr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sr SkusResult) hasNextLink() bool { + return sr.NextLink != nil && len(*sr.NextLink) != 0 +} + +// skusResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sr SkusResult) skusResultPreparer(ctx context.Context) (*http.Request, error) { + if !sr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sr.NextLink))) +} + +// SkusResultPage contains a page of Sku values. +type SkusResultPage struct { + fn func(context.Context, SkusResult) (SkusResult, error) + sr SkusResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SkusResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sr) + if err != nil { + return err + } + page.sr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SkusResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SkusResultPage) NotDone() bool { + return !page.sr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SkusResultPage) Response() SkusResult { + return page.sr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SkusResultPage) Values() []Sku { + if page.sr.IsEmpty() { + return nil + } + return *page.sr.Value +} + +// Creates a new instance of the SkusResultPage type. +func NewSkusResultPage(cur SkusResult, getNextPage func(context.Context, SkusResult) (SkusResult, error)) SkusResultPage { + return SkusResultPage{ + fn: getNextPage, + sr: cur, + } +} + +// SkuZoneDetails describes The zonal capabilities of a SKU. +type SkuZoneDetails struct { + // Name - READ-ONLY; The set of zones that the SKU is available in with the specified capabilities. + Name *[]string `json:"name,omitempty"` + // Capabilities - READ-ONLY; A list of capabilities that are available for the SKU in the specified list of zones. + Capabilities *[]SkuCapabilities `json:"capabilities,omitempty"` +} + +// MarshalJSON is the custom marshaler for SkuZoneDetails. +func (szd SkuZoneDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SubscriptionCollection paged Subscriptions list representation. +type SubscriptionCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]SubscriptionContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// SubscriptionCollectionIterator provides access to a complete listing of SubscriptionContract values. +type SubscriptionCollectionIterator struct { + i int + page SubscriptionCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SubscriptionCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SubscriptionCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SubscriptionCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SubscriptionCollectionIterator) Response() SubscriptionCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SubscriptionCollectionIterator) Value() SubscriptionContract { + if !iter.page.NotDone() { + return SubscriptionContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SubscriptionCollectionIterator type. +func NewSubscriptionCollectionIterator(page SubscriptionCollectionPage) SubscriptionCollectionIterator { + return SubscriptionCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sc SubscriptionCollection) IsEmpty() bool { + return sc.Value == nil || len(*sc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sc SubscriptionCollection) hasNextLink() bool { + return sc.NextLink != nil && len(*sc.NextLink) != 0 +} + +// subscriptionCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sc SubscriptionCollection) subscriptionCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !sc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sc.NextLink))) +} + +// SubscriptionCollectionPage contains a page of SubscriptionContract values. +type SubscriptionCollectionPage struct { + fn func(context.Context, SubscriptionCollection) (SubscriptionCollection, error) + sc SubscriptionCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SubscriptionCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sc) + if err != nil { + return err + } + page.sc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SubscriptionCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SubscriptionCollectionPage) NotDone() bool { + return !page.sc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SubscriptionCollectionPage) Response() SubscriptionCollection { + return page.sc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SubscriptionCollectionPage) Values() []SubscriptionContract { + if page.sc.IsEmpty() { + return nil + } + return *page.sc.Value +} + +// Creates a new instance of the SubscriptionCollectionPage type. +func NewSubscriptionCollectionPage(cur SubscriptionCollection, getNextPage func(context.Context, SubscriptionCollection) (SubscriptionCollection, error)) SubscriptionCollectionPage { + return SubscriptionCollectionPage{ + fn: getNextPage, + sc: cur, + } +} + +// SubscriptionContract subscription details. +type SubscriptionContract struct { + autorest.Response `json:"-"` + // SubscriptionContractProperties - Subscription contract properties. + *SubscriptionContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionContract. +func (sc SubscriptionContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sc.SubscriptionContractProperties != nil { + objectMap["properties"] = sc.SubscriptionContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SubscriptionContract struct. +func (sc *SubscriptionContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var subscriptionContractProperties SubscriptionContractProperties + err = json.Unmarshal(*v, &subscriptionContractProperties) + if err != nil { + return err + } + sc.SubscriptionContractProperties = &subscriptionContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sc.Type = &typeVar + } + } + } + + return nil +} + +// SubscriptionContractProperties subscription details. +type SubscriptionContractProperties struct { + // OwnerID - The user resource identifier of the subscription owner. The value is a valid relative URL in the format of /users/{userId} where {userId} is a user identifier. + OwnerID *string `json:"ownerId,omitempty"` + // Scope - Scope like /products/{productId} or /apis or /apis/{apiId}. + Scope *string `json:"scope,omitempty"` + // DisplayName - The name of the subscription, or null if the subscription has no name. + DisplayName *string `json:"displayName,omitempty"` + // State - Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. Possible values include: 'SubscriptionStateSuspended', 'SubscriptionStateActive', 'SubscriptionStateExpired', 'SubscriptionStateSubmitted', 'SubscriptionStateRejected', 'SubscriptionStateCancelled' + State SubscriptionState `json:"state,omitempty"` + // CreatedDate - READ-ONLY; Subscription creation date. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + CreatedDate *date.Time `json:"createdDate,omitempty"` + // StartDate - Subscription activation date. The setting is for audit purposes only and the subscription is not automatically activated. The subscription lifecycle can be managed by using the `state` property. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + StartDate *date.Time `json:"startDate,omitempty"` + // ExpirationDate - Subscription expiration date. The setting is for audit purposes only and the subscription is not automatically expired. The subscription lifecycle can be managed by using the `state` property. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + ExpirationDate *date.Time `json:"expirationDate,omitempty"` + // EndDate - Date when subscription was cancelled or expired. The setting is for audit purposes only and the subscription is not automatically cancelled. The subscription lifecycle can be managed by using the `state` property. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + EndDate *date.Time `json:"endDate,omitempty"` + // NotificationDate - Upcoming subscription expiration notification date. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + NotificationDate *date.Time `json:"notificationDate,omitempty"` + // PrimaryKey - Subscription primary key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - Subscription secondary key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // StateComment - Optional subscription comment added by an administrator when the state is changed to the 'rejected'. + StateComment *string `json:"stateComment,omitempty"` + // AllowTracing - Determines whether tracing is enabled + AllowTracing *bool `json:"allowTracing,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionContractProperties. +func (scp SubscriptionContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scp.OwnerID != nil { + objectMap["ownerId"] = scp.OwnerID + } + if scp.Scope != nil { + objectMap["scope"] = scp.Scope + } + if scp.DisplayName != nil { + objectMap["displayName"] = scp.DisplayName + } + if scp.State != "" { + objectMap["state"] = scp.State + } + if scp.StartDate != nil { + objectMap["startDate"] = scp.StartDate + } + if scp.ExpirationDate != nil { + objectMap["expirationDate"] = scp.ExpirationDate + } + if scp.EndDate != nil { + objectMap["endDate"] = scp.EndDate + } + if scp.NotificationDate != nil { + objectMap["notificationDate"] = scp.NotificationDate + } + if scp.PrimaryKey != nil { + objectMap["primaryKey"] = scp.PrimaryKey + } + if scp.SecondaryKey != nil { + objectMap["secondaryKey"] = scp.SecondaryKey + } + if scp.StateComment != nil { + objectMap["stateComment"] = scp.StateComment + } + if scp.AllowTracing != nil { + objectMap["allowTracing"] = scp.AllowTracing + } + return json.Marshal(objectMap) +} + +// SubscriptionCreateParameterProperties parameters supplied to the Create subscription operation. +type SubscriptionCreateParameterProperties struct { + // OwnerID - User (user id path) for whom subscription is being created in form /users/{userId} + OwnerID *string `json:"ownerId,omitempty"` + // Scope - Scope like /products/{productId} or /apis or /apis/{apiId}. + Scope *string `json:"scope,omitempty"` + // DisplayName - Subscription name. + DisplayName *string `json:"displayName,omitempty"` + // PrimaryKey - Primary subscription key. If not specified during request key will be generated automatically. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - Secondary subscription key. If not specified during request key will be generated automatically. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // State - Initial subscription state. If no value is specified, subscription is created with Submitted state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. Possible values include: 'SubscriptionStateSuspended', 'SubscriptionStateActive', 'SubscriptionStateExpired', 'SubscriptionStateSubmitted', 'SubscriptionStateRejected', 'SubscriptionStateCancelled' + State SubscriptionState `json:"state,omitempty"` + // AllowTracing - Determines whether tracing can be enabled + AllowTracing *bool `json:"allowTracing,omitempty"` +} + +// SubscriptionCreateParameters subscription create details. +type SubscriptionCreateParameters struct { + // SubscriptionCreateParameterProperties - Subscription contract properties. + *SubscriptionCreateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionCreateParameters. +func (scp SubscriptionCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scp.SubscriptionCreateParameterProperties != nil { + objectMap["properties"] = scp.SubscriptionCreateParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SubscriptionCreateParameters struct. +func (scp *SubscriptionCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var subscriptionCreateParameterProperties SubscriptionCreateParameterProperties + err = json.Unmarshal(*v, &subscriptionCreateParameterProperties) + if err != nil { + return err + } + scp.SubscriptionCreateParameterProperties = &subscriptionCreateParameterProperties + } + } + } + + return nil +} + +// SubscriptionKeyParameterNamesContract subscription key parameter names details. +type SubscriptionKeyParameterNamesContract struct { + // Header - Subscription key header name. + Header *string `json:"header,omitempty"` + // Query - Subscription key query string parameter name. + Query *string `json:"query,omitempty"` +} + +// SubscriptionKeysContract subscription keys. +type SubscriptionKeysContract struct { + autorest.Response `json:"-"` + // PrimaryKey - Subscription primary key. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - Subscription secondary key. + SecondaryKey *string `json:"secondaryKey,omitempty"` +} + +// SubscriptionsDelegationSettingsProperties subscriptions delegation settings properties. +type SubscriptionsDelegationSettingsProperties struct { + // Enabled - Enable or disable delegation for subscriptions. + Enabled *bool `json:"enabled,omitempty"` +} + +// SubscriptionUpdateParameterProperties parameters supplied to the Update subscription operation. +type SubscriptionUpdateParameterProperties struct { + // OwnerID - User identifier path: /users/{userId} + OwnerID *string `json:"ownerId,omitempty"` + // Scope - Scope like /products/{productId} or /apis or /apis/{apiId} + Scope *string `json:"scope,omitempty"` + // ExpirationDate - Subscription expiration date. The setting is for audit purposes only and the subscription is not automatically expired. The subscription lifecycle can be managed by using the `state` property. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + ExpirationDate *date.Time `json:"expirationDate,omitempty"` + // DisplayName - Subscription name. + DisplayName *string `json:"displayName,omitempty"` + // PrimaryKey - Primary subscription key. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - Secondary subscription key. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // State - Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. Possible values include: 'SubscriptionStateSuspended', 'SubscriptionStateActive', 'SubscriptionStateExpired', 'SubscriptionStateSubmitted', 'SubscriptionStateRejected', 'SubscriptionStateCancelled' + State SubscriptionState `json:"state,omitempty"` + // StateComment - Comments describing subscription state change by the administrator when the state is changed to the 'rejected'. + StateComment *string `json:"stateComment,omitempty"` + // AllowTracing - Determines whether tracing can be enabled + AllowTracing *bool `json:"allowTracing,omitempty"` +} + +// SubscriptionUpdateParameters subscription update details. +type SubscriptionUpdateParameters struct { + // SubscriptionUpdateParameterProperties - Subscription Update contract properties. + *SubscriptionUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUpdateParameters. +func (sup SubscriptionUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sup.SubscriptionUpdateParameterProperties != nil { + objectMap["properties"] = sup.SubscriptionUpdateParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SubscriptionUpdateParameters struct. +func (sup *SubscriptionUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var subscriptionUpdateParameterProperties SubscriptionUpdateParameterProperties + err = json.Unmarshal(*v, &subscriptionUpdateParameterProperties) + if err != nil { + return err + } + sup.SubscriptionUpdateParameterProperties = &subscriptionUpdateParameterProperties + } + } + } + + return nil +} + +// TagCollection paged Tag list representation. +type TagCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]TagContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// TagCollectionIterator provides access to a complete listing of TagContract values. +type TagCollectionIterator struct { + i int + page TagCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *TagCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TagCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TagCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter TagCollectionIterator) Response() TagCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter TagCollectionIterator) Value() TagContract { + if !iter.page.NotDone() { + return TagContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TagCollectionIterator type. +func NewTagCollectionIterator(page TagCollectionPage) TagCollectionIterator { + return TagCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tc TagCollection) IsEmpty() bool { + return tc.Value == nil || len(*tc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tc TagCollection) hasNextLink() bool { + return tc.NextLink != nil && len(*tc.NextLink) != 0 +} + +// tagCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tc TagCollection) tagCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !tc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tc.NextLink))) +} + +// TagCollectionPage contains a page of TagContract values. +type TagCollectionPage struct { + fn func(context.Context, TagCollection) (TagCollection, error) + tc TagCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *TagCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.tc) + if err != nil { + return err + } + page.tc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TagCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TagCollectionPage) NotDone() bool { + return !page.tc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TagCollectionPage) Response() TagCollection { + return page.tc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TagCollectionPage) Values() []TagContract { + if page.tc.IsEmpty() { + return nil + } + return *page.tc.Value +} + +// Creates a new instance of the TagCollectionPage type. +func NewTagCollectionPage(cur TagCollection, getNextPage func(context.Context, TagCollection) (TagCollection, error)) TagCollectionPage { + return TagCollectionPage{ + fn: getNextPage, + tc: cur, + } +} + +// TagContract tag Contract details. +type TagContract struct { + autorest.Response `json:"-"` + // TagContractProperties - Tag entity contract properties. + *TagContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TagContract. +func (tc TagContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tc.TagContractProperties != nil { + objectMap["properties"] = tc.TagContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TagContract struct. +func (tc *TagContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tagContractProperties TagContractProperties + err = json.Unmarshal(*v, &tagContractProperties) + if err != nil { + return err + } + tc.TagContractProperties = &tagContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tc.Type = &typeVar + } + } + } + + return nil +} + +// TagContractProperties tag contract Properties. +type TagContractProperties struct { + // DisplayName - Tag name. + DisplayName *string `json:"displayName,omitempty"` +} + +// TagCreateUpdateParameters parameters supplied to Create/Update Tag operations. +type TagCreateUpdateParameters struct { + // TagContractProperties - Properties supplied to Create Tag operation. + *TagContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for TagCreateUpdateParameters. +func (tcup TagCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tcup.TagContractProperties != nil { + objectMap["properties"] = tcup.TagContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TagCreateUpdateParameters struct. +func (tcup *TagCreateUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tagContractProperties TagContractProperties + err = json.Unmarshal(*v, &tagContractProperties) + if err != nil { + return err + } + tcup.TagContractProperties = &tagContractProperties + } + } + } + + return nil +} + +// TagDescriptionBaseProperties parameters supplied to the Create TagDescription operation. +type TagDescriptionBaseProperties struct { + // Description - Description of the Tag. + Description *string `json:"description,omitempty"` + // ExternalDocsURL - Absolute URL of external resources describing the tag. + ExternalDocsURL *string `json:"externalDocsUrl,omitempty"` + // ExternalDocsDescription - Description of the external resources describing the tag. + ExternalDocsDescription *string `json:"externalDocsDescription,omitempty"` +} + +// TagDescriptionCollection paged TagDescription list representation. +type TagDescriptionCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]TagDescriptionContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// TagDescriptionCollectionIterator provides access to a complete listing of TagDescriptionContract values. +type TagDescriptionCollectionIterator struct { + i int + page TagDescriptionCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *TagDescriptionCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagDescriptionCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TagDescriptionCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TagDescriptionCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter TagDescriptionCollectionIterator) Response() TagDescriptionCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter TagDescriptionCollectionIterator) Value() TagDescriptionContract { + if !iter.page.NotDone() { + return TagDescriptionContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TagDescriptionCollectionIterator type. +func NewTagDescriptionCollectionIterator(page TagDescriptionCollectionPage) TagDescriptionCollectionIterator { + return TagDescriptionCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tdc TagDescriptionCollection) IsEmpty() bool { + return tdc.Value == nil || len(*tdc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tdc TagDescriptionCollection) hasNextLink() bool { + return tdc.NextLink != nil && len(*tdc.NextLink) != 0 +} + +// tagDescriptionCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tdc TagDescriptionCollection) tagDescriptionCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !tdc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tdc.NextLink))) +} + +// TagDescriptionCollectionPage contains a page of TagDescriptionContract values. +type TagDescriptionCollectionPage struct { + fn func(context.Context, TagDescriptionCollection) (TagDescriptionCollection, error) + tdc TagDescriptionCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *TagDescriptionCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagDescriptionCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.tdc) + if err != nil { + return err + } + page.tdc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TagDescriptionCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TagDescriptionCollectionPage) NotDone() bool { + return !page.tdc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TagDescriptionCollectionPage) Response() TagDescriptionCollection { + return page.tdc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TagDescriptionCollectionPage) Values() []TagDescriptionContract { + if page.tdc.IsEmpty() { + return nil + } + return *page.tdc.Value +} + +// Creates a new instance of the TagDescriptionCollectionPage type. +func NewTagDescriptionCollectionPage(cur TagDescriptionCollection, getNextPage func(context.Context, TagDescriptionCollection) (TagDescriptionCollection, error)) TagDescriptionCollectionPage { + return TagDescriptionCollectionPage{ + fn: getNextPage, + tdc: cur, + } +} + +// TagDescriptionContract contract details. +type TagDescriptionContract struct { + autorest.Response `json:"-"` + // TagDescriptionContractProperties - TagDescription entity contract properties. + *TagDescriptionContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TagDescriptionContract. +func (tdc TagDescriptionContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tdc.TagDescriptionContractProperties != nil { + objectMap["properties"] = tdc.TagDescriptionContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TagDescriptionContract struct. +func (tdc *TagDescriptionContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tagDescriptionContractProperties TagDescriptionContractProperties + err = json.Unmarshal(*v, &tagDescriptionContractProperties) + if err != nil { + return err + } + tdc.TagDescriptionContractProperties = &tagDescriptionContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tdc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tdc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tdc.Type = &typeVar + } + } + } + + return nil +} + +// TagDescriptionContractProperties tagDescription contract Properties. +type TagDescriptionContractProperties struct { + // TagID - Identifier of the tag in the form of /tags/{tagId} + TagID *string `json:"tagId,omitempty"` + // DisplayName - Tag name. + DisplayName *string `json:"displayName,omitempty"` + // Description - Description of the Tag. + Description *string `json:"description,omitempty"` + // ExternalDocsURL - Absolute URL of external resources describing the tag. + ExternalDocsURL *string `json:"externalDocsUrl,omitempty"` + // ExternalDocsDescription - Description of the external resources describing the tag. + ExternalDocsDescription *string `json:"externalDocsDescription,omitempty"` +} + +// TagDescriptionCreateParameters parameters supplied to the Create TagDescription operation. +type TagDescriptionCreateParameters struct { + // TagDescriptionBaseProperties - Properties supplied to Create TagDescription operation. + *TagDescriptionBaseProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for TagDescriptionCreateParameters. +func (tdcp TagDescriptionCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tdcp.TagDescriptionBaseProperties != nil { + objectMap["properties"] = tdcp.TagDescriptionBaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TagDescriptionCreateParameters struct. +func (tdcp *TagDescriptionCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tagDescriptionBaseProperties TagDescriptionBaseProperties + err = json.Unmarshal(*v, &tagDescriptionBaseProperties) + if err != nil { + return err + } + tdcp.TagDescriptionBaseProperties = &tagDescriptionBaseProperties + } + } + } + + return nil +} + +// TagResourceCollection paged Tag list representation. +type TagResourceCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]TagResourceContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// TagResourceCollectionIterator provides access to a complete listing of TagResourceContract values. +type TagResourceCollectionIterator struct { + i int + page TagResourceCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *TagResourceCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagResourceCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TagResourceCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TagResourceCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter TagResourceCollectionIterator) Response() TagResourceCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter TagResourceCollectionIterator) Value() TagResourceContract { + if !iter.page.NotDone() { + return TagResourceContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TagResourceCollectionIterator type. +func NewTagResourceCollectionIterator(page TagResourceCollectionPage) TagResourceCollectionIterator { + return TagResourceCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (trc TagResourceCollection) IsEmpty() bool { + return trc.Value == nil || len(*trc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (trc TagResourceCollection) hasNextLink() bool { + return trc.NextLink != nil && len(*trc.NextLink) != 0 +} + +// tagResourceCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (trc TagResourceCollection) tagResourceCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !trc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(trc.NextLink))) +} + +// TagResourceCollectionPage contains a page of TagResourceContract values. +type TagResourceCollectionPage struct { + fn func(context.Context, TagResourceCollection) (TagResourceCollection, error) + trc TagResourceCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *TagResourceCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagResourceCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.trc) + if err != nil { + return err + } + page.trc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TagResourceCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TagResourceCollectionPage) NotDone() bool { + return !page.trc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TagResourceCollectionPage) Response() TagResourceCollection { + return page.trc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TagResourceCollectionPage) Values() []TagResourceContract { + if page.trc.IsEmpty() { + return nil + } + return *page.trc.Value +} + +// Creates a new instance of the TagResourceCollectionPage type. +func NewTagResourceCollectionPage(cur TagResourceCollection, getNextPage func(context.Context, TagResourceCollection) (TagResourceCollection, error)) TagResourceCollectionPage { + return TagResourceCollectionPage{ + fn: getNextPage, + trc: cur, + } +} + +// TagResourceContract tagResource contract properties. +type TagResourceContract struct { + // Tag - Tag associated with the resource. + Tag *TagTagResourceContractProperties `json:"tag,omitempty"` + // API - API associated with the tag. + API *APITagResourceContractProperties `json:"api,omitempty"` + // Operation - Operation associated with the tag. + Operation *OperationTagResourceContractProperties `json:"operation,omitempty"` + // Product - Product associated with the tag. + Product *ProductTagResourceContractProperties `json:"product,omitempty"` +} + +// TagTagResourceContractProperties contract defining the Tag property in the Tag Resource Contract +type TagTagResourceContractProperties struct { + // ID - Tag identifier + ID *string `json:"id,omitempty"` + // Name - Tag Name + Name *string `json:"name,omitempty"` +} + +// TenantConfigurationDeployFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TenantConfigurationDeployFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TenantConfigurationClient) (OperationResultContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TenantConfigurationDeployFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TenantConfigurationDeployFuture.Result. +func (future *TenantConfigurationDeployFuture) result(client TenantConfigurationClient) (orc OperationResultContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationDeployFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + orc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.TenantConfigurationDeployFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if orc.Response.Response, err = future.GetResult(sender); err == nil && orc.Response.Response.StatusCode != http.StatusNoContent { + orc, err = client.DeployResponder(orc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationDeployFuture", "Result", orc.Response.Response, "Failure responding to request") + } + } + return +} + +// TenantConfigurationSaveFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type TenantConfigurationSaveFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TenantConfigurationClient) (OperationResultContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TenantConfigurationSaveFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TenantConfigurationSaveFuture.Result. +func (future *TenantConfigurationSaveFuture) result(client TenantConfigurationClient) (orc OperationResultContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationSaveFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + orc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.TenantConfigurationSaveFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if orc.Response.Response, err = future.GetResult(sender); err == nil && orc.Response.Response.StatusCode != http.StatusNoContent { + orc, err = client.SaveResponder(orc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationSaveFuture", "Result", orc.Response.Response, "Failure responding to request") + } + } + return +} + +// TenantConfigurationSyncStateContract result of Tenant Configuration Sync State. +type TenantConfigurationSyncStateContract struct { + autorest.Response `json:"-"` + // TenantConfigurationSyncStateContractProperties - Properties returned Tenant Configuration Sync State check. + *TenantConfigurationSyncStateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for TenantConfigurationSyncStateContract. +func (tcssc TenantConfigurationSyncStateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tcssc.TenantConfigurationSyncStateContractProperties != nil { + objectMap["properties"] = tcssc.TenantConfigurationSyncStateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TenantConfigurationSyncStateContract struct. +func (tcssc *TenantConfigurationSyncStateContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tenantConfigurationSyncStateContractProperties TenantConfigurationSyncStateContractProperties + err = json.Unmarshal(*v, &tenantConfigurationSyncStateContractProperties) + if err != nil { + return err + } + tcssc.TenantConfigurationSyncStateContractProperties = &tenantConfigurationSyncStateContractProperties + } + } + } + + return nil +} + +// TenantConfigurationSyncStateContractProperties tenant Configuration Synchronization State. +type TenantConfigurationSyncStateContractProperties struct { + // Branch - The name of Git branch. + Branch *string `json:"branch,omitempty"` + // CommitID - The latest commit Id. + CommitID *string `json:"commitId,omitempty"` + // IsExport - value indicating if last sync was save (true) or deploy (false) operation. + IsExport *bool `json:"isExport,omitempty"` + // IsSynced - value indicating if last synchronization was later than the configuration change. + IsSynced *bool `json:"isSynced,omitempty"` + // IsGitEnabled - value indicating whether Git configuration access is enabled. + IsGitEnabled *bool `json:"isGitEnabled,omitempty"` + // SyncDate - The date of the latest synchronization. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + SyncDate *date.Time `json:"syncDate,omitempty"` + // ConfigurationChangeDate - The date of the latest configuration change. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + ConfigurationChangeDate *date.Time `json:"configurationChangeDate,omitempty"` + // LastOperationID - Most recent tenant configuration operation identifier + LastOperationID *string `json:"lastOperationId,omitempty"` +} + +// TenantConfigurationValidateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TenantConfigurationValidateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TenantConfigurationClient) (OperationResultContract, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TenantConfigurationValidateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TenantConfigurationValidateFuture.Result. +func (future *TenantConfigurationValidateFuture) result(client TenantConfigurationClient) (orc OperationResultContract, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationValidateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + orc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("apimanagement.TenantConfigurationValidateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if orc.Response.Response, err = future.GetResult(sender); err == nil && orc.Response.Response.StatusCode != http.StatusNoContent { + orc, err = client.ValidateResponder(orc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationValidateFuture", "Result", orc.Response.Response, "Failure responding to request") + } + } + return +} + +// TenantSettingsCollection paged AccessInformation list representation. +type TenantSettingsCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Page values. + Value *[]TenantSettingsContract `json:"value,omitempty"` + // NextLink - READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for TenantSettingsCollection. +func (tsc TenantSettingsCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TenantSettingsCollectionIterator provides access to a complete listing of TenantSettingsContract values. +type TenantSettingsCollectionIterator struct { + i int + page TenantSettingsCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *TenantSettingsCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantSettingsCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TenantSettingsCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TenantSettingsCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter TenantSettingsCollectionIterator) Response() TenantSettingsCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter TenantSettingsCollectionIterator) Value() TenantSettingsContract { + if !iter.page.NotDone() { + return TenantSettingsContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TenantSettingsCollectionIterator type. +func NewTenantSettingsCollectionIterator(page TenantSettingsCollectionPage) TenantSettingsCollectionIterator { + return TenantSettingsCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tsc TenantSettingsCollection) IsEmpty() bool { + return tsc.Value == nil || len(*tsc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tsc TenantSettingsCollection) hasNextLink() bool { + return tsc.NextLink != nil && len(*tsc.NextLink) != 0 +} + +// tenantSettingsCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tsc TenantSettingsCollection) tenantSettingsCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !tsc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tsc.NextLink))) +} + +// TenantSettingsCollectionPage contains a page of TenantSettingsContract values. +type TenantSettingsCollectionPage struct { + fn func(context.Context, TenantSettingsCollection) (TenantSettingsCollection, error) + tsc TenantSettingsCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *TenantSettingsCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantSettingsCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.tsc) + if err != nil { + return err + } + page.tsc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TenantSettingsCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TenantSettingsCollectionPage) NotDone() bool { + return !page.tsc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TenantSettingsCollectionPage) Response() TenantSettingsCollection { + return page.tsc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TenantSettingsCollectionPage) Values() []TenantSettingsContract { + if page.tsc.IsEmpty() { + return nil + } + return *page.tsc.Value +} + +// Creates a new instance of the TenantSettingsCollectionPage type. +func NewTenantSettingsCollectionPage(cur TenantSettingsCollection, getNextPage func(context.Context, TenantSettingsCollection) (TenantSettingsCollection, error)) TenantSettingsCollectionPage { + return TenantSettingsCollectionPage{ + fn: getNextPage, + tsc: cur, + } +} + +// TenantSettingsContract tenant Settings. +type TenantSettingsContract struct { + autorest.Response `json:"-"` + // TenantSettingsContractProperties - TenantSettings entity contract properties. + *TenantSettingsContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TenantSettingsContract. +func (tsc TenantSettingsContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsc.TenantSettingsContractProperties != nil { + objectMap["properties"] = tsc.TenantSettingsContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TenantSettingsContract struct. +func (tsc *TenantSettingsContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tenantSettingsContractProperties TenantSettingsContractProperties + err = json.Unmarshal(*v, &tenantSettingsContractProperties) + if err != nil { + return err + } + tsc.TenantSettingsContractProperties = &tenantSettingsContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tsc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tsc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tsc.Type = &typeVar + } + } + } + + return nil +} + +// TenantSettingsContractProperties tenant access information contract of the API Management service. +type TenantSettingsContractProperties struct { + // Settings - Tenant settings + Settings map[string]*string `json:"settings"` +} + +// MarshalJSON is the custom marshaler for TenantSettingsContractProperties. +func (tscp TenantSettingsContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tscp.Settings != nil { + objectMap["settings"] = tscp.Settings + } + return json.Marshal(objectMap) +} + +// TermsOfServiceProperties terms of service contract properties. +type TermsOfServiceProperties struct { + // Text - A terms of service text. + Text *string `json:"text,omitempty"` + // Enabled - Display terms of service during a sign-up process. + Enabled *bool `json:"enabled,omitempty"` + // ConsentRequired - Ask user for consent to the terms of service. + ConsentRequired *bool `json:"consentRequired,omitempty"` +} + +// TokenBodyParameterContract oAuth acquire token request body parameter (www-url-form-encoded). +type TokenBodyParameterContract struct { + // Name - body parameter name. + Name *string `json:"name,omitempty"` + // Value - body parameter value. + Value *string `json:"value,omitempty"` +} + +// UserCollection paged Users list representation. +type UserCollection struct { + autorest.Response `json:"-"` + // Value - Page values. + Value *[]UserContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// UserCollectionIterator provides access to a complete listing of UserContract values. +type UserCollectionIterator struct { + i int + page UserCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *UserCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *UserCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter UserCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter UserCollectionIterator) Response() UserCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter UserCollectionIterator) Value() UserContract { + if !iter.page.NotDone() { + return UserContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the UserCollectionIterator type. +func NewUserCollectionIterator(page UserCollectionPage) UserCollectionIterator { + return UserCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (uc UserCollection) IsEmpty() bool { + return uc.Value == nil || len(*uc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (uc UserCollection) hasNextLink() bool { + return uc.NextLink != nil && len(*uc.NextLink) != 0 +} + +// userCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (uc UserCollection) userCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !uc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(uc.NextLink))) +} + +// UserCollectionPage contains a page of UserContract values. +type UserCollectionPage struct { + fn func(context.Context, UserCollection) (UserCollection, error) + uc UserCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *UserCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.uc) + if err != nil { + return err + } + page.uc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *UserCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page UserCollectionPage) NotDone() bool { + return !page.uc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page UserCollectionPage) Response() UserCollection { + return page.uc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page UserCollectionPage) Values() []UserContract { + if page.uc.IsEmpty() { + return nil + } + return *page.uc.Value +} + +// Creates a new instance of the UserCollectionPage type. +func NewUserCollectionPage(cur UserCollection, getNextPage func(context.Context, UserCollection) (UserCollection, error)) UserCollectionPage { + return UserCollectionPage{ + fn: getNextPage, + uc: cur, + } +} + +// UserContract user details. +type UserContract struct { + autorest.Response `json:"-"` + // UserContractProperties - User entity contract properties. + *UserContractProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserContract. +func (uc UserContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if uc.UserContractProperties != nil { + objectMap["properties"] = uc.UserContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UserContract struct. +func (uc *UserContract) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var userContractProperties UserContractProperties + err = json.Unmarshal(*v, &userContractProperties) + if err != nil { + return err + } + uc.UserContractProperties = &userContractProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + uc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + uc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + uc.Type = &typeVar + } + } + } + + return nil +} + +// UserContractProperties user profile. +type UserContractProperties struct { + // FirstName - First name. + FirstName *string `json:"firstName,omitempty"` + // LastName - Last name. + LastName *string `json:"lastName,omitempty"` + // Email - Email address. + Email *string `json:"email,omitempty"` + // RegistrationDate - Date of user registration. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. + RegistrationDate *date.Time `json:"registrationDate,omitempty"` + // Groups - READ-ONLY; Collection of groups user is part of. + Groups *[]GroupContractProperties `json:"groups,omitempty"` + // State - Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state is Active. Possible values include: 'UserStateActive', 'UserStateBlocked', 'UserStatePending', 'UserStateDeleted' + State UserState `json:"state,omitempty"` + // Note - Optional note about a user set by the administrator. + Note *string `json:"note,omitempty"` + // Identities - Collection of user identities. + Identities *[]UserIdentityContract `json:"identities,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserContractProperties. +func (ucp UserContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ucp.FirstName != nil { + objectMap["firstName"] = ucp.FirstName + } + if ucp.LastName != nil { + objectMap["lastName"] = ucp.LastName + } + if ucp.Email != nil { + objectMap["email"] = ucp.Email + } + if ucp.RegistrationDate != nil { + objectMap["registrationDate"] = ucp.RegistrationDate + } + if ucp.State != "" { + objectMap["state"] = ucp.State + } + if ucp.Note != nil { + objectMap["note"] = ucp.Note + } + if ucp.Identities != nil { + objectMap["identities"] = ucp.Identities + } + return json.Marshal(objectMap) +} + +// UserCreateParameterProperties parameters supplied to the Create User operation. +type UserCreateParameterProperties struct { + // Email - Email address. Must not be empty and must be unique within the service instance. + Email *string `json:"email,omitempty"` + // FirstName - First name. + FirstName *string `json:"firstName,omitempty"` + // LastName - Last name. + LastName *string `json:"lastName,omitempty"` + // Password - User Password. If no value is provided, a default password is generated. + Password *string `json:"password,omitempty"` + // AppType - Determines the type of application which send the create user request. Default is legacy portal. Possible values include: 'AppTypePortal', 'AppTypeDeveloperPortal' + AppType AppType `json:"appType,omitempty"` + // Confirmation - Determines the type of confirmation e-mail that will be sent to the newly created user. Possible values include: 'ConfirmationSignup', 'ConfirmationInvite' + Confirmation Confirmation `json:"confirmation,omitempty"` + // State - Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state is Active. Possible values include: 'UserStateActive', 'UserStateBlocked', 'UserStatePending', 'UserStateDeleted' + State UserState `json:"state,omitempty"` + // Note - Optional note about a user set by the administrator. + Note *string `json:"note,omitempty"` + // Identities - Collection of user identities. + Identities *[]UserIdentityContract `json:"identities,omitempty"` +} + +// UserCreateParameters user create details. +type UserCreateParameters struct { + // UserCreateParameterProperties - User entity create contract properties. + *UserCreateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserCreateParameters. +func (ucp UserCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ucp.UserCreateParameterProperties != nil { + objectMap["properties"] = ucp.UserCreateParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UserCreateParameters struct. +func (ucp *UserCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var userCreateParameterProperties UserCreateParameterProperties + err = json.Unmarshal(*v, &userCreateParameterProperties) + if err != nil { + return err + } + ucp.UserCreateParameterProperties = &userCreateParameterProperties + } + } + } + + return nil +} + +// UserEntityBaseParameters user Entity Base Parameters set. +type UserEntityBaseParameters struct { + // State - Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state is Active. Possible values include: 'UserStateActive', 'UserStateBlocked', 'UserStatePending', 'UserStateDeleted' + State UserState `json:"state,omitempty"` + // Note - Optional note about a user set by the administrator. + Note *string `json:"note,omitempty"` + // Identities - Collection of user identities. + Identities *[]UserIdentityContract `json:"identities,omitempty"` +} + +// UserIdentityCollection list of Users Identity list representation. +type UserIdentityCollection struct { + autorest.Response `json:"-"` + // Value - User Identity values. + Value *[]UserIdentityContract `json:"value,omitempty"` + // Count - Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + // NextLink - Next page link if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// UserIdentityCollectionIterator provides access to a complete listing of UserIdentityContract values. +type UserIdentityCollectionIterator struct { + i int + page UserIdentityCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *UserIdentityCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserIdentityCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *UserIdentityCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter UserIdentityCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter UserIdentityCollectionIterator) Response() UserIdentityCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter UserIdentityCollectionIterator) Value() UserIdentityContract { + if !iter.page.NotDone() { + return UserIdentityContract{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the UserIdentityCollectionIterator type. +func NewUserIdentityCollectionIterator(page UserIdentityCollectionPage) UserIdentityCollectionIterator { + return UserIdentityCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (uic UserIdentityCollection) IsEmpty() bool { + return uic.Value == nil || len(*uic.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (uic UserIdentityCollection) hasNextLink() bool { + return uic.NextLink != nil && len(*uic.NextLink) != 0 +} + +// userIdentityCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (uic UserIdentityCollection) userIdentityCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !uic.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(uic.NextLink))) +} + +// UserIdentityCollectionPage contains a page of UserIdentityContract values. +type UserIdentityCollectionPage struct { + fn func(context.Context, UserIdentityCollection) (UserIdentityCollection, error) + uic UserIdentityCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *UserIdentityCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserIdentityCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.uic) + if err != nil { + return err + } + page.uic = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *UserIdentityCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page UserIdentityCollectionPage) NotDone() bool { + return !page.uic.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page UserIdentityCollectionPage) Response() UserIdentityCollection { + return page.uic +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page UserIdentityCollectionPage) Values() []UserIdentityContract { + if page.uic.IsEmpty() { + return nil + } + return *page.uic.Value +} + +// Creates a new instance of the UserIdentityCollectionPage type. +func NewUserIdentityCollectionPage(cur UserIdentityCollection, getNextPage func(context.Context, UserIdentityCollection) (UserIdentityCollection, error)) UserIdentityCollectionPage { + return UserIdentityCollectionPage{ + fn: getNextPage, + uic: cur, + } +} + +// UserIdentityContract user identity details. +type UserIdentityContract struct { + // Provider - Identity provider name. + Provider *string `json:"provider,omitempty"` + // ID - Identifier value within provider. + ID *string `json:"id,omitempty"` +} + +// UserIdentityProperties ... +type UserIdentityProperties struct { + // PrincipalID - The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty"` +} + +// UserTokenParameterProperties parameters supplied to the Get User Token operation. +type UserTokenParameterProperties struct { + // KeyType - The Key to be used to generate token for user. Possible values include: 'KeyTypePrimary', 'KeyTypeSecondary' + KeyType KeyType `json:"keyType,omitempty"` + // Expiry - 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 *date.Time `json:"expiry,omitempty"` +} + +// UserTokenParameters get User Token parameters. +type UserTokenParameters struct { + // UserTokenParameterProperties - User Token Parameter contract properties. + *UserTokenParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserTokenParameters. +func (utp UserTokenParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if utp.UserTokenParameterProperties != nil { + objectMap["properties"] = utp.UserTokenParameterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UserTokenParameters struct. +func (utp *UserTokenParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var userTokenParameterProperties UserTokenParameterProperties + err = json.Unmarshal(*v, &userTokenParameterProperties) + if err != nil { + return err + } + utp.UserTokenParameterProperties = &userTokenParameterProperties + } + } + } + + return nil +} + +// UserTokenResult get User Token response details. +type UserTokenResult struct { + autorest.Response `json:"-"` + // Value - Shared Access Authorization token for the User. + Value *string `json:"value,omitempty"` +} + +// UserUpdateParameters user update parameters. +type UserUpdateParameters struct { + // UserUpdateParametersProperties - User entity update contract properties. + *UserUpdateParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserUpdateParameters. +func (uup UserUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if uup.UserUpdateParametersProperties != nil { + objectMap["properties"] = uup.UserUpdateParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UserUpdateParameters struct. +func (uup *UserUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var userUpdateParametersProperties UserUpdateParametersProperties + err = json.Unmarshal(*v, &userUpdateParametersProperties) + if err != nil { + return err + } + uup.UserUpdateParametersProperties = &userUpdateParametersProperties + } + } + } + + return nil +} + +// UserUpdateParametersProperties parameters supplied to the Update User operation. +type UserUpdateParametersProperties struct { + // Email - Email address. Must not be empty and must be unique within the service instance. + Email *string `json:"email,omitempty"` + // Password - User Password. + Password *string `json:"password,omitempty"` + // FirstName - First name. + FirstName *string `json:"firstName,omitempty"` + // LastName - Last name. + LastName *string `json:"lastName,omitempty"` + // State - Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state is Active. Possible values include: 'UserStateActive', 'UserStateBlocked', 'UserStatePending', 'UserStateDeleted' + State UserState `json:"state,omitempty"` + // Note - Optional note about a user set by the administrator. + Note *string `json:"note,omitempty"` + // Identities - Collection of user identities. + Identities *[]UserIdentityContract `json:"identities,omitempty"` +} + +// VirtualNetworkConfiguration configuration of a virtual network to which API Management service is +// deployed. +type VirtualNetworkConfiguration struct { + // Vnetid - READ-ONLY; The virtual network ID. This is typically a GUID. Expect a null GUID by default. + Vnetid *string `json:"vnetid,omitempty"` + // Subnetname - READ-ONLY; The name of the subnet. + Subnetname *string `json:"subnetname,omitempty"` + // SubnetResourceID - The full resource ID of a subnet in a virtual network to deploy the API Management service in. + SubnetResourceID *string `json:"subnetResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkConfiguration. +func (vnc VirtualNetworkConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vnc.SubnetResourceID != nil { + objectMap["subnetResourceId"] = vnc.SubnetResourceID + } + return json.Marshal(objectMap) +} + +// X509CertificateName properties of server X509Names. +type X509CertificateName struct { + // Name - Common Name of the Certificate. + Name *string `json:"name,omitempty"` + // IssuerCertificateThumbprint - Thumbprint for the Issuer of the Certificate. + IssuerCertificateThumbprint *string `json:"issuerCertificateThumbprint,omitempty"` +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/namedvalue.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/namedvalue.go new file mode 100644 index 000000000000..4461e34ba0ae --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/namedvalue.go @@ -0,0 +1,838 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// NamedValueClient is the apiManagement Client +type NamedValueClient struct { + BaseClient +} + +// NewNamedValueClient creates an instance of the NamedValueClient client. +func NewNamedValueClient(subscriptionID string) NamedValueClient { + return NewNamedValueClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNamedValueClientWithBaseURI creates an instance of the NamedValueClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewNamedValueClientWithBaseURI(baseURI string, subscriptionID string) NamedValueClient { + return NamedValueClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates named value. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// namedValueID - identifier of the NamedValue. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client NamedValueClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters NamedValueCreateContract, ifMatch string) (result NamedValueCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: namedValueID, + Constraints: []validation.Constraint{{Target: "namedValueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "namedValueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.NamedValueCreateContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.NamedValueCreateContractProperties.DisplayName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.NamedValueCreateContractProperties.DisplayName", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "parameters.NamedValueCreateContractProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "parameters.NamedValueCreateContractProperties.DisplayName", Name: validation.Pattern, Rule: `^[A-Za-z0-9-._]+$`, Chain: nil}, + }}, + {Target: "parameters.NamedValueCreateContractProperties.Value", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.NamedValueCreateContractProperties.Value", Name: validation.MaxLength, Rule: 4096, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.NamedValueClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, namedValueID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client NamedValueClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters NamedValueCreateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namedValueId": autorest.Encode("path", namedValueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client NamedValueClient) CreateOrUpdateSender(req *http.Request) (future NamedValueCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client NamedValueClient) CreateOrUpdateResponder(resp *http.Response) (result NamedValueContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific named value from the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client NamedValueClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: namedValueID, + Constraints: []validation.Constraint{{Target: "namedValueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "namedValueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NamedValueClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, namedValueID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client NamedValueClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namedValueId": autorest.Encode("path", namedValueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client NamedValueClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client NamedValueClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the named value specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// namedValueID - identifier of the NamedValue. +func (client NamedValueClient) Get(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (result NamedValueContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: namedValueID, + Constraints: []validation.Constraint{{Target: "namedValueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "namedValueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NamedValueClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, namedValueID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client NamedValueClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namedValueId": autorest.Encode("path", namedValueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NamedValueClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NamedValueClient) GetResponder(resp *http.Response) (result NamedValueContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the named value specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// namedValueID - identifier of the NamedValue. +func (client NamedValueClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: namedValueID, + Constraints: []validation.Constraint{{Target: "namedValueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "namedValueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NamedValueClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, namedValueID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client NamedValueClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namedValueId": autorest.Encode("path", namedValueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client NamedValueClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client NamedValueClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of named values defined within a service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +// isKeyVaultRefreshFailed - when set to true, the response contains only named value entities which failed +// refresh. +func (client NamedValueClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (result NamedValueCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueClient.ListByService") + defer func() { + sc := -1 + if result.nvc.Response.Response != nil { + sc = result.nvc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.NamedValueClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip, isKeyVaultRefreshFailed) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.nvc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "ListByService", resp, "Failure sending request") + return + } + + result.nvc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "ListByService", resp, "Failure responding to request") + return + } + if result.nvc.hasNextLink() && result.nvc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client NamedValueClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if isKeyVaultRefreshFailed != nil { + queryParameters["isKeyVaultRefreshFailed"] = autorest.Encode("query", *isKeyVaultRefreshFailed) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client NamedValueClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client NamedValueClient) ListByServiceResponder(resp *http.Response) (result NamedValueCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client NamedValueClient) listByServiceNextResults(ctx context.Context, lastResults NamedValueCollection) (result NamedValueCollection, err error) { + req, err := lastResults.namedValueCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client NamedValueClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, isKeyVaultRefreshFailed *bool) (result NamedValueCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip, isKeyVaultRefreshFailed) + return +} + +// ListValue gets the secret of the named value specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// namedValueID - identifier of the NamedValue. +func (client NamedValueClient) ListValue(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (result NamedValueSecretContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueClient.ListValue") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: namedValueID, + Constraints: []validation.Constraint{{Target: "namedValueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "namedValueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NamedValueClient", "ListValue", err.Error()) + } + + req, err := client.ListValuePreparer(ctx, resourceGroupName, serviceName, namedValueID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "ListValue", nil, "Failure preparing request") + return + } + + resp, err := client.ListValueSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "ListValue", resp, "Failure sending request") + return + } + + result, err = client.ListValueResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "ListValue", resp, "Failure responding to request") + return + } + + return +} + +// ListValuePreparer prepares the ListValue request. +func (client NamedValueClient) ListValuePreparer(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namedValueId": autorest.Encode("path", namedValueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListValueSender sends the ListValue request. The method will close the +// http.Response Body if it receives an error. +func (client NamedValueClient) ListValueSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListValueResponder handles the response to the ListValue request. The method always +// closes the http.Response Body. +func (client NamedValueClient) ListValueResponder(resp *http.Response) (result NamedValueSecretContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RefreshSecret refresh the secret of the named value specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// namedValueID - identifier of the NamedValue. +func (client NamedValueClient) RefreshSecret(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (result NamedValueRefreshSecretFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueClient.RefreshSecret") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: namedValueID, + Constraints: []validation.Constraint{{Target: "namedValueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "namedValueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NamedValueClient", "RefreshSecret", err.Error()) + } + + req, err := client.RefreshSecretPreparer(ctx, resourceGroupName, serviceName, namedValueID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "RefreshSecret", nil, "Failure preparing request") + return + } + + result, err = client.RefreshSecretSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "RefreshSecret", nil, "Failure sending request") + return + } + + return +} + +// RefreshSecretPreparer prepares the RefreshSecret request. +func (client NamedValueClient) RefreshSecretPreparer(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namedValueId": autorest.Encode("path", namedValueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RefreshSecretSender sends the RefreshSecret request. The method will close the +// http.Response Body if it receives an error. +func (client NamedValueClient) RefreshSecretSender(req *http.Request) (future NamedValueRefreshSecretFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RefreshSecretResponder handles the response to the RefreshSecret request. The method always +// closes the http.Response Body. +func (client NamedValueClient) RefreshSecretResponder(resp *http.Response) (result NamedValueContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the specific named value. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// namedValueID - identifier of the NamedValue. +// parameters - update parameters. +// 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. +func (client NamedValueClient) Update(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters NamedValueUpdateParameters, ifMatch string) (result NamedValueUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamedValueClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: namedValueID, + Constraints: []validation.Constraint{{Target: "namedValueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "namedValueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NamedValueClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, namedValueID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NamedValueClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client NamedValueClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters NamedValueUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namedValueId": autorest.Encode("path", namedValueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client NamedValueClient) UpdateSender(req *http.Request) (future NamedValueUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client NamedValueClient) UpdateResponder(resp *http.Response) (result NamedValueContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/networkstatus.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/networkstatus.go new file mode 100644 index 000000000000..b55b4f907b33 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/networkstatus.go @@ -0,0 +1,207 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// NetworkStatusClient is the apiManagement Client +type NetworkStatusClient struct { + BaseClient +} + +// NewNetworkStatusClient creates an instance of the NetworkStatusClient client. +func NewNetworkStatusClient(subscriptionID string) NetworkStatusClient { + return NewNetworkStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNetworkStatusClientWithBaseURI creates an instance of the NetworkStatusClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewNetworkStatusClientWithBaseURI(baseURI string, subscriptionID string) NetworkStatusClient { + return NetworkStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets the Connectivity Status to the external resources on which the Api Management service depends +// from inside the Cloud Service. This also returns the DNS Servers as visible to the CloudService. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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, East US, South Central US. +func (client NetworkStatusClient) ListByLocation(ctx context.Context, resourceGroupName string, serviceName string, locationName string) (result NetworkStatusContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkStatusClient.ListByLocation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: locationName, + Constraints: []validation.Constraint{{Target: "locationName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NetworkStatusClient", "ListByLocation", err.Error()) + } + + req, err := client.ListByLocationPreparer(ctx, resourceGroupName, serviceName, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NetworkStatusClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NetworkStatusClient", "ListByLocation", resp, "Failure sending request") + return + } + + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NetworkStatusClient", "ListByLocation", resp, "Failure responding to request") + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client NetworkStatusClient) ListByLocationPreparer(ctx context.Context, resourceGroupName string, serviceName string, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client NetworkStatusClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client NetworkStatusClient) ListByLocationResponder(resp *http.Response) (result NetworkStatusContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets the Connectivity Status to the external resources on which the Api Management service depends +// from inside the Cloud Service. This also returns the DNS Servers as visible to the CloudService. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client NetworkStatusClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result ListNetworkStatusContractByLocation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkStatusClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NetworkStatusClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NetworkStatusClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NetworkStatusClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NetworkStatusClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client NetworkStatusClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client NetworkStatusClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client NetworkStatusClient) ListByServiceResponder(resp *http.Response) (result ListNetworkStatusContractByLocation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/notification.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/notification.go new file mode 100644 index 000000000000..35d5699deb70 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/notification.go @@ -0,0 +1,349 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// NotificationClient is the apiManagement Client +type NotificationClient struct { + BaseClient +} + +// NewNotificationClient creates an instance of the NotificationClient client. +func NewNotificationClient(subscriptionID string) NotificationClient { + return NewNotificationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNotificationClientWithBaseURI creates an instance of the NotificationClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewNotificationClientWithBaseURI(baseURI string, subscriptionID string) NotificationClient { + return NotificationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or Update API Management publisher notification. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client NotificationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, ifMatch string) (result NotificationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, notificationName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client NotificationClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client NotificationClient) CreateOrUpdateResponder(resp *http.Response) (result NotificationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the details of the Notification specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +func (client NotificationClient) Get(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName) (result NotificationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, notificationName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client NotificationClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NotificationClient) GetResponder(resp *http.Response) (result NotificationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists a collection of properties defined within a service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// top - number of records to return. +// skip - number of records to skip. +func (client NotificationClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (result NotificationCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationClient.ListByService") + defer func() { + sc := -1 + if result.nc.Response.Response != nil { + sc = result.nc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.nc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "ListByService", resp, "Failure sending request") + return + } + + result.nc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "ListByService", resp, "Failure responding to request") + return + } + if result.nc.hasNextLink() && result.nc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client NotificationClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client NotificationClient) ListByServiceResponder(resp *http.Response) (result NotificationCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client NotificationClient) listByServiceNextResults(ctx context.Context, lastResults NotificationCollection) (result NotificationCollection, err error) { + req, err := lastResults.notificationCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client NotificationClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, top *int32, skip *int32) (result NotificationCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/notificationrecipientemail.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/notificationrecipientemail.go new file mode 100644 index 000000000000..9b57351bc41f --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/notificationrecipientemail.go @@ -0,0 +1,381 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// NotificationRecipientEmailClient is the apiManagement Client +type NotificationRecipientEmailClient struct { + BaseClient +} + +// NewNotificationRecipientEmailClient creates an instance of the NotificationRecipientEmailClient client. +func NewNotificationRecipientEmailClient(subscriptionID string) NotificationRecipientEmailClient { + return NewNotificationRecipientEmailClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNotificationRecipientEmailClientWithBaseURI creates an instance of the NotificationRecipientEmailClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewNotificationRecipientEmailClientWithBaseURI(baseURI string, subscriptionID string) NotificationRecipientEmailClient { + return NotificationRecipientEmailClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckEntityExists determine if Notification Recipient Email subscribed to the notification. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +// email - email identifier. +func (client NotificationRecipientEmailClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationRecipientEmailClient.CheckEntityExists") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationRecipientEmailClient", "CheckEntityExists", err.Error()) + } + + req, err := client.CheckEntityExistsPreparer(ctx, resourceGroupName, serviceName, notificationName, email) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "CheckEntityExists", nil, "Failure preparing request") + return + } + + resp, err := client.CheckEntityExistsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "CheckEntityExists", resp, "Failure sending request") + return + } + + result, err = client.CheckEntityExistsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "CheckEntityExists", resp, "Failure responding to request") + return + } + + return +} + +// CheckEntityExistsPreparer prepares the CheckEntityExists request. +func (client NotificationRecipientEmailClient) CheckEntityExistsPreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "email": autorest.Encode("path", email), + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckEntityExistsSender sends the CheckEntityExists request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationRecipientEmailClient) CheckEntityExistsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckEntityExistsResponder handles the response to the CheckEntityExists request. The method always +// closes the http.Response Body. +func (client NotificationRecipientEmailClient) CheckEntityExistsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate adds the Email address to the list of Recipients for the Notification. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +// email - email identifier. +func (client NotificationRecipientEmailClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string) (result RecipientEmailContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationRecipientEmailClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationRecipientEmailClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, notificationName, email) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client NotificationRecipientEmailClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "email": autorest.Encode("path", email), + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationRecipientEmailClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client NotificationRecipientEmailClient) CreateOrUpdateResponder(resp *http.Response) (result RecipientEmailContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the email from the list of Notification. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +// email - email identifier. +func (client NotificationRecipientEmailClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationRecipientEmailClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationRecipientEmailClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, notificationName, email) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client NotificationRecipientEmailClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "email": autorest.Encode("path", email), + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationRecipientEmailClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client NotificationRecipientEmailClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByNotification gets the list of the Notification Recipient Emails subscribed to a notification. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +func (client NotificationRecipientEmailClient) ListByNotification(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName) (result RecipientEmailCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationRecipientEmailClient.ListByNotification") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationRecipientEmailClient", "ListByNotification", err.Error()) + } + + req, err := client.ListByNotificationPreparer(ctx, resourceGroupName, serviceName, notificationName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "ListByNotification", nil, "Failure preparing request") + return + } + + resp, err := client.ListByNotificationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "ListByNotification", resp, "Failure sending request") + return + } + + result, err = client.ListByNotificationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientEmailClient", "ListByNotification", resp, "Failure responding to request") + return + } + + return +} + +// ListByNotificationPreparer prepares the ListByNotification request. +func (client NotificationRecipientEmailClient) ListByNotificationPreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByNotificationSender sends the ListByNotification request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationRecipientEmailClient) ListByNotificationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByNotificationResponder handles the response to the ListByNotification request. The method always +// closes the http.Response Body. +func (client NotificationRecipientEmailClient) ListByNotificationResponder(resp *http.Response) (result RecipientEmailCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/notificationrecipientuser.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/notificationrecipientuser.go new file mode 100644 index 000000000000..c0a18bc76ae8 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/notificationrecipientuser.go @@ -0,0 +1,390 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// NotificationRecipientUserClient is the apiManagement Client +type NotificationRecipientUserClient struct { + BaseClient +} + +// NewNotificationRecipientUserClient creates an instance of the NotificationRecipientUserClient client. +func NewNotificationRecipientUserClient(subscriptionID string) NotificationRecipientUserClient { + return NewNotificationRecipientUserClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNotificationRecipientUserClientWithBaseURI creates an instance of the NotificationRecipientUserClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewNotificationRecipientUserClientWithBaseURI(baseURI string, subscriptionID string) NotificationRecipientUserClient { + return NotificationRecipientUserClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckEntityExists determine if the Notification Recipient User is subscribed to the notification. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +// userID - user identifier. Must be unique in the current API Management service instance. +func (client NotificationRecipientUserClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationRecipientUserClient.CheckEntityExists") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationRecipientUserClient", "CheckEntityExists", err.Error()) + } + + req, err := client.CheckEntityExistsPreparer(ctx, resourceGroupName, serviceName, notificationName, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "CheckEntityExists", nil, "Failure preparing request") + return + } + + resp, err := client.CheckEntityExistsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "CheckEntityExists", resp, "Failure sending request") + return + } + + result, err = client.CheckEntityExistsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "CheckEntityExists", resp, "Failure responding to request") + return + } + + return +} + +// CheckEntityExistsPreparer prepares the CheckEntityExists request. +func (client NotificationRecipientUserClient) CheckEntityExistsPreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckEntityExistsSender sends the CheckEntityExists request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationRecipientUserClient) CheckEntityExistsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckEntityExistsResponder handles the response to the CheckEntityExists request. The method always +// closes the http.Response Body. +func (client NotificationRecipientUserClient) CheckEntityExistsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate adds the API Management User to the list of Recipients for the Notification. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +// userID - user identifier. Must be unique in the current API Management service instance. +func (client NotificationRecipientUserClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string) (result RecipientUserContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationRecipientUserClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationRecipientUserClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, notificationName, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client NotificationRecipientUserClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationRecipientUserClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client NotificationRecipientUserClient) CreateOrUpdateResponder(resp *http.Response) (result RecipientUserContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the API Management user from the list of Notification. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +// userID - user identifier. Must be unique in the current API Management service instance. +func (client NotificationRecipientUserClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationRecipientUserClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationRecipientUserClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, notificationName, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client NotificationRecipientUserClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationRecipientUserClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client NotificationRecipientUserClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByNotification gets the list of the Notification Recipient User subscribed to the notification. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// notificationName - notification Name Identifier. +func (client NotificationRecipientUserClient) ListByNotification(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName) (result RecipientUserCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotificationRecipientUserClient.ListByNotification") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.NotificationRecipientUserClient", "ListByNotification", err.Error()) + } + + req, err := client.ListByNotificationPreparer(ctx, resourceGroupName, serviceName, notificationName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "ListByNotification", nil, "Failure preparing request") + return + } + + resp, err := client.ListByNotificationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "ListByNotification", resp, "Failure sending request") + return + } + + result, err = client.ListByNotificationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.NotificationRecipientUserClient", "ListByNotification", resp, "Failure responding to request") + return + } + + return +} + +// ListByNotificationPreparer prepares the ListByNotification request. +func (client NotificationRecipientUserClient) ListByNotificationPreparer(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "notificationName": autorest.Encode("path", notificationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByNotificationSender sends the ListByNotification request. The method will close the +// http.Response Body if it receives an error. +func (client NotificationRecipientUserClient) ListByNotificationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByNotificationResponder handles the response to the ListByNotification request. The method always +// closes the http.Response Body. +func (client NotificationRecipientUserClient) ListByNotificationResponder(resp *http.Response) (result RecipientUserCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/openidconnectprovider.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/openidconnectprovider.go new file mode 100644 index 000000000000..cacf336e75c2 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/openidconnectprovider.go @@ -0,0 +1,736 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OpenIDConnectProviderClient is the apiManagement Client +type OpenIDConnectProviderClient struct { + BaseClient +} + +// NewOpenIDConnectProviderClient creates an instance of the OpenIDConnectProviderClient client. +func NewOpenIDConnectProviderClient(subscriptionID string) OpenIDConnectProviderClient { + return NewOpenIDConnectProviderClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOpenIDConnectProviderClientWithBaseURI creates an instance of the OpenIDConnectProviderClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewOpenIDConnectProviderClientWithBaseURI(baseURI string, subscriptionID string) OpenIDConnectProviderClient { + return OpenIDConnectProviderClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the OpenID Connect Provider. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// opid - identifier of the OpenID Connect Provider. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client OpenIDConnectProviderClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderContract, ifMatch string) (result OpenidConnectProviderContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: opid, + Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.OpenidConnectProviderContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.OpenidConnectProviderContractProperties.DisplayName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.OpenidConnectProviderContractProperties.DisplayName", Name: validation.MaxLength, Rule: 50, Chain: nil}}}, + {Target: "parameters.OpenidConnectProviderContractProperties.MetadataEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.OpenidConnectProviderContractProperties.ClientID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, opid, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client OpenIDConnectProviderClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "opid": autorest.Encode("path", opid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client OpenIDConnectProviderClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client OpenIDConnectProviderClient) CreateOrUpdateResponder(resp *http.Response) (result OpenidConnectProviderContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific OpenID Connect Provider of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// opid - identifier of the OpenID Connect Provider. +// 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. +func (client OpenIDConnectProviderClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: opid, + Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, opid, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client OpenIDConnectProviderClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "opid": autorest.Encode("path", opid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client OpenIDConnectProviderClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client OpenIDConnectProviderClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets specific OpenID Connect Provider without secrets. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// opid - identifier of the OpenID Connect Provider. +func (client OpenIDConnectProviderClient) Get(ctx context.Context, resourceGroupName string, serviceName string, opid string) (result OpenidConnectProviderContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: opid, + Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, opid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client OpenIDConnectProviderClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "opid": autorest.Encode("path", opid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OpenIDConnectProviderClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OpenIDConnectProviderClient) GetResponder(resp *http.Response) (result OpenidConnectProviderContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the openIdConnectProvider specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// opid - identifier of the OpenID Connect Provider. +func (client OpenIDConnectProviderClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, opid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: opid, + Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, opid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client OpenIDConnectProviderClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "opid": autorest.Encode("path", opid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client OpenIDConnectProviderClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client OpenIDConnectProviderClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists of all the OpenId Connect Providers. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +func (client OpenIDConnectProviderClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result OpenIDConnectProviderCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.ListByService") + defer func() { + sc := -1 + if result.oicpc.Response.Response != nil { + sc = result.oicpc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.oicpc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListByService", resp, "Failure sending request") + return + } + + result.oicpc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListByService", resp, "Failure responding to request") + return + } + if result.oicpc.hasNextLink() && result.oicpc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client OpenIDConnectProviderClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client OpenIDConnectProviderClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client OpenIDConnectProviderClient) ListByServiceResponder(resp *http.Response) (result OpenIDConnectProviderCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client OpenIDConnectProviderClient) listByServiceNextResults(ctx context.Context, lastResults OpenIDConnectProviderCollection) (result OpenIDConnectProviderCollection, err error) { + req, err := lastResults.openIDConnectProviderCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client OpenIDConnectProviderClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result OpenIDConnectProviderCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// ListSecrets gets the client secret details of the OpenID Connect Provider. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// opid - identifier of the OpenID Connect Provider. +func (client OpenIDConnectProviderClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, opid string) (result ClientSecretContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.ListSecrets") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: opid, + Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "ListSecrets", err.Error()) + } + + req, err := client.ListSecretsPreparer(ctx, resourceGroupName, serviceName, opid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListSecrets", nil, "Failure preparing request") + return + } + + resp, err := client.ListSecretsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListSecrets", resp, "Failure sending request") + return + } + + result, err = client.ListSecretsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "ListSecrets", resp, "Failure responding to request") + return + } + + return +} + +// ListSecretsPreparer prepares the ListSecrets request. +func (client OpenIDConnectProviderClient) ListSecretsPreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "opid": autorest.Encode("path", opid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSecretsSender sends the ListSecrets request. The method will close the +// http.Response Body if it receives an error. +func (client OpenIDConnectProviderClient) ListSecretsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSecretsResponder handles the response to the ListSecrets request. The method always +// closes the http.Response Body. +func (client OpenIDConnectProviderClient) ListSecretsResponder(resp *http.Response) (result ClientSecretContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the specific OpenID Connect Provider. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// opid - identifier of the OpenID Connect Provider. +// parameters - update parameters. +// 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. +func (client OpenIDConnectProviderClient) Update(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderUpdateContract, ifMatch string) (result OpenidConnectProviderContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenIDConnectProviderClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: opid, + Constraints: []validation.Constraint{{Target: "opid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "opid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.OpenIDConnectProviderClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, opid, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OpenIDConnectProviderClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client OpenIDConnectProviderClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderUpdateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "opid": autorest.Encode("path", opid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client OpenIDConnectProviderClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client OpenIDConnectProviderClient) UpdateResponder(resp *http.Response) (result OpenidConnectProviderContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/operation.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/operation.go new file mode 100644 index 000000000000..ea0aed033be7 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/operation.go @@ -0,0 +1,194 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationClient is the apiManagement Client +type OperationClient struct { + BaseClient +} + +// NewOperationClient creates an instance of the OperationClient client. +func NewOperationClient(subscriptionID string) OperationClient { + return NewOperationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationClientWithBaseURI creates an instance of the OperationClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationClientWithBaseURI(baseURI string, subscriptionID string) OperationClient { + return OperationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByTags lists a collection of operations associated with tags. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// filter - | 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 |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, +// contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, +// contains, startswith, endswith |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +// includeNotTaggedOperations - include not tagged Operations. +func (client OperationClient) ListByTags(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, includeNotTaggedOperations *bool) (result TagResourceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationClient.ListByTags") + defer func() { + sc := -1 + if result.trc.Response.Response != nil { + sc = result.trc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.OperationClient", "ListByTags", err.Error()) + } + + result.fn = client.listByTagsNextResults + req, err := client.ListByTagsPreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip, includeNotTaggedOperations) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OperationClient", "ListByTags", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTagsSender(req) + if err != nil { + result.trc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.OperationClient", "ListByTags", resp, "Failure sending request") + return + } + + result.trc, err = client.ListByTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OperationClient", "ListByTags", resp, "Failure responding to request") + return + } + if result.trc.hasNextLink() && result.trc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByTagsPreparer prepares the ListByTags request. +func (client OperationClient) ListByTagsPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, includeNotTaggedOperations *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if includeNotTaggedOperations != nil { + queryParameters["includeNotTaggedOperations"] = autorest.Encode("query", *includeNotTaggedOperations) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTagsSender sends the ListByTags request. The method will close the +// http.Response Body if it receives an error. +func (client OperationClient) ListByTagsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTagsResponder handles the response to the ListByTags request. The method always +// closes the http.Response Body. +func (client OperationClient) ListByTagsResponder(resp *http.Response) (result TagResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByTagsNextResults retrieves the next set of results, if any. +func (client OperationClient) listByTagsNextResults(ctx context.Context, lastResults TagResourceCollection) (result TagResourceCollection, err error) { + req, err := lastResults.tagResourceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.OperationClient", "listByTagsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByTagsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.OperationClient", "listByTagsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OperationClient", "listByTagsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByTagsComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationClient) ListByTagsComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32, includeNotTaggedOperations *bool) (result TagResourceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationClient.ListByTags") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByTags(ctx, resourceGroupName, serviceName, apiid, filter, top, skip, includeNotTaggedOperations) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/operations.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/operations.go new file mode 100644 index 000000000000..f9fb0f5a6813 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/operations.go @@ -0,0 +1,140 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the apiManagement Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations of the Microsoft.ApiManagement provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ApiManagement/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/policy.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/policy.go new file mode 100644 index 000000000000..2332ca886d7a --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/policy.go @@ -0,0 +1,474 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PolicyClient is the apiManagement Client +type PolicyClient struct { + BaseClient +} + +// NewPolicyClient creates an instance of the PolicyClient client. +func NewPolicyClient(subscriptionID string) PolicyClient { + return NewPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPolicyClientWithBaseURI creates an instance of the PolicyClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPolicyClientWithBaseURI(baseURI string, subscriptionID string) PolicyClient { + return PolicyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the global policy configuration of the Api Management service. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - the policy contents to apply. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client PolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters PolicyContract, ifMatch string) (result PolicyContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PolicyContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PolicyContractProperties.Value", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.PolicyClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PolicyClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters PolicyContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PolicyClient) CreateOrUpdateResponder(resp *http.Response) (result PolicyContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the global policy configuration of the Api Management Service. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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 it should be * for unconditional update. +func (client PolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.PolicyClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PolicyClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the Global policy definition of the Api Management service. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// formatParameter - policy Export Format. +func (client PolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, formatParameter PolicyExportFormat) (result PolicyContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.PolicyClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, formatParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PolicyClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, formatParameter PolicyExportFormat) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(formatParameter)) > 0 { + queryParameters["format"] = autorest.Encode("query", formatParameter) + } else { + queryParameters["format"] = autorest.Encode("query", "xml") + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PolicyClient) GetResponder(resp *http.Response) (result PolicyContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the Global policy definition in the Api Management service. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client PolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.PolicyClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client PolicyClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyId": autorest.Encode("path", "policy"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client PolicyClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists all the Global Policy definitions of the Api Management service. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client PolicyClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result PolicyCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.PolicyClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PolicyClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PolicyClient) ListByServiceResponder(resp *http.Response) (result PolicyCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/policydescription.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/policydescription.go new file mode 100644 index 000000000000..bce1569af17f --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/policydescription.go @@ -0,0 +1,121 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PolicyDescriptionClient is the apiManagement Client +type PolicyDescriptionClient struct { + BaseClient +} + +// NewPolicyDescriptionClient creates an instance of the PolicyDescriptionClient client. +func NewPolicyDescriptionClient(subscriptionID string) PolicyDescriptionClient { + return NewPolicyDescriptionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPolicyDescriptionClientWithBaseURI creates an instance of the PolicyDescriptionClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPolicyDescriptionClientWithBaseURI(baseURI string, subscriptionID string) PolicyDescriptionClient { + return PolicyDescriptionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByService lists all policy descriptions. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// scope - policy scope. +func (client PolicyDescriptionClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, scope PolicyScopeContract) (result PolicyDescriptionCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PolicyDescriptionClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.PolicyDescriptionClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyDescriptionClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.PolicyDescriptionClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PolicyDescriptionClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PolicyDescriptionClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, scope PolicyScopeContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(scope)) > 0 { + queryParameters["scope"] = autorest.Encode("query", scope) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PolicyDescriptionClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PolicyDescriptionClient) ListByServiceResponder(resp *http.Response) (result PolicyDescriptionCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/portalrevision.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/portalrevision.go new file mode 100644 index 000000000000..5993b444c6d7 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/portalrevision.go @@ -0,0 +1,559 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PortalRevisionClient is the apiManagement Client +type PortalRevisionClient struct { + BaseClient +} + +// NewPortalRevisionClient creates an instance of the PortalRevisionClient client. +func NewPortalRevisionClient(subscriptionID string) PortalRevisionClient { + return NewPortalRevisionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPortalRevisionClientWithBaseURI creates an instance of the PortalRevisionClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPortalRevisionClientWithBaseURI(baseURI string, subscriptionID string) PortalRevisionClient { + return PortalRevisionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new developer portal's revision by running the portal's publishing. The `isCurrent` +// property indicates if the revision is publicly accessible. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// portalRevisionID - portal revision identifier. Must be unique in the current API Management service +// instance. +func (client PortalRevisionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract) (result PortalRevisionCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: portalRevisionID, + Constraints: []validation.Constraint{{Target: "portalRevisionID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "portalRevisionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PortalRevisionContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PortalRevisionContractProperties.Description", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PortalRevisionContractProperties.Description", Name: validation.MaxLength, Rule: 2000, Chain: nil}}}, + {Target: "parameters.PortalRevisionContractProperties.StatusDetails", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PortalRevisionContractProperties.StatusDetails", Name: validation.MaxLength, Rule: 2000, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.PortalRevisionClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, portalRevisionID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PortalRevisionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "portalRevisionId": autorest.Encode("path", portalRevisionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PortalRevisionClient) CreateOrUpdateSender(req *http.Request) (future PortalRevisionCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PortalRevisionClient) CreateOrUpdateResponder(resp *http.Response) (result PortalRevisionContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the developer portal's revision specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// portalRevisionID - portal revision identifier. Must be unique in the current API Management service +// instance. +func (client PortalRevisionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (result PortalRevisionContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: portalRevisionID, + Constraints: []validation.Constraint{{Target: "portalRevisionID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "portalRevisionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.PortalRevisionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, portalRevisionID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PortalRevisionClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "portalRevisionId": autorest.Encode("path", portalRevisionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PortalRevisionClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PortalRevisionClient) GetResponder(resp *http.Response) (result PortalRevisionContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the developer portal revision specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// portalRevisionID - portal revision identifier. Must be unique in the current API Management service +// instance. +func (client PortalRevisionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: portalRevisionID, + Constraints: []validation.Constraint{{Target: "portalRevisionID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "portalRevisionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.PortalRevisionClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, portalRevisionID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client PortalRevisionClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "portalRevisionId": autorest.Encode("path", portalRevisionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client PortalRevisionClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client PortalRevisionClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists developer portal's revisions. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Supported operators | Supported functions | +// |-------------|------------------------|-----------------------------------| +// +// |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| +// |description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| +// |isCurrent | eq, ne | | +// top - number of records to return. +// skip - number of records to skip. +func (client PortalRevisionClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result PortalRevisionCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.ListByService") + defer func() { + sc := -1 + if result.prc.Response.Response != nil { + sc = result.prc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.PortalRevisionClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.prc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "ListByService", resp, "Failure sending request") + return + } + + result.prc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "ListByService", resp, "Failure responding to request") + return + } + if result.prc.hasNextLink() && result.prc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PortalRevisionClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PortalRevisionClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PortalRevisionClient) ListByServiceResponder(resp *http.Response) (result PortalRevisionCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client PortalRevisionClient) listByServiceNextResults(ctx context.Context, lastResults PortalRevisionCollection) (result PortalRevisionCollection, err error) { + req, err := lastResults.portalRevisionCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client PortalRevisionClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result PortalRevisionCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// Update updates the description of specified portal revision or makes it current. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// portalRevisionID - portal revision 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. +func (client PortalRevisionClient) Update(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, ifMatch string) (result PortalRevisionUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalRevisionClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: portalRevisionID, + Constraints: []validation.Constraint{{Target: "portalRevisionID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "portalRevisionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.PortalRevisionClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, portalRevisionID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalRevisionClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PortalRevisionClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "portalRevisionId": autorest.Encode("path", portalRevisionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PortalRevisionClient) UpdateSender(req *http.Request) (future PortalRevisionUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PortalRevisionClient) UpdateResponder(resp *http.Response) (result PortalRevisionContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/portalsettings.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/portalsettings.go new file mode 100644 index 000000000000..755d6904a311 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/portalsettings.go @@ -0,0 +1,116 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PortalSettingsClient is the apiManagement Client +type PortalSettingsClient struct { + BaseClient +} + +// NewPortalSettingsClient creates an instance of the PortalSettingsClient client. +func NewPortalSettingsClient(subscriptionID string) PortalSettingsClient { + return NewPortalSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPortalSettingsClientWithBaseURI creates an instance of the PortalSettingsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPortalSettingsClientWithBaseURI(baseURI string, subscriptionID string) PortalSettingsClient { + return PortalSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByService lists a collection of portalsettings defined within a service instance.. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client PortalSettingsClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result PortalSettingsCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PortalSettingsClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.PortalSettingsClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalSettingsClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.PortalSettingsClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.PortalSettingsClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PortalSettingsClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PortalSettingsClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PortalSettingsClient) ListByServiceResponder(resp *http.Response) (result PortalSettingsCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/product.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/product.go new file mode 100644 index 000000000000..af651c2dd79c --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/product.go @@ -0,0 +1,815 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProductClient is the apiManagement Client +type ProductClient struct { + BaseClient +} + +// NewProductClient creates an instance of the ProductClient client. +func NewProductClient(subscriptionID string) ProductClient { + return NewProductClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductClientWithBaseURI creates an instance of the ProductClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewProductClientWithBaseURI(baseURI string, subscriptionID string) ProductClient { + return ProductClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or Updates a product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// parameters - create or update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client ProductClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters ProductContract, ifMatch string) (result ProductContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ProductContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ProductContractProperties.DisplayName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ProductContractProperties.DisplayName", Name: validation.MaxLength, Rule: 300, Chain: nil}, + {Target: "parameters.ProductContractProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, productID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ProductClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters ProductContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ProductClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ProductClient) CreateOrUpdateResponder(resp *http.Response) (result ProductContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +// deleteSubscriptions - delete existing subscriptions associated with the product or not. +func (client ProductClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, deleteSubscriptions *bool) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, productID, ifMatch, deleteSubscriptions) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ProductClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, deleteSubscriptions *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if deleteSubscriptions != nil { + queryParameters["deleteSubscriptions"] = autorest.Encode("query", *deleteSubscriptions) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ProductClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ProductClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the product specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +func (client ProductClient) Get(ctx context.Context, resourceGroupName string, serviceName string, productID string) (result ProductContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, productID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProductClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ProductClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ProductClient) GetResponder(resp *http.Response) (result ProductContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the product specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +func (client ProductClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, productID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, productID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client ProductClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client ProductClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client ProductClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService lists a collection of products in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 | | |
+// top - number of records to return. +// skip - number of records to skip. +// expandGroups - when set to true, the response contains an array of groups that have visibility to the +// product. The default is false. +// tags - products which are part of a specific tag. +func (client ProductClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool, tags string) (result ProductCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductClient.ListByService") + defer func() { + sc := -1 + if result.pc.Response.Response != nil { + sc = result.pc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip, expandGroups, tags) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.pc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "ListByService", resp, "Failure sending request") + return + } + + result.pc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "ListByService", resp, "Failure responding to request") + return + } + if result.pc.hasNextLink() && result.pc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client ProductClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool, tags string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if expandGroups != nil { + queryParameters["expandGroups"] = autorest.Encode("query", *expandGroups) + } + if len(tags) > 0 { + queryParameters["tags"] = autorest.Encode("query", tags) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client ProductClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client ProductClient) ListByServiceResponder(resp *http.Response) (result ProductCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client ProductClient) listByServiceNextResults(ctx context.Context, lastResults ProductCollection) (result ProductCollection, err error) { + req, err := lastResults.productCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ProductClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ProductClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool, tags string) (result ProductCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip, expandGroups, tags) + return +} + +// ListByTags lists a collection of products associated with tags. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 | substringof, contains, startswith, endswith +// |
+// top - number of records to return. +// skip - number of records to skip. +// includeNotTaggedProducts - include not tagged Products. +func (client ProductClient) ListByTags(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedProducts *bool) (result TagResourceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductClient.ListByTags") + defer func() { + sc := -1 + if result.trc.Response.Response != nil { + sc = result.trc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductClient", "ListByTags", err.Error()) + } + + result.fn = client.listByTagsNextResults + req, err := client.ListByTagsPreparer(ctx, resourceGroupName, serviceName, filter, top, skip, includeNotTaggedProducts) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "ListByTags", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTagsSender(req) + if err != nil { + result.trc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "ListByTags", resp, "Failure sending request") + return + } + + result.trc, err = client.ListByTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "ListByTags", resp, "Failure responding to request") + return + } + if result.trc.hasNextLink() && result.trc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByTagsPreparer prepares the ListByTags request. +func (client ProductClient) ListByTagsPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedProducts *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if includeNotTaggedProducts != nil { + queryParameters["includeNotTaggedProducts"] = autorest.Encode("query", *includeNotTaggedProducts) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTagsSender sends the ListByTags request. The method will close the +// http.Response Body if it receives an error. +func (client ProductClient) ListByTagsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTagsResponder handles the response to the ListByTags request. The method always +// closes the http.Response Body. +func (client ProductClient) ListByTagsResponder(resp *http.Response) (result TagResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByTagsNextResults retrieves the next set of results, if any. +func (client ProductClient) listByTagsNextResults(ctx context.Context, lastResults TagResourceCollection) (result TagResourceCollection, err error) { + req, err := lastResults.tagResourceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ProductClient", "listByTagsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByTagsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ProductClient", "listByTagsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "listByTagsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByTagsComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductClient) ListByTagsComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, includeNotTaggedProducts *bool) (result TagResourceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductClient.ListByTags") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByTags(ctx, resourceGroupName, serviceName, filter, top, skip, includeNotTaggedProducts) + return +} + +// Update update existing product details. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// parameters - update parameters. +// 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. +func (client ProductClient) Update(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters ProductUpdateParameters, ifMatch string) (result ProductContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, productID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ProductClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters ProductUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ProductClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ProductClient) UpdateResponder(resp *http.Response) (result ProductContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productapi.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productapi.go new file mode 100644 index 000000000000..a3652ed8a69f --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productapi.go @@ -0,0 +1,473 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProductAPIClient is the apiManagement Client +type ProductAPIClient struct { + BaseClient +} + +// NewProductAPIClient creates an instance of the ProductAPIClient client. +func NewProductAPIClient(subscriptionID string) ProductAPIClient { + return NewProductAPIClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductAPIClientWithBaseURI creates an instance of the ProductAPIClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewProductAPIClientWithBaseURI(baseURI string, subscriptionID string) ProductAPIClient { + return ProductAPIClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckEntityExists checks that API entity specified by identifier is associated with the Product entity. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product 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. +func (client ProductAPIClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductAPIClient.CheckEntityExists") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductAPIClient", "CheckEntityExists", err.Error()) + } + + req, err := client.CheckEntityExistsPreparer(ctx, resourceGroupName, serviceName, productID, apiid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "CheckEntityExists", nil, "Failure preparing request") + return + } + + resp, err := client.CheckEntityExistsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "CheckEntityExists", resp, "Failure sending request") + return + } + + result, err = client.CheckEntityExistsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "CheckEntityExists", resp, "Failure responding to request") + return + } + + return +} + +// CheckEntityExistsPreparer prepares the CheckEntityExists request. +func (client ProductAPIClient) CheckEntityExistsPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckEntityExistsSender sends the CheckEntityExists request. The method will close the +// http.Response Body if it receives an error. +func (client ProductAPIClient) CheckEntityExistsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckEntityExistsResponder handles the response to the CheckEntityExists request. The method always +// closes the http.Response Body. +func (client ProductAPIClient) CheckEntityExistsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate adds an API to the specified product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product 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. +func (client ProductAPIClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiid string) (result APIContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductAPIClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductAPIClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, productID, apiid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ProductAPIClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ProductAPIClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ProductAPIClient) CreateOrUpdateResponder(resp *http.Response) (result APIContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified API from the specified product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product 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. +func (client ProductAPIClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductAPIClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductAPIClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, productID, apiid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ProductAPIClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ProductAPIClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ProductAPIClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByProduct lists a collection of the APIs associated with a product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +func (client ProductAPIClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result APICollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductAPIClient.ListByProduct") + defer func() { + sc := -1 + if result.ac.Response.Response != nil { + sc = result.ac.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductAPIClient", "ListByProduct", err.Error()) + } + + result.fn = client.listByProductNextResults + req, err := client.ListByProductPreparer(ctx, resourceGroupName, serviceName, productID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "ListByProduct", nil, "Failure preparing request") + return + } + + resp, err := client.ListByProductSender(req) + if err != nil { + result.ac.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "ListByProduct", resp, "Failure sending request") + return + } + + result.ac, err = client.ListByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "ListByProduct", resp, "Failure responding to request") + return + } + if result.ac.hasNextLink() && result.ac.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByProductPreparer prepares the ListByProduct request. +func (client ProductAPIClient) ListByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByProductSender sends the ListByProduct request. The method will close the +// http.Response Body if it receives an error. +func (client ProductAPIClient) ListByProductSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByProductResponder handles the response to the ListByProduct request. The method always +// closes the http.Response Body. +func (client ProductAPIClient) ListByProductResponder(resp *http.Response) (result APICollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByProductNextResults retrieves the next set of results, if any. +func (client ProductAPIClient) listByProductNextResults(ctx context.Context, lastResults APICollection) (result APICollection, err error) { + req, err := lastResults.aPICollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "listByProductNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByProductSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "listByProductNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductAPIClient", "listByProductNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByProductComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductAPIClient) ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result APICollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductAPIClient.ListByProduct") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByProduct(ctx, resourceGroupName, serviceName, productID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productgroup.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productgroup.go new file mode 100644 index 000000000000..0c825674b4e2 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productgroup.go @@ -0,0 +1,463 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProductGroupClient is the apiManagement Client +type ProductGroupClient struct { + BaseClient +} + +// NewProductGroupClient creates an instance of the ProductGroupClient client. +func NewProductGroupClient(subscriptionID string) ProductGroupClient { + return NewProductGroupClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductGroupClientWithBaseURI creates an instance of the ProductGroupClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewProductGroupClientWithBaseURI(baseURI string, subscriptionID string) ProductGroupClient { + return ProductGroupClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckEntityExists checks that Group entity specified by identifier is associated with the Product entity. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// groupID - group identifier. Must be unique in the current API Management service instance. +func (client ProductGroupClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductGroupClient.CheckEntityExists") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductGroupClient", "CheckEntityExists", err.Error()) + } + + req, err := client.CheckEntityExistsPreparer(ctx, resourceGroupName, serviceName, productID, groupID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "CheckEntityExists", nil, "Failure preparing request") + return + } + + resp, err := client.CheckEntityExistsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "CheckEntityExists", resp, "Failure sending request") + return + } + + result, err = client.CheckEntityExistsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "CheckEntityExists", resp, "Failure responding to request") + return + } + + return +} + +// CheckEntityExistsPreparer prepares the CheckEntityExists request. +func (client ProductGroupClient) CheckEntityExistsPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckEntityExistsSender sends the CheckEntityExists request. The method will close the +// http.Response Body if it receives an error. +func (client ProductGroupClient) CheckEntityExistsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckEntityExistsResponder handles the response to the CheckEntityExists request. The method always +// closes the http.Response Body. +func (client ProductGroupClient) CheckEntityExistsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate adds the association between the specified developer group with the specified product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// groupID - group identifier. Must be unique in the current API Management service instance. +func (client ProductGroupClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string) (result GroupContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductGroupClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductGroupClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, productID, groupID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ProductGroupClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ProductGroupClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ProductGroupClient) CreateOrUpdateResponder(resp *http.Response) (result GroupContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the association between the specified group and product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// groupID - group identifier. Must be unique in the current API Management service instance. +func (client ProductGroupClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductGroupClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: groupID, + Constraints: []validation.Constraint{{Target: "groupID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "groupID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductGroupClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, productID, groupID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ProductGroupClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ProductGroupClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ProductGroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByProduct lists the collection of developer groups associated with the specified product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt +// | |
| displayName | filter | eq, ne | |
| description | filter | eq, ne | |
+// top - number of records to return. +// skip - number of records to skip. +func (client ProductGroupClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result GroupCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductGroupClient.ListByProduct") + defer func() { + sc := -1 + if result.gc.Response.Response != nil { + sc = result.gc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductGroupClient", "ListByProduct", err.Error()) + } + + result.fn = client.listByProductNextResults + req, err := client.ListByProductPreparer(ctx, resourceGroupName, serviceName, productID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "ListByProduct", nil, "Failure preparing request") + return + } + + resp, err := client.ListByProductSender(req) + if err != nil { + result.gc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "ListByProduct", resp, "Failure sending request") + return + } + + result.gc, err = client.ListByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "ListByProduct", resp, "Failure responding to request") + return + } + if result.gc.hasNextLink() && result.gc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByProductPreparer prepares the ListByProduct request. +func (client ProductGroupClient) ListByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByProductSender sends the ListByProduct request. The method will close the +// http.Response Body if it receives an error. +func (client ProductGroupClient) ListByProductSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByProductResponder handles the response to the ListByProduct request. The method always +// closes the http.Response Body. +func (client ProductGroupClient) ListByProductResponder(resp *http.Response) (result GroupCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByProductNextResults retrieves the next set of results, if any. +func (client ProductGroupClient) listByProductNextResults(ctx context.Context, lastResults GroupCollection) (result GroupCollection, err error) { + req, err := lastResults.groupCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "listByProductNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByProductSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "listByProductNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductGroupClient", "listByProductNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByProductComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductGroupClient) ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result GroupCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductGroupClient.ListByProduct") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByProduct(ctx, resourceGroupName, serviceName, productID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productpolicy.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productpolicy.go new file mode 100644 index 000000000000..94b8f74d1c07 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productpolicy.go @@ -0,0 +1,499 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProductPolicyClient is the apiManagement Client +type ProductPolicyClient struct { + BaseClient +} + +// NewProductPolicyClient creates an instance of the ProductPolicyClient client. +func NewProductPolicyClient(subscriptionID string) ProductPolicyClient { + return NewProductPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductPolicyClientWithBaseURI creates an instance of the ProductPolicyClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewProductPolicyClientWithBaseURI(baseURI string, subscriptionID string) ProductPolicyClient { + return ProductPolicyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates policy configuration for the Product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// parameters - the policy contents to apply. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client ProductPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters PolicyContract, ifMatch string) (result PolicyContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductPolicyClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PolicyContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PolicyContractProperties.Value", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductPolicyClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, productID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ProductPolicyClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters PolicyContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyId": autorest.Encode("path", "policy"), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ProductPolicyClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ProductPolicyClient) CreateOrUpdateResponder(resp *http.Response) (result PolicyContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the policy configuration at the Product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client ProductPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductPolicyClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductPolicyClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, productID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ProductPolicyClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyId": autorest.Encode("path", "policy"), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ProductPolicyClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ProductPolicyClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the policy configuration at the Product level. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// formatParameter - policy Export Format. +func (client ProductPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, productID string, formatParameter PolicyExportFormat) (result PolicyContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductPolicyClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductPolicyClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, productID, formatParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProductPolicyClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, formatParameter PolicyExportFormat) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyId": autorest.Encode("path", "policy"), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(formatParameter)) > 0 { + queryParameters["format"] = autorest.Encode("query", formatParameter) + } else { + queryParameters["format"] = autorest.Encode("query", "xml") + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ProductPolicyClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ProductPolicyClient) GetResponder(resp *http.Response) (result PolicyContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag get the ETag of the policy configuration at the Product level. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +func (client ProductPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, productID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductPolicyClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductPolicyClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, productID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client ProductPolicyClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyId": autorest.Encode("path", "policy"), + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client ProductPolicyClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client ProductPolicyClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByProduct get the policy configuration at the Product level. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +func (client ProductPolicyClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string) (result PolicyCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductPolicyClient.ListByProduct") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductPolicyClient", "ListByProduct", err.Error()) + } + + req, err := client.ListByProductPreparer(ctx, resourceGroupName, serviceName, productID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "ListByProduct", nil, "Failure preparing request") + return + } + + resp, err := client.ListByProductSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "ListByProduct", resp, "Failure sending request") + return + } + + result, err = client.ListByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductPolicyClient", "ListByProduct", resp, "Failure responding to request") + return + } + + return +} + +// ListByProductPreparer prepares the ListByProduct request. +func (client ProductPolicyClient) ListByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByProductSender sends the ListByProduct request. The method will close the +// http.Response Body if it receives an error. +func (client ProductPolicyClient) ListByProductSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByProductResponder handles the response to the ListByProduct request. The method always +// closes the http.Response Body. +func (client ProductPolicyClient) ListByProductResponder(resp *http.Response) (result PolicyCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productsubscriptions.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productsubscriptions.go new file mode 100644 index 000000000000..b096ead2e925 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/productsubscriptions.go @@ -0,0 +1,190 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProductSubscriptionsClient is the apiManagement Client +type ProductSubscriptionsClient struct { + BaseClient +} + +// NewProductSubscriptionsClient creates an instance of the ProductSubscriptionsClient client. +func NewProductSubscriptionsClient(subscriptionID string) ProductSubscriptionsClient { + return NewProductSubscriptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductSubscriptionsClientWithBaseURI creates an instance of the ProductSubscriptionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewProductSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) ProductSubscriptionsClient { + return ProductSubscriptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the collection of subscriptions to the specified product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// filter - | 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 | | |
+// top - number of records to return. +// skip - number of records to skip. +func (client ProductSubscriptionsClient) List(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result SubscriptionCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductSubscriptionsClient.List") + defer func() { + sc := -1 + if result.sc.Response.Response != nil { + sc = result.sc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ProductSubscriptionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, serviceName, productID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "List", resp, "Failure sending request") + return + } + + result.sc, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "List", resp, "Failure responding to request") + return + } + if result.sc.hasNextLink() && result.sc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ProductSubscriptionsClient) ListPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ProductSubscriptionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ProductSubscriptionsClient) ListResponder(resp *http.Response) (result SubscriptionCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ProductSubscriptionsClient) listNextResults(ctx context.Context, lastResults SubscriptionCollection) (result SubscriptionCollection, err error) { + req, err := lastResults.subscriptionCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ProductSubscriptionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductSubscriptionsClient) ListComplete(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result SubscriptionCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductSubscriptionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, serviceName, productID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/quotabycounterkeys.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/quotabycounterkeys.go new file mode 100644 index 000000000000..e5effd500e7d --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/quotabycounterkeys.go @@ -0,0 +1,216 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// QuotaByCounterKeysClient is the apiManagement Client +type QuotaByCounterKeysClient struct { + BaseClient +} + +// NewQuotaByCounterKeysClient creates an instance of the QuotaByCounterKeysClient client. +func NewQuotaByCounterKeysClient(subscriptionID string) QuotaByCounterKeysClient { + return NewQuotaByCounterKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewQuotaByCounterKeysClientWithBaseURI creates an instance of the QuotaByCounterKeysClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewQuotaByCounterKeysClientWithBaseURI(baseURI string, subscriptionID string) QuotaByCounterKeysClient { + return QuotaByCounterKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByService lists a collection of current quota counter periods associated with the counter-key configured in the +// policy on the specified service instance. The api does not support paging yet. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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 quota-by-key policy.For Example, if you specify counter-key="boo" in the policy, then it’s +// accessible by "boo" counter key. But if it’s defined as counter-key="@("b"+"a")" then it will be accessible +// by "ba" key +func (client QuotaByCounterKeysClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string) (result QuotaCounterCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaByCounterKeysClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.QuotaByCounterKeysClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, quotaCounterKey) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client QuotaByCounterKeysClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "quotaCounterKey": autorest.Encode("path", quotaCounterKey), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaByCounterKeysClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client QuotaByCounterKeysClient) ListByServiceResponder(resp *http.Response) (result QuotaCounterCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates all the quota counter values specified with the existing quota counter key to a value in the +// specified service instance. This should be used for reset of the quota counter values. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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 quota-by-key policy.For Example, if you specify counter-key="boo" in the policy, then it’s +// accessible by "boo" counter key. But if it’s defined as counter-key="@("b"+"a")" then it will be accessible +// by "ba" key +// parameters - the value of the quota counter to be applied to all quota counter periods. +func (client QuotaByCounterKeysClient) Update(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, parameters QuotaCounterValueUpdateContract) (result QuotaCounterCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaByCounterKeysClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.QuotaByCounterKeysClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, quotaCounterKey, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByCounterKeysClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client QuotaByCounterKeysClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, parameters QuotaCounterValueUpdateContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "quotaCounterKey": autorest.Encode("path", quotaCounterKey), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaByCounterKeysClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client QuotaByCounterKeysClient) UpdateResponder(resp *http.Response) (result QuotaCounterCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/quotabyperiodkeys.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/quotabyperiodkeys.go new file mode 100644 index 000000000000..6a9ad96bee37 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/quotabyperiodkeys.go @@ -0,0 +1,219 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// QuotaByPeriodKeysClient is the apiManagement Client +type QuotaByPeriodKeysClient struct { + BaseClient +} + +// NewQuotaByPeriodKeysClient creates an instance of the QuotaByPeriodKeysClient client. +func NewQuotaByPeriodKeysClient(subscriptionID string) QuotaByPeriodKeysClient { + return NewQuotaByPeriodKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewQuotaByPeriodKeysClientWithBaseURI creates an instance of the QuotaByPeriodKeysClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewQuotaByPeriodKeysClientWithBaseURI(baseURI string, subscriptionID string) QuotaByPeriodKeysClient { + return QuotaByPeriodKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the value of the quota counter associated with the counter-key in the policy for the specific period in +// service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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 quota-by-key policy.For Example, if you specify counter-key="boo" in the policy, then it’s +// accessible by "boo" counter key. But if it’s defined as counter-key="@("b"+"a")" then it will be accessible +// by "ba" key +// quotaPeriodKey - quota period key identifier. +func (client QuotaByPeriodKeysClient) Get(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string) (result QuotaCounterContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaByPeriodKeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.QuotaByPeriodKeysClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, quotaCounterKey, quotaPeriodKey) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client QuotaByPeriodKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "quotaCounterKey": autorest.Encode("path", quotaCounterKey), + "quotaPeriodKey": autorest.Encode("path", quotaPeriodKey), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaByPeriodKeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client QuotaByPeriodKeysClient) GetResponder(resp *http.Response) (result QuotaCounterContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing quota counter value in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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 quota-by-key policy.For Example, if you specify counter-key="boo" in the policy, then it’s +// accessible by "boo" counter key. But if it’s defined as counter-key="@("b"+"a")" then it will be accessible +// by "ba" key +// quotaPeriodKey - quota period key identifier. +// parameters - the value of the Quota counter to be applied on the specified period. +func (client QuotaByPeriodKeysClient) Update(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, parameters QuotaCounterValueUpdateContract) (result QuotaCounterContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QuotaByPeriodKeysClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.QuotaByPeriodKeysClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, quotaCounterKey, quotaPeriodKey, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.QuotaByPeriodKeysClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client QuotaByPeriodKeysClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, parameters QuotaCounterValueUpdateContract) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "quotaCounterKey": autorest.Encode("path", quotaCounterKey), + "quotaPeriodKey": autorest.Encode("path", quotaPeriodKey), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client QuotaByPeriodKeysClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client QuotaByPeriodKeysClient) UpdateResponder(resp *http.Response) (result QuotaCounterContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/region.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/region.go new file mode 100644 index 000000000000..0b9adde30f6e --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/region.go @@ -0,0 +1,158 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegionClient is the apiManagement Client +type RegionClient struct { + BaseClient +} + +// NewRegionClient creates an instance of the RegionClient client. +func NewRegionClient(subscriptionID string) RegionClient { + return NewRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRegionClientWithBaseURI creates an instance of the RegionClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRegionClientWithBaseURI(baseURI string, subscriptionID string) RegionClient { + return RegionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByService lists all azure regions in which the service exists. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client RegionClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string) (result RegionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegionClient.ListByService") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.RegionClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.RegionClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.RegionClient", "ListByService", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.RegionClient", "ListByService", resp, "Failure responding to request") + return + } + if result.rlr.hasNextLink() && result.rlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client RegionClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client RegionClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client RegionClient) ListByServiceResponder(resp *http.Response) (result RegionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client RegionClient) listByServiceNextResults(ctx context.Context, lastResults RegionListResult) (result RegionListResult, err error) { + req, err := lastResults.regionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.RegionClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.RegionClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.RegionClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegionClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string) (result RegionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegionClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/reports.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/reports.go new file mode 100644 index 000000000000..1be8058f5554 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/reports.go @@ -0,0 +1,1220 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ReportsClient is the apiManagement Client +type ReportsClient struct { + BaseClient +} + +// NewReportsClient creates an instance of the ReportsClient client. +func NewReportsClient(subscriptionID string) ReportsClient { + return NewReportsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReportsClientWithBaseURI creates an instance of the ReportsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewReportsClientWithBaseURI(baseURI string, subscriptionID string) ReportsClient { + return ReportsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByAPI lists report records by API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - the filter to apply on the operation. +// top - number of records to return. +// skip - number of records to skip. +// orderby - oData order by query option. +func (client ReportsClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByAPI") + defer func() { + sc := -1 + if result.rc.Response.Response != nil { + sc = result.rc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ReportsClient", "ListByAPI", err.Error()) + } + + result.fn = client.listByAPINextResults + req, err := client.ListByAPIPreparer(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByAPI", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAPISender(req) + if err != nil { + result.rc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByAPI", resp, "Failure sending request") + return + } + + result.rc, err = client.ListByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByAPI", resp, "Failure responding to request") + return + } + if result.rc.hasNextLink() && result.rc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAPIPreparer prepares the ListByAPI request. +func (client ReportsClient) ListByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAPISender sends the ListByAPI request. The method will close the +// http.Response Body if it receives an error. +func (client ReportsClient) ListByAPISender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAPIResponder handles the response to the ListByAPI request. The method always +// closes the http.Response Body. +func (client ReportsClient) ListByAPIResponder(resp *http.Response) (result ReportCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAPINextResults retrieves the next set of results, if any. +func (client ReportsClient) listByAPINextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { + req, err := lastResults.reportCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByAPINextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAPISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByAPINextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByAPINextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAPIComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReportsClient) ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByAPI") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAPI(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + return +} + +// ListByGeo lists report records by geography. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| timestamp | filter | ge, le | | +//
| country | select | | |
| region | select | | |
| zip | select | | | +//
| apiRegion | filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | +// |
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| operationId | filter +// | eq | |
| callCountSuccess | select | | |
| callCountBlocked | select | | | +//
| callCountFailed | select | | |
| callCountOther | select | | |
| bandwidth +// | select, orderBy | | |
| cacheHitsCount | select | | |
| cacheMissCount | select +// | | |
| apiTimeAvg | select | | |
| apiTimeMin | select | | |
| +// apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | +// select | | |
| serviceTimeMax | select | | |
+// top - number of records to return. +// skip - number of records to skip. +func (client ReportsClient) ListByGeo(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByGeo") + defer func() { + sc := -1 + if result.rc.Response.Response != nil { + sc = result.rc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ReportsClient", "ListByGeo", err.Error()) + } + + result.fn = client.listByGeoNextResults + req, err := client.ListByGeoPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByGeo", nil, "Failure preparing request") + return + } + + resp, err := client.ListByGeoSender(req) + if err != nil { + result.rc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByGeo", resp, "Failure sending request") + return + } + + result.rc, err = client.ListByGeoResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByGeo", resp, "Failure responding to request") + return + } + if result.rc.hasNextLink() && result.rc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByGeoPreparer prepares the ListByGeo request. +func (client ReportsClient) ListByGeoPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByGeoSender sends the ListByGeo request. The method will close the +// http.Response Body if it receives an error. +func (client ReportsClient) ListByGeoSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByGeoResponder handles the response to the ListByGeo request. The method always +// closes the http.Response Body. +func (client ReportsClient) ListByGeoResponder(resp *http.Response) (result ReportCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByGeoNextResults retrieves the next set of results, if any. +func (client ReportsClient) listByGeoNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { + req, err := lastResults.reportCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByGeoNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByGeoSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByGeoNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByGeoResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByGeoNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByGeoComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReportsClient) ListByGeoComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result ReportCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByGeo") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByGeo(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// ListByOperation lists report records by API Operations. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| timestamp | filter | ge, le | | +//
| displayName | select, orderBy | | |
| apiRegion | filter | eq | |
| userId | +// filter | eq | |
| productId | filter | eq | |
| subscriptionId | filter | eq | | +//
| apiId | filter | eq | |
| operationId | select, filter | eq | |
| callCountSuccess +// | select, orderBy | | |
| callCountBlocked | select, orderBy | | |
| +// callCountFailed | select, orderBy | | |
| callCountOther | select, orderBy | | |
| +// callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | |
| +// cacheHitsCount | select | | |
| cacheMissCount | select | | |
| apiTimeAvg | +// select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | +// |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| +// serviceTimeMax | select | | |
+// top - number of records to return. +// skip - number of records to skip. +// orderby - oData order by query option. +func (client ReportsClient) ListByOperation(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByOperation") + defer func() { + sc := -1 + if result.rc.Response.Response != nil { + sc = result.rc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ReportsClient", "ListByOperation", err.Error()) + } + + result.fn = client.listByOperationNextResults + req, err := client.ListByOperationPreparer(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByOperation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByOperationSender(req) + if err != nil { + result.rc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByOperation", resp, "Failure sending request") + return + } + + result.rc, err = client.ListByOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByOperation", resp, "Failure responding to request") + return + } + if result.rc.hasNextLink() && result.rc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByOperationPreparer prepares the ListByOperation request. +func (client ReportsClient) ListByOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByOperationSender sends the ListByOperation request. The method will close the +// http.Response Body if it receives an error. +func (client ReportsClient) ListByOperationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByOperationResponder handles the response to the ListByOperation request. The method always +// closes the http.Response Body. +func (client ReportsClient) ListByOperationResponder(resp *http.Response) (result ReportCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByOperationNextResults retrieves the next set of results, if any. +func (client ReportsClient) listByOperationNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { + req, err := lastResults.reportCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByOperationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByOperationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByOperationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByOperationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByOperationComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReportsClient) ListByOperationComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByOperation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByOperation(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + return +} + +// ListByProduct lists report records by Product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| timestamp | filter | ge, le | | +//
| displayName | select, orderBy | | |
| apiRegion | filter | eq | |
| userId | +// filter | eq | |
| productId | select, filter | eq | |
| subscriptionId | filter | eq | +// |
| callCountSuccess | select, orderBy | | |
| callCountBlocked | select, orderBy | | +// |
| callCountFailed | select, orderBy | | |
| callCountOther | select, orderBy | | +// |
| callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +//
| cacheHitsCount | select | | |
| cacheMissCount | select | | |
| apiTimeAvg +// | select, orderBy | | |
| apiTimeMin | select | | |
| apiTimeMax | select | | +// |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| +// serviceTimeMax | select | | |
+// top - number of records to return. +// skip - number of records to skip. +// orderby - oData order by query option. +func (client ReportsClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByProduct") + defer func() { + sc := -1 + if result.rc.Response.Response != nil { + sc = result.rc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ReportsClient", "ListByProduct", err.Error()) + } + + result.fn = client.listByProductNextResults + req, err := client.ListByProductPreparer(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByProduct", nil, "Failure preparing request") + return + } + + resp, err := client.ListByProductSender(req) + if err != nil { + result.rc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByProduct", resp, "Failure sending request") + return + } + + result.rc, err = client.ListByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByProduct", resp, "Failure responding to request") + return + } + if result.rc.hasNextLink() && result.rc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByProductPreparer prepares the ListByProduct request. +func (client ReportsClient) ListByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByProductSender sends the ListByProduct request. The method will close the +// http.Response Body if it receives an error. +func (client ReportsClient) ListByProductSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByProductResponder handles the response to the ListByProduct request. The method always +// closes the http.Response Body. +func (client ReportsClient) ListByProductResponder(resp *http.Response) (result ReportCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByProductNextResults retrieves the next set of results, if any. +func (client ReportsClient) listByProductNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { + req, err := lastResults.reportCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByProductNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByProductSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByProductNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByProductNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByProductComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReportsClient) ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByProduct") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByProduct(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + return +} + +// ListByRequest lists report records by Request. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| timestamp | filter | ge, le | | +//
| apiId | filter | eq | |
| operationId | filter | eq | |
| productId | filter | eq | +// |
| userId | filter | eq | |
| apiRegion | filter | eq | |
| subscriptionId | filter +// | eq | |
+// top - number of records to return. +// skip - number of records to skip. +func (client ReportsClient) ListByRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result RequestReportCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByRequest") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ReportsClient", "ListByRequest", err.Error()) + } + + req, err := client.ListByRequestPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByRequest", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRequestSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByRequest", resp, "Failure sending request") + return + } + + result, err = client.ListByRequestResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByRequest", resp, "Failure responding to request") + return + } + + return +} + +// ListByRequestPreparer prepares the ListByRequest request. +func (client ReportsClient) ListByRequestPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByRequestSender sends the ListByRequest request. The method will close the +// http.Response Body if it receives an error. +func (client ReportsClient) ListByRequestSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByRequestResponder handles the response to the ListByRequest request. The method always +// closes the http.Response Body. +func (client ReportsClient) ListByRequestResponder(resp *http.Response) (result RequestReportCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription lists report records by subscription. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| timestamp | filter | ge, le | | +//
| displayName | select, orderBy | | |
| apiRegion | filter | eq | |
| userId | +// select, filter | eq | |
| productId | select, filter | eq | |
| subscriptionId | select, +// filter | eq | |
| callCountSuccess | select, orderBy | | |
| callCountBlocked | +// select, orderBy | | |
| callCountFailed | select, orderBy | | |
| callCountOther | +// select, orderBy | | |
| callCountTotal | select, orderBy | | |
| bandwidth | +// select, orderBy | | |
| cacheHitsCount | select | | |
| cacheMissCount | select | +// | |
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | |
| +// apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | +// select | | |
| serviceTimeMax | select | | |
+// top - number of records to return. +// skip - number of records to skip. +// orderby - oData order by query option. +func (client ReportsClient) ListBySubscription(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListBySubscription") + defer func() { + sc := -1 + if result.rc.Response.Response != nil { + sc = result.rc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ReportsClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.rc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.rc, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.rc.hasNextLink() && result.rc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ReportsClient) ListBySubscriptionPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ReportsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ReportsClient) ListBySubscriptionResponder(resp *http.Response) (result ReportCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client ReportsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { + req, err := lastResults.reportCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReportsClient) ListBySubscriptionComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + return +} + +// ListByTime lists report records by Time. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| timestamp | filter, select | ge, le | +// |
| interval | select | | |
| apiRegion | filter | eq | |
| userId | filter | eq +// | |
| productId | filter | eq | |
| subscriptionId | filter | eq | |
| apiId | +// filter | eq | |
| operationId | filter | eq | |
| callCountSuccess | select | | | +//
| callCountBlocked | select | | |
| callCountFailed | select | | |
| +// callCountOther | select | | |
| bandwidth | select, orderBy | | |
| cacheHitsCount +// | select | | |
| cacheMissCount | select | | |
| apiTimeAvg | select | | | +//
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| serviceTimeAvg | +// select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | +// |
+// interval - by time interval. Interval must be multiple of 15 minutes and may not be zero. The value should +// be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert +// TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). +// top - number of records to return. +// skip - number of records to skip. +// orderby - oData order by query option. +func (client ReportsClient) ListByTime(ctx context.Context, resourceGroupName string, serviceName string, filter string, interval string, top *int32, skip *int32, orderby string) (result ReportCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByTime") + defer func() { + sc := -1 + if result.rc.Response.Response != nil { + sc = result.rc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ReportsClient", "ListByTime", err.Error()) + } + + result.fn = client.listByTimeNextResults + req, err := client.ListByTimePreparer(ctx, resourceGroupName, serviceName, filter, interval, top, skip, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByTime", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTimeSender(req) + if err != nil { + result.rc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByTime", resp, "Failure sending request") + return + } + + result.rc, err = client.ListByTimeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByTime", resp, "Failure responding to request") + return + } + if result.rc.hasNextLink() && result.rc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByTimePreparer prepares the ListByTime request. +func (client ReportsClient) ListByTimePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, interval string, top *int32, skip *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + "interval": autorest.Encode("query", interval), + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTimeSender sends the ListByTime request. The method will close the +// http.Response Body if it receives an error. +func (client ReportsClient) ListByTimeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTimeResponder handles the response to the ListByTime request. The method always +// closes the http.Response Body. +func (client ReportsClient) ListByTimeResponder(resp *http.Response) (result ReportCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByTimeNextResults retrieves the next set of results, if any. +func (client ReportsClient) listByTimeNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { + req, err := lastResults.reportCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByTimeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByTimeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByTimeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByTimeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByTimeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByTimeComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReportsClient) ListByTimeComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, interval string, top *int32, skip *int32, orderby string) (result ReportCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByTime") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByTime(ctx, resourceGroupName, serviceName, filter, interval, top, skip, orderby) + return +} + +// ListByUser lists report records by User. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| timestamp | filter | ge, le | | +//
| displayName | select, orderBy | | |
| userId | select, filter | eq | |
| +// apiRegion | filter | eq | |
| productId | filter | eq | |
| subscriptionId | filter | eq | +// |
| apiId | filter | eq | |
| operationId | filter | eq | |
| callCountSuccess | +// select, orderBy | | |
| callCountBlocked | select, orderBy | | |
| callCountFailed +// | select, orderBy | | |
| callCountOther | select, orderBy | | |
| callCountTotal +// | select, orderBy | | |
| bandwidth | select, orderBy | | |
| cacheHitsCount | +// select | | |
| cacheMissCount | select | | |
| apiTimeAvg | select, orderBy | +// | |
| apiTimeMin | select | | |
| apiTimeMax | select | | |
| +// serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | +// select | | |
+// top - number of records to return. +// skip - number of records to skip. +// orderby - oData order by query option. +func (client ReportsClient) ListByUser(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByUser") + defer func() { + sc := -1 + if result.rc.Response.Response != nil { + sc = result.rc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.ReportsClient", "ListByUser", err.Error()) + } + + result.fn = client.listByUserNextResults + req, err := client.ListByUserPreparer(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByUser", nil, "Failure preparing request") + return + } + + resp, err := client.ListByUserSender(req) + if err != nil { + result.rc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByUser", resp, "Failure sending request") + return + } + + result.rc, err = client.ListByUserResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "ListByUser", resp, "Failure responding to request") + return + } + if result.rc.hasNextLink() && result.rc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByUserPreparer prepares the ListByUser request. +func (client ReportsClient) ListByUserPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByUserSender sends the ListByUser request. The method will close the +// http.Response Body if it receives an error. +func (client ReportsClient) ListByUserSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByUserResponder handles the response to the ListByUser request. The method always +// closes the http.Response Body. +func (client ReportsClient) ListByUserResponder(resp *http.Response) (result ReportCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByUserNextResults retrieves the next set of results, if any. +func (client ReportsClient) listByUserNextResults(ctx context.Context, lastResults ReportCollection) (result ReportCollection, err error) { + req, err := lastResults.reportCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByUserNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByUserSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByUserNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByUserResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ReportsClient", "listByUserNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByUserComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReportsClient) ListByUserComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, orderby string) (result ReportCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByUser") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByUser(ctx, resourceGroupName, serviceName, filter, top, skip, orderby) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/service.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/service.go new file mode 100644 index 000000000000..4cb708eac8ee --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/service.go @@ -0,0 +1,1143 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServiceClient is the apiManagement Client +type ServiceClient struct { + BaseClient +} + +// NewServiceClient creates an instance of the ServiceClient client. +func NewServiceClient(subscriptionID string) ServiceClient { + return NewServiceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceClientWithBaseURI creates an instance of the ServiceClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServiceClientWithBaseURI(baseURI string, subscriptionID string) ServiceClient { + return ServiceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ApplyNetworkConfigurationUpdates updates the Microsoft.ApiManagement resource running in the Virtual network to pick +// the updated DNS changes. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - parameters supplied to the Apply Network Configuration operation. If the parameters are empty, +// all the regions in which the Api Management service is deployed will be updated sequentially without +// incurring downtime in the region. +func (client ServiceClient) ApplyNetworkConfigurationUpdates(ctx context.Context, resourceGroupName string, serviceName string, parameters *ServiceApplyNetworkConfigurationParameters) (result ServiceApplyNetworkConfigurationUpdatesFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.ApplyNetworkConfigurationUpdates") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceClient", "ApplyNetworkConfigurationUpdates", err.Error()) + } + + req, err := client.ApplyNetworkConfigurationUpdatesPreparer(ctx, resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ApplyNetworkConfigurationUpdates", nil, "Failure preparing request") + return + } + + result, err = client.ApplyNetworkConfigurationUpdatesSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ApplyNetworkConfigurationUpdates", nil, "Failure sending request") + return + } + + return +} + +// ApplyNetworkConfigurationUpdatesPreparer prepares the ApplyNetworkConfigurationUpdates request. +func (client ServiceClient) ApplyNetworkConfigurationUpdatesPreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters *ServiceApplyNetworkConfigurationParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ApplyNetworkConfigurationUpdatesSender sends the ApplyNetworkConfigurationUpdates request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) ApplyNetworkConfigurationUpdatesSender(req *http.Request) (future ServiceApplyNetworkConfigurationUpdatesFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ApplyNetworkConfigurationUpdatesResponder handles the response to the ApplyNetworkConfigurationUpdates request. The method always +// closes the http.Response Body. +func (client ServiceClient) ApplyNetworkConfigurationUpdatesResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Backup creates a backup of the API Management service to the given Azure Storage Account. This is long running +// operation and could take several minutes to complete. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - parameters supplied to the ApiManagementService_Backup operation. +func (client ServiceClient) Backup(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (result ServiceBackupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Backup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageAccount", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ContainerName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceClient", "Backup", err.Error()) + } + + req, err := client.BackupPreparer(ctx, resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Backup", nil, "Failure preparing request") + return + } + + result, err = client.BackupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Backup", nil, "Failure sending request") + return + } + + return +} + +// BackupPreparer prepares the Backup request. +func (client ServiceClient) BackupPreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// BackupSender sends the Backup request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) BackupSender(req *http.Request) (future ServiceBackupFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// BackupResponder handles the response to the Backup request. The method always +// closes the http.Response Body. +func (client ServiceClient) BackupResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CheckNameAvailability checks availability and correctness of a name for an API Management service. +// Parameters: +// parameters - parameters supplied to the CheckNameAvailability operation. +func (client ServiceClient) CheckNameAvailability(ctx context.Context, parameters ServiceCheckNameAvailabilityParameters) (result ServiceNameAvailabilityResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceClient", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client ServiceClient) CheckNameAvailabilityPreparer(ctx context.Context, parameters ServiceCheckNameAvailabilityParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client ServiceClient) CheckNameAvailabilityResponder(resp *http.Response) (result ServiceNameAvailabilityResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates an API Management service. This is long running operation and could take several +// minutes to complete. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - parameters supplied to the CreateOrUpdate API Management service operation. +func (client ServiceClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceResource) (result ServiceCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServiceProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherEmail", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherEmail", Name: validation.MaxLength, Rule: 100, Chain: nil}}}, + {Target: "parameters.ServiceProperties.PublisherName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherName", Name: validation.MaxLength, Rule: 100, Chain: nil}}}, + }}, + {Target: "parameters.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Sku.Capacity", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServiceClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Etag = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) CreateOrUpdateSender(req *http.Request) (future ServiceCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServiceClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing API Management service. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client ServiceClient) Delete(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServiceClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) DeleteSender(req *http.Request) (future ServiceDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServiceClient) DeleteResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets an API Management service resource description. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client ServiceClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceClient) GetResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetDomainOwnershipIdentifier get the custom domain ownership identifier for an API Management service. +func (client ServiceClient) GetDomainOwnershipIdentifier(ctx context.Context) (result ServiceGetDomainOwnershipIdentifierResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.GetDomainOwnershipIdentifier") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetDomainOwnershipIdentifierPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetDomainOwnershipIdentifier", nil, "Failure preparing request") + return + } + + resp, err := client.GetDomainOwnershipIdentifierSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetDomainOwnershipIdentifier", resp, "Failure sending request") + return + } + + result, err = client.GetDomainOwnershipIdentifierResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetDomainOwnershipIdentifier", resp, "Failure responding to request") + return + } + + return +} + +// GetDomainOwnershipIdentifierPreparer prepares the GetDomainOwnershipIdentifier request. +func (client ServiceClient) GetDomainOwnershipIdentifierPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDomainOwnershipIdentifierSender sends the GetDomainOwnershipIdentifier request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) GetDomainOwnershipIdentifierSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetDomainOwnershipIdentifierResponder handles the response to the GetDomainOwnershipIdentifier request. The method always +// closes the http.Response Body. +func (client ServiceClient) GetDomainOwnershipIdentifierResponder(resp *http.Response) (result ServiceGetDomainOwnershipIdentifierResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSsoToken gets the Single-Sign-On token for the API Management Service which is valid for 5 Minutes. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client ServiceClient) GetSsoToken(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceGetSsoTokenResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.GetSsoToken") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceClient", "GetSsoToken", err.Error()) + } + + req, err := client.GetSsoTokenPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetSsoToken", nil, "Failure preparing request") + return + } + + resp, err := client.GetSsoTokenSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetSsoToken", resp, "Failure sending request") + return + } + + result, err = client.GetSsoTokenResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetSsoToken", resp, "Failure responding to request") + return + } + + return +} + +// GetSsoTokenPreparer prepares the GetSsoToken request. +func (client ServiceClient) GetSsoTokenPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSsoTokenSender sends the GetSsoToken request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) GetSsoTokenSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSsoTokenResponder handles the response to the GetSsoToken request. The method always +// closes the http.Response Body. +func (client ServiceClient) GetSsoTokenResponder(resp *http.Response) (result ServiceGetSsoTokenResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all API Management services within an Azure subscription. +func (client ServiceClient) List(ctx context.Context) (result ServiceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.List") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "List", resp, "Failure sending request") + return + } + + result.slr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "List", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceClient) ListResponder(resp *http.Response) (result ServiceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServiceClient) listNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) { + req, err := lastResults.serviceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceClient) ListComplete(ctx context.Context) (result ServiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup list all API Management services within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client ServiceClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServiceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServiceClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServiceClient) ListByResourceGroupResponder(resp *http.Response) (result ServiceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ServiceClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) { + req, err := lastResults.serviceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Restore restores a backup of an API Management service created using the ApiManagementService_Backup operation on +// the current service. This is a long running operation and could take several minutes to complete. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - parameters supplied to the Restore API Management service from backup operation. +func (client ServiceClient) Restore(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (result ServiceRestoreFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Restore") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageAccount", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ContainerName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceClient", "Restore", err.Error()) + } + + req, err := client.RestorePreparer(ctx, resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Restore", nil, "Failure preparing request") + return + } + + result, err = client.RestoreSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Restore", nil, "Failure sending request") + return + } + + return +} + +// RestorePreparer prepares the Restore request. +func (client ServiceClient) RestorePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RestoreSender sends the Restore request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) RestoreSender(req *http.Request) (future ServiceRestoreFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RestoreResponder handles the response to the Restore request. The method always +// closes the http.Response Body. +func (client ServiceClient) RestoreResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing API Management service. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - parameters supplied to the CreateOrUpdate API Management service operation. +func (client ServiceClient) Update(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceUpdateParameters) (result ServiceUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServiceClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Etag = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) UpdateSender(req *http.Request) (future ServiceUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServiceClient) UpdateResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/serviceskus.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/serviceskus.go new file mode 100644 index 000000000000..1eb1890d0123 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/serviceskus.go @@ -0,0 +1,158 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServiceSkusClient is the apiManagement Client +type ServiceSkusClient struct { + BaseClient +} + +// NewServiceSkusClient creates an instance of the ServiceSkusClient client. +func NewServiceSkusClient(subscriptionID string) ServiceSkusClient { + return NewServiceSkusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceSkusClientWithBaseURI creates an instance of the ServiceSkusClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServiceSkusClientWithBaseURI(baseURI string, subscriptionID string) ServiceSkusClient { + return ServiceSkusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListAvailableServiceSkus gets all available SKU for a given API Management service +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client ServiceSkusClient) ListAvailableServiceSkus(ctx context.Context, resourceGroupName string, serviceName string) (result ResourceSkuResultsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceSkusClient.ListAvailableServiceSkus") + defer func() { + sc := -1 + if result.rsr.Response.Response != nil { + sc = result.rsr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", err.Error()) + } + + result.fn = client.listAvailableServiceSkusNextResults + req, err := client.ListAvailableServiceSkusPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", nil, "Failure preparing request") + return + } + + resp, err := client.ListAvailableServiceSkusSender(req) + if err != nil { + result.rsr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", resp, "Failure sending request") + return + } + + result.rsr, err = client.ListAvailableServiceSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "ListAvailableServiceSkus", resp, "Failure responding to request") + return + } + if result.rsr.hasNextLink() && result.rsr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListAvailableServiceSkusPreparer prepares the ListAvailableServiceSkus request. +func (client ServiceSkusClient) ListAvailableServiceSkusPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAvailableServiceSkusSender sends the ListAvailableServiceSkus request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceSkusClient) ListAvailableServiceSkusSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListAvailableServiceSkusResponder handles the response to the ListAvailableServiceSkus request. The method always +// closes the http.Response Body. +func (client ServiceSkusClient) ListAvailableServiceSkusResponder(resp *http.Response) (result ResourceSkuResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listAvailableServiceSkusNextResults retrieves the next set of results, if any. +func (client ServiceSkusClient) listAvailableServiceSkusNextResults(ctx context.Context, lastResults ResourceSkuResults) (result ResourceSkuResults, err error) { + req, err := lastResults.resourceSkuResultsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "listAvailableServiceSkusNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListAvailableServiceSkusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "listAvailableServiceSkusNextResults", resp, "Failure sending next results request") + } + result, err = client.ListAvailableServiceSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.ServiceSkusClient", "listAvailableServiceSkusNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListAvailableServiceSkusComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceSkusClient) ListAvailableServiceSkusComplete(ctx context.Context, resourceGroupName string, serviceName string) (result ResourceSkuResultsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceSkusClient.ListAvailableServiceSkus") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListAvailableServiceSkus(ctx, resourceGroupName, serviceName) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/signinsettings.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/signinsettings.go new file mode 100644 index 000000000000..6b01dc43cde7 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/signinsettings.go @@ -0,0 +1,380 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SignInSettingsClient is the apiManagement Client +type SignInSettingsClient struct { + BaseClient +} + +// NewSignInSettingsClient creates an instance of the SignInSettingsClient client. +func NewSignInSettingsClient(subscriptionID string) SignInSettingsClient { + return NewSignInSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSignInSettingsClientWithBaseURI creates an instance of the SignInSettingsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSignInSettingsClientWithBaseURI(baseURI string, subscriptionID string) SignInSettingsClient { + return SignInSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or Update Sign-In settings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - create or update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client SignInSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSigninSettings, ifMatch string) (result PortalSigninSettings, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignInSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SignInSettingsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SignInSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSigninSettings, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SignInSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SignInSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result PortalSigninSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get Sign In Settings for the Portal +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client SignInSettingsClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result PortalSigninSettings, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignInSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SignInSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SignInSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SignInSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SignInSettingsClient) GetResponder(resp *http.Response) (result PortalSigninSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the SignInSettings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client SignInSettingsClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignInSettingsClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SignInSettingsClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client SignInSettingsClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client SignInSettingsClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client SignInSettingsClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update update Sign-In settings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - update Sign-In settings. +// 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. +func (client SignInSettingsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSigninSettings, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignInSettingsClient.Update") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SignInSettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignInSettingsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SignInSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSigninSettings, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SignInSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SignInSettingsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/signupsettings.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/signupsettings.go new file mode 100644 index 000000000000..6076730d7b1e --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/signupsettings.go @@ -0,0 +1,380 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SignUpSettingsClient is the apiManagement Client +type SignUpSettingsClient struct { + BaseClient +} + +// NewSignUpSettingsClient creates an instance of the SignUpSettingsClient client. +func NewSignUpSettingsClient(subscriptionID string) SignUpSettingsClient { + return NewSignUpSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSignUpSettingsClientWithBaseURI creates an instance of the SignUpSettingsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSignUpSettingsClientWithBaseURI(baseURI string, subscriptionID string) SignUpSettingsClient { + return SignUpSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or Update Sign-Up settings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - create or update parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client SignUpSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSignupSettings, ifMatch string) (result PortalSignupSettings, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignUpSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SignUpSettingsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SignUpSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSignupSettings, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SignUpSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SignUpSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result PortalSignupSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get Sign Up Settings for the Portal +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client SignUpSettingsClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result PortalSignupSettings, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignUpSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SignUpSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SignUpSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SignUpSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SignUpSettingsClient) GetResponder(resp *http.Response) (result PortalSignupSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the SignUpSettings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client SignUpSettingsClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignUpSettingsClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SignUpSettingsClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client SignUpSettingsClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client SignUpSettingsClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client SignUpSettingsClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update update Sign-Up settings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - update Sign-Up settings. +// 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. +func (client SignUpSettingsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSignupSettings, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignUpSettingsClient.Update") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SignUpSettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SignUpSettingsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SignUpSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSignupSettings, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SignUpSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SignUpSettingsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/skus.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/skus.go new file mode 100644 index 000000000000..642e1020f88b --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/skus.go @@ -0,0 +1,144 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SkusClient is the apiManagement Client +type SkusClient struct { + BaseClient +} + +// NewSkusClient creates an instance of the SkusClient client. +func NewSkusClient(subscriptionID string) SkusClient { + return NewSkusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSkusClientWithBaseURI creates an instance of the SkusClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient { + return SkusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List gets the list of Microsoft.ApiManagement SKUs available for your Subscription. +func (client SkusClient) List(ctx context.Context) (result SkusResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusClient.List") + defer func() { + sc := -1 + if result.sr.Response.Response != nil { + sc = result.sr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SkusClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SkusClient", "List", resp, "Failure sending request") + return + } + + result.sr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SkusClient", "List", resp, "Failure responding to request") + return + } + if result.sr.hasNextLink() && result.sr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client SkusClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SkusClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SkusClient) ListResponder(resp *http.Response) (result SkusResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SkusClient) listNextResults(ctx context.Context, lastResults SkusResult) (result SkusResult, err error) { + req, err := lastResults.skusResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.SkusClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.SkusClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SkusClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SkusClient) ListComplete(ctx context.Context) (result SkusResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/subscription.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/subscription.go new file mode 100644 index 000000000000..3bd87b6c3857 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/subscription.go @@ -0,0 +1,959 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SubscriptionClient is the apiManagement Client +type SubscriptionClient struct { + BaseClient +} + +// NewSubscriptionClient creates an instance of the SubscriptionClient client. +func NewSubscriptionClient(subscriptionID string) SubscriptionClient { + return NewSubscriptionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionClientWithBaseURI creates an instance of the SubscriptionClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSubscriptionClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionClient { + return SubscriptionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the subscription of specified user to the specified product. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// parameters - create parameters. +// notify - 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 +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +// appType - determines the type of application which send the create user request. Default is legacy publisher +// portal. +func (client SubscriptionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, sid string, parameters SubscriptionCreateParameters, notify *bool, ifMatch string, appType AppType) (result SubscriptionContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SubscriptionCreateParameterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SubscriptionCreateParameterProperties.Scope", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.SubscriptionCreateParameterProperties.DisplayName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.SubscriptionCreateParameterProperties.DisplayName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "parameters.SubscriptionCreateParameterProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + {Target: "parameters.SubscriptionCreateParameterProperties.PrimaryKey", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SubscriptionCreateParameterProperties.PrimaryKey", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "parameters.SubscriptionCreateParameterProperties.PrimaryKey", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + {Target: "parameters.SubscriptionCreateParameterProperties.SecondaryKey", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SubscriptionCreateParameterProperties.SecondaryKey", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "parameters.SubscriptionCreateParameterProperties.SecondaryKey", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.SubscriptionClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, sid, parameters, notify, ifMatch, appType) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SubscriptionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, sid string, parameters SubscriptionCreateParameters, notify *bool, ifMatch string, appType AppType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "sid": autorest.Encode("path", sid), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if notify != nil { + queryParameters["notify"] = autorest.Encode("query", *notify) + } + if len(string(appType)) > 0 { + queryParameters["appType"] = autorest.Encode("query", appType) + } else { + queryParameters["appType"] = autorest.Encode("query", "portal") + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) CreateOrUpdateResponder(resp *http.Response) (result SubscriptionContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified subscription. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// 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. +func (client SubscriptionClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SubscriptionClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, sid, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SubscriptionClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "sid": autorest.Encode("path", sid), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified Subscription entity. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client SubscriptionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result SubscriptionContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SubscriptionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, sid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SubscriptionClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, sid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "sid": autorest.Encode("path", sid), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) GetResponder(resp *http.Response) (result SubscriptionContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the apimanagement subscription specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client SubscriptionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SubscriptionClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, sid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client SubscriptionClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, sid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "sid": autorest.Encode("path", sid), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// List lists all subscriptions of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 | | |
+// top - number of records to return. +// skip - number of records to skip. +func (client SubscriptionClient) List(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result SubscriptionCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.List") + defer func() { + sc := -1 + if result.sc.Response.Response != nil { + sc = result.sc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.SubscriptionClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "List", resp, "Failure sending request") + return + } + + result.sc, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "List", resp, "Failure responding to request") + return + } + if result.sc.hasNextLink() && result.sc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client SubscriptionClient) ListPreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) ListResponder(resp *http.Response) (result SubscriptionCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SubscriptionClient) listNextResults(ctx context.Context, lastResults SubscriptionCollection) (result SubscriptionCollection, err error) { + req, err := lastResults.subscriptionCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionClient) ListComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result SubscriptionCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} + +// ListSecrets gets the specified Subscription keys. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client SubscriptionClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result SubscriptionKeysContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.ListSecrets") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SubscriptionClient", "ListSecrets", err.Error()) + } + + req, err := client.ListSecretsPreparer(ctx, resourceGroupName, serviceName, sid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "ListSecrets", nil, "Failure preparing request") + return + } + + resp, err := client.ListSecretsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "ListSecrets", resp, "Failure sending request") + return + } + + result, err = client.ListSecretsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "ListSecrets", resp, "Failure responding to request") + return + } + + return +} + +// ListSecretsPreparer prepares the ListSecrets request. +func (client SubscriptionClient) ListSecretsPreparer(ctx context.Context, resourceGroupName string, serviceName string, sid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "sid": autorest.Encode("path", sid), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSecretsSender sends the ListSecrets request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) ListSecretsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSecretsResponder handles the response to the ListSecrets request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) ListSecretsResponder(resp *http.Response) (result SubscriptionKeysContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegeneratePrimaryKey regenerates primary key of existing subscription of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client SubscriptionClient) RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.RegeneratePrimaryKey") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SubscriptionClient", "RegeneratePrimaryKey", err.Error()) + } + + req, err := client.RegeneratePrimaryKeyPreparer(ctx, resourceGroupName, serviceName, sid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegeneratePrimaryKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "RegeneratePrimaryKey", resp, "Failure sending request") + return + } + + result, err = client.RegeneratePrimaryKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "RegeneratePrimaryKey", resp, "Failure responding to request") + return + } + + return +} + +// RegeneratePrimaryKeyPreparer prepares the RegeneratePrimaryKey request. +func (client SubscriptionClient) RegeneratePrimaryKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, sid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "sid": autorest.Encode("path", sid), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegeneratePrimaryKeySender sends the RegeneratePrimaryKey request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) RegeneratePrimaryKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegeneratePrimaryKeyResponder handles the response to the RegeneratePrimaryKey request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) RegeneratePrimaryKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// RegenerateSecondaryKey regenerates secondary key of existing subscription of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +func (client SubscriptionClient) RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, sid string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.RegenerateSecondaryKey") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SubscriptionClient", "RegenerateSecondaryKey", err.Error()) + } + + req, err := client.RegenerateSecondaryKeyPreparer(ctx, resourceGroupName, serviceName, sid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateSecondaryKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "RegenerateSecondaryKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateSecondaryKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "RegenerateSecondaryKey", resp, "Failure responding to request") + return + } + + return +} + +// RegenerateSecondaryKeyPreparer prepares the RegenerateSecondaryKey request. +func (client SubscriptionClient) RegenerateSecondaryKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, sid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "sid": autorest.Encode("path", sid), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateSecondaryKeySender sends the RegenerateSecondaryKey request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) RegenerateSecondaryKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegenerateSecondaryKeyResponder handles the response to the RegenerateSecondaryKey request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) RegenerateSecondaryKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates the details of a subscription specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// parameters - update parameters. +// 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. +// notify - 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 +// appType - determines the type of application which send the create user request. Default is legacy publisher +// portal. +func (client SubscriptionClient) Update(ctx context.Context, resourceGroupName string, serviceName string, sid string, parameters SubscriptionUpdateParameters, ifMatch string, notify *bool, appType AppType) (result SubscriptionContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.SubscriptionClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, sid, parameters, ifMatch, notify, appType) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.SubscriptionClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SubscriptionClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, sid string, parameters SubscriptionUpdateParameters, ifMatch string, notify *bool, appType AppType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "sid": autorest.Encode("path", sid), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if notify != nil { + queryParameters["notify"] = autorest.Encode("query", *notify) + } + if len(string(appType)) > 0 { + queryParameters["appType"] = autorest.Encode("query", appType) + } else { + queryParameters["appType"] = autorest.Encode("query", "portal") + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SubscriptionClient) UpdateResponder(resp *http.Response) (result SubscriptionContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tag.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tag.go new file mode 100644 index 000000000000..8d181a8839e0 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tag.go @@ -0,0 +1,2295 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TagClient is the apiManagement Client +type TagClient struct { + BaseClient +} + +// NewTagClient creates an instance of the TagClient client. +func NewTagClient(subscriptionID string) TagClient { + return NewTagClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTagClientWithBaseURI creates an instance of the TagClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTagClientWithBaseURI(baseURI string, subscriptionID string) TagClient { + return TagClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// AssignToAPI assign tag to the Api. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) AssignToAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result TagContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.AssignToAPI") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "AssignToAPI", err.Error()) + } + + req, err := client.AssignToAPIPreparer(ctx, resourceGroupName, serviceName, apiid, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToAPI", nil, "Failure preparing request") + return + } + + resp, err := client.AssignToAPISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToAPI", resp, "Failure sending request") + return + } + + result, err = client.AssignToAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToAPI", resp, "Failure responding to request") + return + } + + return +} + +// AssignToAPIPreparer prepares the AssignToAPI request. +func (client TagClient) AssignToAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AssignToAPISender sends the AssignToAPI request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) AssignToAPISender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// AssignToAPIResponder handles the response to the AssignToAPI request. The method always +// closes the http.Response Body. +func (client TagClient) AssignToAPIResponder(resp *http.Response) (result TagContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// AssignToOperation assign tag to the Operation. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) AssignToOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result TagContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.AssignToOperation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "AssignToOperation", err.Error()) + } + + req, err := client.AssignToOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToOperation", nil, "Failure preparing request") + return + } + + resp, err := client.AssignToOperationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToOperation", resp, "Failure sending request") + return + } + + result, err = client.AssignToOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToOperation", resp, "Failure responding to request") + return + } + + return +} + +// AssignToOperationPreparer prepares the AssignToOperation request. +func (client TagClient) AssignToOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AssignToOperationSender sends the AssignToOperation request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) AssignToOperationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// AssignToOperationResponder handles the response to the AssignToOperation request. The method always +// closes the http.Response Body. +func (client TagClient) AssignToOperationResponder(resp *http.Response) (result TagContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// AssignToProduct assign tag to the Product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) AssignToProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result TagContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.AssignToProduct") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "AssignToProduct", err.Error()) + } + + req, err := client.AssignToProductPreparer(ctx, resourceGroupName, serviceName, productID, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToProduct", nil, "Failure preparing request") + return + } + + resp, err := client.AssignToProductSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToProduct", resp, "Failure sending request") + return + } + + result, err = client.AssignToProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "AssignToProduct", resp, "Failure responding to request") + return + } + + return +} + +// AssignToProductPreparer prepares the AssignToProduct request. +func (client TagClient) AssignToProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AssignToProductSender sends the AssignToProduct request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) AssignToProductSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// AssignToProductResponder handles the response to the AssignToProduct request. The method always +// closes the http.Response Body. +func (client TagClient) AssignToProductResponder(resp *http.Response) (result TagContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates a tag. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// tagID - tag identifier. Must be unique in the current API Management service instance. +// parameters - create parameters. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client TagClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, ifMatch string) (result TagContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TagContractProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TagContractProperties.DisplayName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.TagContractProperties.DisplayName", Name: validation.MaxLength, Rule: 160, Chain: nil}, + {Target: "parameters.TagContractProperties.DisplayName", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, tagID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client TagClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client TagClient) CreateOrUpdateResponder(resp *http.Response) (result TagContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific tag of the API Management service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// 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. +func (client TagClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, tagID, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client TagClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client TagClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DetachFromAPI detach the tag from the Api. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) DetachFromAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.DetachFromAPI") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "DetachFromAPI", err.Error()) + } + + req, err := client.DetachFromAPIPreparer(ctx, resourceGroupName, serviceName, apiid, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromAPI", nil, "Failure preparing request") + return + } + + resp, err := client.DetachFromAPISender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromAPI", resp, "Failure sending request") + return + } + + result, err = client.DetachFromAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromAPI", resp, "Failure responding to request") + return + } + + return +} + +// DetachFromAPIPreparer prepares the DetachFromAPI request. +func (client TagClient) DetachFromAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DetachFromAPISender sends the DetachFromAPI request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) DetachFromAPISender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DetachFromAPIResponder handles the response to the DetachFromAPI request. The method always +// closes the http.Response Body. +func (client TagClient) DetachFromAPIResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DetachFromOperation detach the tag from the Operation. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) DetachFromOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.DetachFromOperation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "DetachFromOperation", err.Error()) + } + + req, err := client.DetachFromOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromOperation", nil, "Failure preparing request") + return + } + + resp, err := client.DetachFromOperationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromOperation", resp, "Failure sending request") + return + } + + result, err = client.DetachFromOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromOperation", resp, "Failure responding to request") + return + } + + return +} + +// DetachFromOperationPreparer prepares the DetachFromOperation request. +func (client TagClient) DetachFromOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DetachFromOperationSender sends the DetachFromOperation request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) DetachFromOperationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DetachFromOperationResponder handles the response to the DetachFromOperation request. The method always +// closes the http.Response Body. +func (client TagClient) DetachFromOperationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DetachFromProduct detach the tag from the Product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) DetachFromProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.DetachFromProduct") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "DetachFromProduct", err.Error()) + } + + req, err := client.DetachFromProductPreparer(ctx, resourceGroupName, serviceName, productID, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromProduct", nil, "Failure preparing request") + return + } + + resp, err := client.DetachFromProductSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromProduct", resp, "Failure sending request") + return + } + + result, err = client.DetachFromProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "DetachFromProduct", resp, "Failure responding to request") + return + } + + return +} + +// DetachFromProductPreparer prepares the DetachFromProduct request. +func (client TagClient) DetachFromProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DetachFromProductSender sends the DetachFromProduct request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) DetachFromProductSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DetachFromProductResponder handles the response to the DetachFromProduct request. The method always +// closes the http.Response Body. +func (client TagClient) DetachFromProductResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the tag specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) Get(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (result TagContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client TagClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TagClient) GetResponder(resp *http.Response) (result TagContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByAPI get tag associated with the API. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) GetByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result TagContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetByAPI") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "GetByAPI", err.Error()) + } + + req, err := client.GetByAPIPreparer(ctx, resourceGroupName, serviceName, apiid, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByAPI", nil, "Failure preparing request") + return + } + + resp, err := client.GetByAPISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByAPI", resp, "Failure sending request") + return + } + + result, err = client.GetByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByAPI", resp, "Failure responding to request") + return + } + + return +} + +// GetByAPIPreparer prepares the GetByAPI request. +func (client TagClient) GetByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByAPISender sends the GetByAPI request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) GetByAPISender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByAPIResponder handles the response to the GetByAPI request. The method always +// closes the http.Response Body. +func (client TagClient) GetByAPIResponder(resp *http.Response) (result TagContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByOperation get tag associated with the Operation. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) GetByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result TagContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetByOperation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "GetByOperation", err.Error()) + } + + req, err := client.GetByOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByOperation", nil, "Failure preparing request") + return + } + + resp, err := client.GetByOperationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByOperation", resp, "Failure sending request") + return + } + + result, err = client.GetByOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByOperation", resp, "Failure responding to request") + return + } + + return +} + +// GetByOperationPreparer prepares the GetByOperation request. +func (client TagClient) GetByOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByOperationSender sends the GetByOperation request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) GetByOperationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByOperationResponder handles the response to the GetByOperation request. The method always +// closes the http.Response Body. +func (client TagClient) GetByOperationResponder(resp *http.Response) (result TagContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByProduct get tag associated with the Product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) GetByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result TagContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetByProduct") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "GetByProduct", err.Error()) + } + + req, err := client.GetByProductPreparer(ctx, resourceGroupName, serviceName, productID, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByProduct", nil, "Failure preparing request") + return + } + + resp, err := client.GetByProductSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByProduct", resp, "Failure sending request") + return + } + + result, err = client.GetByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetByProduct", resp, "Failure responding to request") + return + } + + return +} + +// GetByProductPreparer prepares the GetByProduct request. +func (client TagClient) GetByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByProductSender sends the GetByProduct request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) GetByProductSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByProductResponder handles the response to the GetByProduct request. The method always +// closes the http.Response Body. +func (client TagClient) GetByProductResponder(resp *http.Response) (result TagContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityState gets the entity state version of the tag specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) GetEntityState(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetEntityState") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "GetEntityState", err.Error()) + } + + req, err := client.GetEntityStatePreparer(ctx, resourceGroupName, serviceName, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityState", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityStateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityState", resp, "Failure sending request") + return + } + + result, err = client.GetEntityStateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityState", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityStatePreparer prepares the GetEntityState request. +func (client TagClient) GetEntityStatePreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityStateSender sends the GetEntityState request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) GetEntityStateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityStateResponder handles the response to the GetEntityState request. The method always +// closes the http.Response Body. +func (client TagClient) GetEntityStateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetEntityStateByAPI gets the entity state version of the tag specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) GetEntityStateByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetEntityStateByAPI") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "GetEntityStateByAPI", err.Error()) + } + + req, err := client.GetEntityStateByAPIPreparer(ctx, resourceGroupName, serviceName, apiid, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByAPI", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityStateByAPISender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByAPI", resp, "Failure sending request") + return + } + + result, err = client.GetEntityStateByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByAPI", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityStateByAPIPreparer prepares the GetEntityStateByAPI request. +func (client TagClient) GetEntityStateByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityStateByAPISender sends the GetEntityStateByAPI request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) GetEntityStateByAPISender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityStateByAPIResponder handles the response to the GetEntityStateByAPI request. The method always +// closes the http.Response Body. +func (client TagClient) GetEntityStateByAPIResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetEntityStateByOperation gets the entity state version of the tag specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) GetEntityStateByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetEntityStateByOperation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "GetEntityStateByOperation", err.Error()) + } + + req, err := client.GetEntityStateByOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByOperation", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityStateByOperationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByOperation", resp, "Failure sending request") + return + } + + result, err = client.GetEntityStateByOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByOperation", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityStateByOperationPreparer prepares the GetEntityStateByOperation request. +func (client TagClient) GetEntityStateByOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityStateByOperationSender sends the GetEntityStateByOperation request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) GetEntityStateByOperationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityStateByOperationResponder handles the response to the GetEntityStateByOperation request. The method always +// closes the http.Response Body. +func (client TagClient) GetEntityStateByOperationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetEntityStateByProduct gets the entity state version of the tag specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// tagID - tag identifier. Must be unique in the current API Management service instance. +func (client TagClient) GetEntityStateByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.GetEntityStateByProduct") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "GetEntityStateByProduct", err.Error()) + } + + req, err := client.GetEntityStateByProductPreparer(ctx, resourceGroupName, serviceName, productID, tagID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByProduct", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityStateByProductSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByProduct", resp, "Failure sending request") + return + } + + result, err = client.GetEntityStateByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "GetEntityStateByProduct", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityStateByProductPreparer prepares the GetEntityStateByProduct request. +func (client TagClient) GetEntityStateByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityStateByProductSender sends the GetEntityStateByProduct request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) GetEntityStateByProductSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityStateByProductResponder handles the response to the GetEntityStateByProduct request. The method always +// closes the http.Response Body. +func (client TagClient) GetEntityStateByProductResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByAPI lists all Tags associated with the API. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, +// gt, lt | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client TagClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result TagCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByAPI") + defer func() { + sc := -1 + if result.tc.Response.Response != nil { + sc = result.tc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "ListByAPI", err.Error()) + } + + result.fn = client.listByAPINextResults + req, err := client.ListByAPIPreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByAPI", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAPISender(req) + if err != nil { + result.tc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByAPI", resp, "Failure sending request") + return + } + + result.tc, err = client.ListByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByAPI", resp, "Failure responding to request") + return + } + if result.tc.hasNextLink() && result.tc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAPIPreparer prepares the ListByAPI request. +func (client TagClient) ListByAPIPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAPISender sends the ListByAPI request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) ListByAPISender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAPIResponder handles the response to the ListByAPI request. The method always +// closes the http.Response Body. +func (client TagClient) ListByAPIResponder(resp *http.Response) (result TagCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAPINextResults retrieves the next set of results, if any. +func (client TagClient) listByAPINextResults(ctx context.Context, lastResults TagCollection) (result TagCollection, err error) { + req, err := lastResults.tagCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByAPINextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAPISender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByAPINextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAPIResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByAPINextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAPIComplete enumerates all values, automatically crossing page boundaries as required. +func (client TagClient) ListByAPIComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result TagCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByAPI") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAPI(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) + return +} + +// ListByOperation lists all Tags associated with the Operation. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// operationID - operation identifier within an API. Must be unique in the current API Management service +// instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, +// gt, lt | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client TagClient) ListByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, filter string, top *int32, skip *int32) (result TagCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByOperation") + defer func() { + sc := -1 + if result.tc.Response.Response != nil { + sc = result.tc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, + {TargetValue: operationID, + Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "ListByOperation", err.Error()) + } + + result.fn = client.listByOperationNextResults + req, err := client.ListByOperationPreparer(ctx, resourceGroupName, serviceName, apiid, operationID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByOperation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByOperationSender(req) + if err != nil { + result.tc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByOperation", resp, "Failure sending request") + return + } + + result.tc, err = client.ListByOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByOperation", resp, "Failure responding to request") + return + } + if result.tc.hasNextLink() && result.tc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByOperationPreparer prepares the ListByOperation request. +func (client TagClient) ListByOperationPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByOperationSender sends the ListByOperation request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) ListByOperationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByOperationResponder handles the response to the ListByOperation request. The method always +// closes the http.Response Body. +func (client TagClient) ListByOperationResponder(resp *http.Response) (result TagCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByOperationNextResults retrieves the next set of results, if any. +func (client TagClient) listByOperationNextResults(ctx context.Context, lastResults TagCollection) (result TagCollection, err error) { + req, err := lastResults.tagCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByOperationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByOperationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByOperationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByOperationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByOperationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByOperationComplete enumerates all values, automatically crossing page boundaries as required. +func (client TagClient) ListByOperationComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, operationID string, filter string, top *int32, skip *int32) (result TagCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByOperation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByOperation(ctx, resourceGroupName, serviceName, apiid, operationID, filter, top, skip) + return +} + +// ListByProduct lists all Tags associated with the Product. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// productID - product identifier. Must be unique in the current API Management service instance. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, +// gt, lt | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | +// substringof, contains, startswith, endswith |
+// top - number of records to return. +// skip - number of records to skip. +func (client TagClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result TagCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByProduct") + defer func() { + sc := -1 + if result.tc.Response.Response != nil { + sc = result.tc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: productID, + Constraints: []validation.Constraint{{Target: "productID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "productID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "ListByProduct", err.Error()) + } + + result.fn = client.listByProductNextResults + req, err := client.ListByProductPreparer(ctx, resourceGroupName, serviceName, productID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByProduct", nil, "Failure preparing request") + return + } + + resp, err := client.ListByProductSender(req) + if err != nil { + result.tc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByProduct", resp, "Failure sending request") + return + } + + result.tc, err = client.ListByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByProduct", resp, "Failure responding to request") + return + } + if result.tc.hasNextLink() && result.tc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByProductPreparer prepares the ListByProduct request. +func (client TagClient) ListByProductPreparer(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "productId": autorest.Encode("path", productID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByProductSender sends the ListByProduct request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) ListByProductSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByProductResponder handles the response to the ListByProduct request. The method always +// closes the http.Response Body. +func (client TagClient) ListByProductResponder(resp *http.Response) (result TagCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByProductNextResults retrieves the next set of results, if any. +func (client TagClient) listByProductNextResults(ctx context.Context, lastResults TagCollection) (result TagCollection, err error) { + req, err := lastResults.tagCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByProductNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByProductSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByProductNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByProductResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByProductNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByProductComplete enumerates all values, automatically crossing page boundaries as required. +func (client TagClient) ListByProductComplete(ctx context.Context, resourceGroupName string, serviceName string, productID string, filter string, top *int32, skip *int32) (result TagCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByProduct") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByProduct(ctx, resourceGroupName, serviceName, productID, filter, top, skip) + return +} + +// ListByService lists a collection of tags defined within a service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +// scope - scope like 'apis', 'products' or 'apis/{apiId} +func (client TagClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, scope string) (result TagCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByService") + defer func() { + sc := -1 + if result.tc.Response.Response != nil { + sc = result.tc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.tc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByService", resp, "Failure sending request") + return + } + + result.tc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "ListByService", resp, "Failure responding to request") + return + } + if result.tc.hasNextLink() && result.tc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client TagClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if len(scope) > 0 { + queryParameters["scope"] = autorest.Encode("query", scope) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client TagClient) ListByServiceResponder(resp *http.Response) (result TagCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client TagClient) listByServiceNextResults(ctx context.Context, lastResults TagCollection) (result TagCollection, err error) { + req, err := lastResults.tagCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client TagClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, scope string) (result TagCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip, scope) + return +} + +// Update updates the details of the tag specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// tagID - tag identifier. Must be unique in the current API Management service instance. +// parameters - update parameters. +// 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. +func (client TagClient) Update(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, ifMatch string) (result TagContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: tagID, + Constraints: []validation.Constraint{{Target: "tagID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "tagID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "tagID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TagClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, tagID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client TagClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagId": autorest.Encode("path", tagID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client TagClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client TagClient) UpdateResponder(resp *http.Response) (result TagContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tagresource.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tagresource.go new file mode 100644 index 000000000000..af2be4b98bb0 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tagresource.go @@ -0,0 +1,188 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TagResourceClient is the apiManagement Client +type TagResourceClient struct { + BaseClient +} + +// NewTagResourceClient creates an instance of the TagResourceClient client. +func NewTagResourceClient(subscriptionID string) TagResourceClient { + return NewTagResourceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTagResourceClientWithBaseURI creates an instance of the TagResourceClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTagResourceClientWithBaseURI(baseURI string, subscriptionID string) TagResourceClient { + return TagResourceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByService lists a collection of resources associated with tags. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | Field | Usage | Supported operators | Supported functions +// |
|-------------|-------------|-------------|-------------|
| aid | filter | ge, le, eq, ne, gt, lt +// | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | substringof, +// contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, +// contains, startswith, endswith |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, +// startswith, endswith |
| path | 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 |
| +// method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| urlTemplate | +// 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 | |
| +// isCurrent | filter | eq | |
+// top - number of records to return. +// skip - number of records to skip. +func (client TagResourceClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result TagResourceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagResourceClient.ListByService") + defer func() { + sc := -1 + if result.trc.Response.Response != nil { + sc = result.trc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.TagResourceClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagResourceClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.trc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TagResourceClient", "ListByService", resp, "Failure sending request") + return + } + + result.trc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagResourceClient", "ListByService", resp, "Failure responding to request") + return + } + if result.trc.hasNextLink() && result.trc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client TagResourceClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client TagResourceClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client TagResourceClient) ListByServiceResponder(resp *http.Response) (result TagResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client TagResourceClient) listByServiceNextResults(ctx context.Context, lastResults TagResourceCollection) (result TagResourceCollection, err error) { + req, err := lastResults.tagResourceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.TagResourceClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.TagResourceClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TagResourceClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client TagResourceClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result TagResourceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagResourceClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantaccess.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantaccess.go new file mode 100644 index 000000000000..f57970ab77f5 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantaccess.go @@ -0,0 +1,773 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TenantAccessClient is the apiManagement Client +type TenantAccessClient struct { + BaseClient +} + +// NewTenantAccessClient creates an instance of the TenantAccessClient client. +func NewTenantAccessClient(subscriptionID string) TenantAccessClient { + return NewTenantAccessClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTenantAccessClientWithBaseURI creates an instance of the TenantAccessClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTenantAccessClientWithBaseURI(baseURI string, subscriptionID string) TenantAccessClient { + return TenantAccessClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create update tenant access information details. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - parameters supplied to retrieve the Tenant Access Information. +// accessName - the identifier of the Access configuration. +// 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. +func (client TenantAccessClient) Create(ctx context.Context, resourceGroupName string, serviceName string, parameters AccessInformationCreateParameters, accessName AccessIDName, ifMatch string) (result AccessInformationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serviceName, parameters, accessName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client TenantAccessClient) CreatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters AccessInformationCreateParameters, accessName AccessIDName, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessName": autorest.Encode("path", accessName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client TenantAccessClient) CreateResponder(resp *http.Response) (result AccessInformationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get tenant access information details without secrets. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// accessName - the identifier of the Access configuration. +func (client TenantAccessClient) Get(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result AccessInformationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, accessName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client TenantAccessClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessName": autorest.Encode("path", accessName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TenantAccessClient) GetResponder(resp *http.Response) (result AccessInformationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag tenant access metadata +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// accessName - the identifier of the Access configuration. +func (client TenantAccessClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, accessName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client TenantAccessClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessName": autorest.Encode("path", accessName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client TenantAccessClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByService returns list of access infos - for Git and Management endpoints. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - not used +func (client TenantAccessClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result AccessInformationCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.ListByService") + defer func() { + sc := -1 + if result.aic.Response.Response != nil { + sc = result.aic.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.aic.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListByService", resp, "Failure sending request") + return + } + + result.aic, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListByService", resp, "Failure responding to request") + return + } + if result.aic.hasNextLink() && result.aic.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client TenantAccessClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client TenantAccessClient) ListByServiceResponder(resp *http.Response) (result AccessInformationCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client TenantAccessClient) listByServiceNextResults(ctx context.Context, lastResults AccessInformationCollection) (result AccessInformationCollection, err error) { + req, err := lastResults.accessInformationCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client TenantAccessClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result AccessInformationCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter) + return +} + +// ListSecrets get tenant access information details. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// accessName - the identifier of the Access configuration. +func (client TenantAccessClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result AccessInformationSecretsContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.ListSecrets") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessClient", "ListSecrets", err.Error()) + } + + req, err := client.ListSecretsPreparer(ctx, resourceGroupName, serviceName, accessName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListSecrets", nil, "Failure preparing request") + return + } + + resp, err := client.ListSecretsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListSecrets", resp, "Failure sending request") + return + } + + result, err = client.ListSecretsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "ListSecrets", resp, "Failure responding to request") + return + } + + return +} + +// ListSecretsPreparer prepares the ListSecrets request. +func (client TenantAccessClient) ListSecretsPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessName": autorest.Encode("path", accessName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSecretsSender sends the ListSecrets request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessClient) ListSecretsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSecretsResponder handles the response to the ListSecrets request. The method always +// closes the http.Response Body. +func (client TenantAccessClient) ListSecretsResponder(resp *http.Response) (result AccessInformationSecretsContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegeneratePrimaryKey regenerate primary access key +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// accessName - the identifier of the Access configuration. +func (client TenantAccessClient) RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.RegeneratePrimaryKey") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessClient", "RegeneratePrimaryKey", err.Error()) + } + + req, err := client.RegeneratePrimaryKeyPreparer(ctx, resourceGroupName, serviceName, accessName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegeneratePrimaryKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", resp, "Failure sending request") + return + } + + result, err = client.RegeneratePrimaryKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegeneratePrimaryKey", resp, "Failure responding to request") + return + } + + return +} + +// RegeneratePrimaryKeyPreparer prepares the RegeneratePrimaryKey request. +func (client TenantAccessClient) RegeneratePrimaryKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessName": autorest.Encode("path", accessName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegeneratePrimaryKeySender sends the RegeneratePrimaryKey request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessClient) RegeneratePrimaryKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegeneratePrimaryKeyResponder handles the response to the RegeneratePrimaryKey request. The method always +// closes the http.Response Body. +func (client TenantAccessClient) RegeneratePrimaryKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// RegenerateSecondaryKey regenerate secondary access key +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// accessName - the identifier of the Access configuration. +func (client TenantAccessClient) RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.RegenerateSecondaryKey") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessClient", "RegenerateSecondaryKey", err.Error()) + } + + req, err := client.RegenerateSecondaryKeyPreparer(ctx, resourceGroupName, serviceName, accessName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateSecondaryKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateSecondaryKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "RegenerateSecondaryKey", resp, "Failure responding to request") + return + } + + return +} + +// RegenerateSecondaryKeyPreparer prepares the RegenerateSecondaryKey request. +func (client TenantAccessClient) RegenerateSecondaryKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessName": autorest.Encode("path", accessName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateSecondaryKeySender sends the RegenerateSecondaryKey request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessClient) RegenerateSecondaryKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegenerateSecondaryKeyResponder handles the response to the RegenerateSecondaryKey request. The method always +// closes the http.Response Body. +func (client TenantAccessClient) RegenerateSecondaryKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update update tenant access information details. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - parameters supplied to retrieve the Tenant Access Information. +// accessName - the identifier of the Access configuration. +// 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. +func (client TenantAccessClient) Update(ctx context.Context, resourceGroupName string, serviceName string, parameters AccessInformationUpdateParameters, accessName AccessIDName, ifMatch string) (result AccessInformationContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, parameters, accessName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client TenantAccessClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters AccessInformationUpdateParameters, accessName AccessIDName, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessName": autorest.Encode("path", accessName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client TenantAccessClient) UpdateResponder(resp *http.Response) (result AccessInformationContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantaccessgit.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantaccessgit.go new file mode 100644 index 000000000000..326d292fc073 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantaccessgit.go @@ -0,0 +1,202 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TenantAccessGitClient is the apiManagement Client +type TenantAccessGitClient struct { + BaseClient +} + +// NewTenantAccessGitClient creates an instance of the TenantAccessGitClient client. +func NewTenantAccessGitClient(subscriptionID string) TenantAccessGitClient { + return NewTenantAccessGitClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTenantAccessGitClientWithBaseURI creates an instance of the TenantAccessGitClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTenantAccessGitClientWithBaseURI(baseURI string, subscriptionID string) TenantAccessGitClient { + return TenantAccessGitClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// RegeneratePrimaryKey regenerate primary access key for GIT. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// accessName - the identifier of the Access configuration. +func (client TenantAccessGitClient) RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessGitClient.RegeneratePrimaryKey") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessGitClient", "RegeneratePrimaryKey", err.Error()) + } + + req, err := client.RegeneratePrimaryKeyPreparer(ctx, resourceGroupName, serviceName, accessName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegeneratePrimaryKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegeneratePrimaryKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegeneratePrimaryKey", resp, "Failure sending request") + return + } + + result, err = client.RegeneratePrimaryKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegeneratePrimaryKey", resp, "Failure responding to request") + return + } + + return +} + +// RegeneratePrimaryKeyPreparer prepares the RegeneratePrimaryKey request. +func (client TenantAccessGitClient) RegeneratePrimaryKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessName": autorest.Encode("path", accessName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegeneratePrimaryKeySender sends the RegeneratePrimaryKey request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessGitClient) RegeneratePrimaryKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegeneratePrimaryKeyResponder handles the response to the RegeneratePrimaryKey request. The method always +// closes the http.Response Body. +func (client TenantAccessGitClient) RegeneratePrimaryKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// RegenerateSecondaryKey regenerate secondary access key for GIT. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// accessName - the identifier of the Access configuration. +func (client TenantAccessGitClient) RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantAccessGitClient.RegenerateSecondaryKey") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantAccessGitClient", "RegenerateSecondaryKey", err.Error()) + } + + req, err := client.RegenerateSecondaryKeyPreparer(ctx, resourceGroupName, serviceName, accessName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegenerateSecondaryKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateSecondaryKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegenerateSecondaryKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateSecondaryKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantAccessGitClient", "RegenerateSecondaryKey", resp, "Failure responding to request") + return + } + + return +} + +// RegenerateSecondaryKeyPreparer prepares the RegenerateSecondaryKey request. +func (client TenantAccessGitClient) RegenerateSecondaryKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessName": autorest.Encode("path", accessName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateSecondaryKeySender sends the RegenerateSecondaryKey request. The method will close the +// http.Response Body if it receives an error. +func (client TenantAccessGitClient) RegenerateSecondaryKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegenerateSecondaryKeyResponder handles the response to the RegenerateSecondaryKey request. The method always +// closes the http.Response Body. +func (client TenantAccessGitClient) RegenerateSecondaryKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantconfiguration.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantconfiguration.go new file mode 100644 index 000000000000..536fc016cc0d --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantconfiguration.go @@ -0,0 +1,401 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TenantConfigurationClient is the apiManagement Client +type TenantConfigurationClient struct { + BaseClient +} + +// NewTenantConfigurationClient creates an instance of the TenantConfigurationClient client. +func NewTenantConfigurationClient(subscriptionID string) TenantConfigurationClient { + return NewTenantConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTenantConfigurationClientWithBaseURI creates an instance of the TenantConfigurationClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewTenantConfigurationClientWithBaseURI(baseURI string, subscriptionID string) TenantConfigurationClient { + return TenantConfigurationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Deploy this operation applies changes from the specified Git branch to the configuration database. This is a long +// running operation and could take several minutes to complete. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - deploy Configuration parameters. +func (client TenantConfigurationClient) Deploy(ctx context.Context, resourceGroupName string, serviceName string, parameters DeployConfigurationParameters) (result TenantConfigurationDeployFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantConfigurationClient.Deploy") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DeployConfigurationParameterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DeployConfigurationParameterProperties.Branch", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantConfigurationClient", "Deploy", err.Error()) + } + + req, err := client.DeployPreparer(ctx, resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Deploy", nil, "Failure preparing request") + return + } + + result, err = client.DeploySender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Deploy", nil, "Failure sending request") + return + } + + return +} + +// DeployPreparer prepares the Deploy request. +func (client TenantConfigurationClient) DeployPreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters DeployConfigurationParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", "configuration"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeploySender sends the Deploy request. The method will close the +// http.Response Body if it receives an error. +func (client TenantConfigurationClient) DeploySender(req *http.Request) (future TenantConfigurationDeployFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeployResponder handles the response to the Deploy request. The method always +// closes the http.Response Body. +func (client TenantConfigurationClient) DeployResponder(resp *http.Response) (result OperationResultContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSyncState gets the status of the most recent synchronization between the configuration database and the Git +// repository. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client TenantConfigurationClient) GetSyncState(ctx context.Context, resourceGroupName string, serviceName string) (result TenantConfigurationSyncStateContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantConfigurationClient.GetSyncState") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantConfigurationClient", "GetSyncState", err.Error()) + } + + req, err := client.GetSyncStatePreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "GetSyncState", nil, "Failure preparing request") + return + } + + resp, err := client.GetSyncStateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "GetSyncState", resp, "Failure sending request") + return + } + + result, err = client.GetSyncStateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "GetSyncState", resp, "Failure responding to request") + return + } + + return +} + +// GetSyncStatePreparer prepares the GetSyncState request. +func (client TenantConfigurationClient) GetSyncStatePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", "configuration"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSyncStateSender sends the GetSyncState request. The method will close the +// http.Response Body if it receives an error. +func (client TenantConfigurationClient) GetSyncStateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSyncStateResponder handles the response to the GetSyncState request. The method always +// closes the http.Response Body. +func (client TenantConfigurationClient) GetSyncStateResponder(resp *http.Response) (result TenantConfigurationSyncStateContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Save this operation creates a commit with the current configuration snapshot to the specified branch in the +// repository. This is a long running operation and could take several minutes to complete. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - save Configuration parameters. +func (client TenantConfigurationClient) Save(ctx context.Context, resourceGroupName string, serviceName string, parameters SaveConfigurationParameter) (result TenantConfigurationSaveFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantConfigurationClient.Save") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SaveConfigurationParameterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SaveConfigurationParameterProperties.Branch", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantConfigurationClient", "Save", err.Error()) + } + + req, err := client.SavePreparer(ctx, resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Save", nil, "Failure preparing request") + return + } + + result, err = client.SaveSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Save", nil, "Failure sending request") + return + } + + return +} + +// SavePreparer prepares the Save request. +func (client TenantConfigurationClient) SavePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters SaveConfigurationParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", "configuration"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SaveSender sends the Save request. The method will close the +// http.Response Body if it receives an error. +func (client TenantConfigurationClient) SaveSender(req *http.Request) (future TenantConfigurationSaveFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// SaveResponder handles the response to the Save request. The method always +// closes the http.Response Body. +func (client TenantConfigurationClient) SaveResponder(resp *http.Response) (result OperationResultContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Validate this operation validates the changes in the specified Git branch. This is a long running operation and +// could take several minutes to complete. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// parameters - validate Configuration parameters. +func (client TenantConfigurationClient) Validate(ctx context.Context, resourceGroupName string, serviceName string, parameters DeployConfigurationParameters) (result TenantConfigurationValidateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantConfigurationClient.Validate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DeployConfigurationParameterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DeployConfigurationParameterProperties.Branch", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantConfigurationClient", "Validate", err.Error()) + } + + req, err := client.ValidatePreparer(ctx, resourceGroupName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Validate", nil, "Failure preparing request") + return + } + + result, err = client.ValidateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationClient", "Validate", nil, "Failure sending request") + return + } + + return +} + +// ValidatePreparer prepares the Validate request. +func (client TenantConfigurationClient) ValidatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters DeployConfigurationParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", "configuration"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateSender sends the Validate request. The method will close the +// http.Response Body if it receives an error. +func (client TenantConfigurationClient) ValidateSender(req *http.Request) (future TenantConfigurationValidateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ValidateResponder handles the response to the Validate request. The method always +// closes the http.Response Body. +func (client TenantConfigurationClient) ValidateResponder(resp *http.Response) (result OperationResultContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantsettings.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantsettings.go new file mode 100644 index 000000000000..b51128b14531 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/tenantsettings.go @@ -0,0 +1,247 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TenantSettingsClient is the apiManagement Client +type TenantSettingsClient struct { + BaseClient +} + +// NewTenantSettingsClient creates an instance of the TenantSettingsClient client. +func NewTenantSettingsClient(subscriptionID string) TenantSettingsClient { + return NewTenantSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTenantSettingsClientWithBaseURI creates an instance of the TenantSettingsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTenantSettingsClientWithBaseURI(baseURI string, subscriptionID string) TenantSettingsClient { + return TenantSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get tenant settings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client TenantSettingsClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result TenantSettingsContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client TenantSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "settingsType": autorest.Encode("path", "public"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TenantSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TenantSettingsClient) GetResponder(resp *http.Response) (result TenantSettingsContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService public settings. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - not used +func (client TenantSettingsClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result TenantSettingsCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantSettingsClient.ListByService") + defer func() { + sc := -1 + if result.tsc.Response.Response != nil { + sc = result.tsc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.TenantSettingsClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantSettingsClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.tsc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.TenantSettingsClient", "ListByService", resp, "Failure sending request") + return + } + + result.tsc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantSettingsClient", "ListByService", resp, "Failure responding to request") + return + } + if result.tsc.hasNextLink() && result.tsc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client TenantSettingsClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client TenantSettingsClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client TenantSettingsClient) ListByServiceResponder(resp *http.Response) (result TenantSettingsCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client TenantSettingsClient) listByServiceNextResults(ctx context.Context, lastResults TenantSettingsCollection) (result TenantSettingsCollection, err error) { + req, err := lastResults.tenantSettingsCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.TenantSettingsClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.TenantSettingsClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.TenantSettingsClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client TenantSettingsClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string) (result TenantSettingsCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantSettingsClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/user.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/user.go new file mode 100644 index 000000000000..9ad9f20bea34 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/user.go @@ -0,0 +1,866 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UserClient is the apiManagement Client +type UserClient struct { + BaseClient +} + +// NewUserClient creates an instance of the UserClient client. +func NewUserClient(subscriptionID string) UserClient { + return NewUserClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUserClientWithBaseURI creates an instance of the UserClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewUserClientWithBaseURI(baseURI string, subscriptionID string) UserClient { + return UserClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or Updates a user. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +// parameters - create or update parameters. +// notify - send an Email notification to the User. +// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. +func (client UserClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserCreateParameters, notify *bool, ifMatch string) (result UserContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.UserCreateParameterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.UserCreateParameterProperties.Email", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.UserCreateParameterProperties.Email", Name: validation.MaxLength, Rule: 254, Chain: nil}, + {Target: "parameters.UserCreateParameterProperties.Email", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + {Target: "parameters.UserCreateParameterProperties.FirstName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.UserCreateParameterProperties.FirstName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "parameters.UserCreateParameterProperties.FirstName", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + {Target: "parameters.UserCreateParameterProperties.LastName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.UserCreateParameterProperties.LastName", Name: validation.MaxLength, Rule: 100, Chain: nil}, + {Target: "parameters.UserCreateParameterProperties.LastName", Name: validation.MinLength, Rule: 1, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, userID, parameters, notify, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client UserClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserCreateParameters, notify *bool, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if notify != nil { + queryParameters["notify"] = autorest.Encode("query", *notify) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client UserClient) CreateOrUpdateResponder(resp *http.Response) (result UserContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes specific user. +// Parameters: +// resourceGroupName - the name of the resource group. +// 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. +// deleteSubscriptions - whether to delete user's subscription or not. +// notify - send an Account Closed Email notification to the User. +// appType - determines the type of application which send the create user request. Default is legacy publisher +// portal. +func (client UserClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, deleteSubscriptions *bool, notify *bool, appType AppType) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, userID, ifMatch, deleteSubscriptions, notify, appType) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client UserClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, deleteSubscriptions *bool, notify *bool, appType AppType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if deleteSubscriptions != nil { + queryParameters["deleteSubscriptions"] = autorest.Encode("query", *deleteSubscriptions) + } + if notify != nil { + queryParameters["notify"] = autorest.Encode("query", *notify) + } + if len(string(appType)) > 0 { + queryParameters["appType"] = autorest.Encode("query", appType) + } else { + queryParameters["appType"] = autorest.Encode("query", "portal") + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client UserClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateSsoURL retrieves a redirection URL containing an authentication token for signing a given user into the +// developer portal. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +func (client UserClient) GenerateSsoURL(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result GenerateSsoURLResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.GenerateSsoURL") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "GenerateSsoURL", err.Error()) + } + + req, err := client.GenerateSsoURLPreparer(ctx, resourceGroupName, serviceName, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GenerateSsoURL", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateSsoURLSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GenerateSsoURL", resp, "Failure sending request") + return + } + + result, err = client.GenerateSsoURLResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GenerateSsoURL", resp, "Failure responding to request") + return + } + + return +} + +// GenerateSsoURLPreparer prepares the GenerateSsoURL request. +func (client UserClient) GenerateSsoURLPreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateSsoURLSender sends the GenerateSsoURL request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) GenerateSsoURLSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateSsoURLResponder handles the response to the GenerateSsoURL request. The method always +// closes the http.Response Body. +func (client UserClient) GenerateSsoURLResponder(resp *http.Response) (result GenerateSsoURLResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the details of the user specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +func (client UserClient) Get(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result UserContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client UserClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client UserClient) GetResponder(resp *http.Response) (result UserContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEntityTag gets the entity state (Etag) version of the user specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +func (client UserClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.GetEntityTag") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "GetEntityTag", err.Error()) + } + + req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetEntityTag", nil, "Failure preparing request") + return + } + + resp, err := client.GetEntityTagSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetEntityTag", resp, "Failure sending request") + return + } + + result, err = client.GetEntityTagResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetEntityTag", resp, "Failure responding to request") + return + } + + return +} + +// GetEntityTagPreparer prepares the GetEntityTag request. +func (client UserClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEntityTagSender sends the GetEntityTag request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetEntityTagResponder handles the response to the GetEntityTag request. The method always +// closes the http.Response Body. +func (client UserClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetSharedAccessToken gets the Shared Access Authorization Token for the User. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +// parameters - create Authorization Token parameters. +func (client UserClient) GetSharedAccessToken(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserTokenParameters) (result UserTokenResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.GetSharedAccessToken") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.UserTokenParameterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.UserTokenParameterProperties.Expiry", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "GetSharedAccessToken", err.Error()) + } + + req, err := client.GetSharedAccessTokenPreparer(ctx, resourceGroupName, serviceName, userID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetSharedAccessToken", nil, "Failure preparing request") + return + } + + resp, err := client.GetSharedAccessTokenSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetSharedAccessToken", resp, "Failure sending request") + return + } + + result, err = client.GetSharedAccessTokenResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetSharedAccessToken", resp, "Failure responding to request") + return + } + + return +} + +// GetSharedAccessTokenPreparer prepares the GetSharedAccessToken request. +func (client UserClient) GetSharedAccessTokenPreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserTokenParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSharedAccessTokenSender sends the GetSharedAccessToken request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) GetSharedAccessTokenSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSharedAccessTokenResponder handles the response to the GetSharedAccessToken request. The method always +// closes the http.Response Body. +func (client UserClient) GetSharedAccessTokenResponder(resp *http.Response) (result UserTokenResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists a collection of registered users in the specified service instance. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// filter - | 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 |
| state | filter | eq | |
| registrationDate | filter | ge, le, +// eq, ne, gt, lt | |
| note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, +// endswith |
| groups | expand | | |
+// top - number of records to return. +// skip - number of records to skip. +// expandGroups - detailed Group in response. +func (client UserClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool) (result UserCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.ListByService") + defer func() { + sc := -1 + if result.uc.Response.Response != nil { + sc = result.uc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "ListByService", err.Error()) + } + + result.fn = client.listByServiceNextResults + req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, filter, top, skip, expandGroups) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.uc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "ListByService", resp, "Failure sending request") + return + } + + result.uc, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "ListByService", resp, "Failure responding to request") + return + } + if result.uc.hasNextLink() && result.uc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client UserClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if expandGroups != nil { + queryParameters["expandGroups"] = autorest.Encode("query", *expandGroups) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client UserClient) ListByServiceResponder(resp *http.Response) (result UserCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServiceNextResults retrieves the next set of results, if any. +func (client UserClient) listByServiceNextResults(ctx context.Context, lastResults UserCollection) (result UserCollection, err error) { + req, err := lastResults.userCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.UserClient", "listByServiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.UserClient", "listByServiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "listByServiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client UserClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32, expandGroups *bool) (result UserCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.ListByService") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, filter, top, skip, expandGroups) + return +} + +// Update updates the details of the user specified by its identifier. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +// parameters - update parameters. +// 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. +func (client UserClient) Update(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserUpdateParameters, ifMatch string) (result UserContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, userID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client UserClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserUpdateParameters, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client UserClient) UpdateResponder(resp *http.Response) (result UserContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/userconfirmationpassword.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/userconfirmationpassword.go new file mode 100644 index 000000000000..c01eaeed7730 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/userconfirmationpassword.go @@ -0,0 +1,128 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UserConfirmationPasswordClient is the apiManagement Client +type UserConfirmationPasswordClient struct { + BaseClient +} + +// NewUserConfirmationPasswordClient creates an instance of the UserConfirmationPasswordClient client. +func NewUserConfirmationPasswordClient(subscriptionID string) UserConfirmationPasswordClient { + return NewUserConfirmationPasswordClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUserConfirmationPasswordClientWithBaseURI creates an instance of the UserConfirmationPasswordClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewUserConfirmationPasswordClientWithBaseURI(baseURI string, subscriptionID string) UserConfirmationPasswordClient { + return UserConfirmationPasswordClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// SendMethod sends confirmation +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +// appType - determines the type of application which send the create user request. Default is legacy publisher +// portal. +func (client UserConfirmationPasswordClient) SendMethod(ctx context.Context, resourceGroupName string, serviceName string, userID string, appType AppType) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserConfirmationPasswordClient.SendMethod") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserConfirmationPasswordClient", "SendMethod", err.Error()) + } + + req, err := client.SendMethodPreparer(ctx, resourceGroupName, serviceName, userID, appType) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserConfirmationPasswordClient", "SendMethod", nil, "Failure preparing request") + return + } + + resp, err := client.SendMethodSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.UserConfirmationPasswordClient", "SendMethod", resp, "Failure sending request") + return + } + + result, err = client.SendMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserConfirmationPasswordClient", "SendMethod", resp, "Failure responding to request") + return + } + + return +} + +// SendMethodPreparer prepares the SendMethod request. +func (client UserConfirmationPasswordClient) SendMethodPreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string, appType AppType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(appType)) > 0 { + queryParameters["appType"] = autorest.Encode("query", appType) + } else { + queryParameters["appType"] = autorest.Encode("query", "portal") + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SendMethodSender sends the SendMethod request. The method will close the +// http.Response Body if it receives an error. +func (client UserConfirmationPasswordClient) SendMethodSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// SendMethodResponder handles the response to the SendMethod request. The method always +// closes the http.Response Body. +func (client UserConfirmationPasswordClient) SendMethodResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/usergroup.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/usergroup.go new file mode 100644 index 000000000000..9473cafd0dc0 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/usergroup.go @@ -0,0 +1,185 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UserGroupClient is the apiManagement Client +type UserGroupClient struct { + BaseClient +} + +// NewUserGroupClient creates an instance of the UserGroupClient client. +func NewUserGroupClient(subscriptionID string) UserGroupClient { + return NewUserGroupClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUserGroupClientWithBaseURI creates an instance of the UserGroupClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewUserGroupClientWithBaseURI(baseURI string, subscriptionID string) UserGroupClient { + return UserGroupClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all user groups. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +func (client UserGroupClient) List(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (result GroupCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserGroupClient.List") + defer func() { + sc := -1 + if result.gc.Response.Response != nil { + sc = result.gc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.UserGroupClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, serviceName, userID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserGroupClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.gc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserGroupClient", "List", resp, "Failure sending request") + return + } + + result.gc, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserGroupClient", "List", resp, "Failure responding to request") + return + } + if result.gc.hasNextLink() && result.gc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client UserGroupClient) ListPreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client UserGroupClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UserGroupClient) ListResponder(resp *http.Response) (result GroupCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client UserGroupClient) listNextResults(ctx context.Context, lastResults GroupCollection) (result GroupCollection, err error) { + req, err := lastResults.groupCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.UserGroupClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.UserGroupClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserGroupClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client UserGroupClient) ListComplete(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (result GroupCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserGroupClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, serviceName, userID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/useridentities.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/useridentities.go new file mode 100644 index 000000000000..809eeeab4a81 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/useridentities.go @@ -0,0 +1,163 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UserIdentitiesClient is the apiManagement Client +type UserIdentitiesClient struct { + BaseClient +} + +// NewUserIdentitiesClient creates an instance of the UserIdentitiesClient client. +func NewUserIdentitiesClient(subscriptionID string) UserIdentitiesClient { + return NewUserIdentitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUserIdentitiesClientWithBaseURI creates an instance of the UserIdentitiesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewUserIdentitiesClientWithBaseURI(baseURI string, subscriptionID string) UserIdentitiesClient { + return UserIdentitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list of all user identities. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +func (client UserIdentitiesClient) List(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result UserIdentityCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserIdentitiesClient.List") + defer func() { + sc := -1 + if result.uic.Response.Response != nil { + sc = result.uic.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserIdentitiesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, serviceName, userID) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.uic.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "List", resp, "Failure sending request") + return + } + + result.uic, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "List", resp, "Failure responding to request") + return + } + if result.uic.hasNextLink() && result.uic.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client UserIdentitiesClient) ListPreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client UserIdentitiesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UserIdentitiesClient) ListResponder(resp *http.Response) (result UserIdentityCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client UserIdentitiesClient) listNextResults(ctx context.Context, lastResults UserIdentityCollection) (result UserIdentityCollection, err error) { + req, err := lastResults.userIdentityCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserIdentitiesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client UserIdentitiesClient) ListComplete(ctx context.Context, resourceGroupName string, serviceName string, userID string) (result UserIdentityCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserIdentitiesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, serviceName, userID) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/usersubscription.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/usersubscription.go new file mode 100644 index 000000000000..b2b192afd7cc --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/usersubscription.go @@ -0,0 +1,285 @@ +package apimanagement + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UserSubscriptionClient is the apiManagement Client +type UserSubscriptionClient struct { + BaseClient +} + +// NewUserSubscriptionClient creates an instance of the UserSubscriptionClient client. +func NewUserSubscriptionClient(subscriptionID string) UserSubscriptionClient { + return NewUserSubscriptionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUserSubscriptionClientWithBaseURI creates an instance of the UserSubscriptionClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewUserSubscriptionClientWithBaseURI(baseURI string, subscriptionID string) UserSubscriptionClient { + return UserSubscriptionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the specified Subscription entity associated with a particular user. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user 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. +func (client UserSubscriptionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, userID string, sid string) (result SubscriptionContract, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSubscriptionClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: sid, + Constraints: []validation.Constraint{{Target: "sid", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "sid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserSubscriptionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, userID, sid) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client UserSubscriptionClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string, sid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "sid": autorest.Encode("path", sid), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client UserSubscriptionClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client UserSubscriptionClient) GetResponder(resp *http.Response) (result SubscriptionContract, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the collection of subscriptions of the specified user. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// userID - user identifier. Must be unique in the current API Management service instance. +// filter - | 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 |
+// top - number of records to return. +// skip - number of records to skip. +func (client UserSubscriptionClient) List(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (result SubscriptionCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSubscriptionClient.List") + defer func() { + sc := -1 + if result.sc.Response.Response != nil { + sc = result.sc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: userID, + Constraints: []validation.Constraint{{Target: "userID", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "userID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}, + {TargetValue: skip, + Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}}); err != nil { + return result, validation.NewError("apimanagement.UserSubscriptionClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, serviceName, userID, filter, top, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionClient", "List", resp, "Failure sending request") + return + } + + result.sc, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionClient", "List", resp, "Failure responding to request") + return + } + if result.sc.hasNextLink() && result.sc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client UserSubscriptionClient) ListPreparer(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userId": autorest.Encode("path", userID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client UserSubscriptionClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UserSubscriptionClient) ListResponder(resp *http.Response) (result SubscriptionCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client UserSubscriptionClient) listNextResults(ctx context.Context, lastResults SubscriptionCollection) (result SubscriptionCollection, err error) { + req, err := lastResults.subscriptionCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserSubscriptionClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client UserSubscriptionClient) ListComplete(ctx context.Context, resourceGroupName string, serviceName string, userID string, filter string, top *int32, skip *int32) (result SubscriptionCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserSubscriptionClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, serviceName, userID, filter, top, skip) + return +} diff --git a/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/version.go b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/version.go new file mode 100644 index 000000000000..17d790ec9553 --- /dev/null +++ b/services/preview/apimanagement/mgmt/2021-01-01-preview/apimanagement/version.go @@ -0,0 +1,19 @@ +package apimanagement + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " apimanagement/2021-01-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/CHANGELOG.md b/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/CHANGELOG.md index 52911e4cc5e4..d06c103f0c6a 100644 --- a/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/CHANGELOG.md +++ b/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/CHANGELOG.md @@ -1,2 +1,9 @@ # Change History +## Additive Changes + +### Struct Changes + +#### New Struct Fields + +1. ConfigurationStorePropertiesUpdateParameters.PublicNetworkAccess diff --git a/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/_meta.json b/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/_meta.json index 38552069bd8e..c93511a16808 100644 --- a/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/_meta.json +++ b/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/_meta.json @@ -1,5 +1,5 @@ { - "commit": "5fcc6854765009e891052653b304cfe80353430a", + "commit": "b548283ea6f4b3d797e85432fcc6e3ff2a2ac224", "readme": "/_/azure-rest-api-specs/specification/appconfiguration/resource-manager/readme.md", "tag": "package-2021-03-01-preview", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/models.go b/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/models.go index 823efbf815c5..dab726bbfac5 100644 --- a/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/models.go +++ b/services/preview/appconfiguration/mgmt/2021-03-01-preview/appconfiguration/models.go @@ -570,6 +570,8 @@ type ConfigurationStorePropertiesUpdateParameters struct { Encryption *EncryptionProperties `json:"encryption,omitempty"` // DisableLocalAuth - Disables all authentication methods other than AAD authentication. DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + // PublicNetworkAccess - Control permission for data plane traffic coming from public networks while private endpoint is enabled. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` } // ConfigurationStoresCreateFuture an abstraction for monitoring and retrieving the results of a diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/CHANGELOG.md b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/_meta.json b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/_meta.json new file mode 100644 index 000000000000..3473d6428b7c --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "b548283ea6f4b3d797e85432fcc6e3ff2a2ac224", + "readme": "/_/azure-rest-api-specs/specification/applicationinsights/resource-manager/readme.md", + "tag": "package-2020-02-02", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2020-02-02 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/applicationinsights/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/analyticsitems.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/analyticsitems.go new file mode 100644 index 000000000000..2e08deb5b096 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/analyticsitems.go @@ -0,0 +1,429 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AnalyticsItemsClient is the composite Swagger for Application Insights Management Client +type AnalyticsItemsClient struct { + BaseClient +} + +// NewAnalyticsItemsClient creates an instance of the AnalyticsItemsClient client. +func NewAnalyticsItemsClient(subscriptionID string) AnalyticsItemsClient { + return NewAnalyticsItemsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAnalyticsItemsClientWithBaseURI creates an instance of the AnalyticsItemsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAnalyticsItemsClientWithBaseURI(baseURI string, subscriptionID string) AnalyticsItemsClient { + return AnalyticsItemsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a specific Analytics Items defined within an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// scopePath - enum indicating if this item definition is owned by a specific user or is shared between all +// users with access to the Application Insights component. +// ID - the Id of a specific item defined in the Application Insights component +// name - the name of a specific item defined in the Application Insights component +func (client AnalyticsItemsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AnalyticsItemsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, scopePath, ID, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AnalyticsItemsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "scopePath": autorest.Encode("path", scopePath), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(ID) > 0 { + queryParameters["id"] = autorest.Encode("query", ID) + } + if len(name) > 0 { + queryParameters["name"] = autorest.Encode("query", name) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AnalyticsItemsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AnalyticsItemsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a specific Analytics Items defined within an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// scopePath - enum indicating if this item definition is owned by a specific user or is shared between all +// users with access to the Application Insights component. +// ID - the Id of a specific item defined in the Application Insights component +// name - the name of a specific item defined in the Application Insights component +func (client AnalyticsItemsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (result ApplicationInsightsComponentAnalyticsItem, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AnalyticsItemsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, scopePath, ID, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AnalyticsItemsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, ID string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "scopePath": autorest.Encode("path", scopePath), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(ID) > 0 { + queryParameters["id"] = autorest.Encode("query", ID) + } + if len(name) > 0 { + queryParameters["name"] = autorest.Encode("query", name) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AnalyticsItemsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AnalyticsItemsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentAnalyticsItem, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of Analytics Items defined within an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// scopePath - enum indicating if this item definition is owned by a specific user or is shared between all +// users with access to the Application Insights component. +// scope - enum indicating if this item definition is owned by a specific user or is shared between all users +// with access to the Application Insights component. +// typeParameter - enum indicating the type of the Analytics item. +// includeContent - flag indicating whether or not to return the content of each applicable item. If false, +// only return the item information. +func (client AnalyticsItemsClient) List(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, scope ItemScope, typeParameter ItemTypeParameter, includeContent *bool) (result ListApplicationInsightsComponentAnalyticsItem, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AnalyticsItemsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName, scopePath, scope, typeParameter, includeContent) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AnalyticsItemsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, scope ItemScope, typeParameter ItemTypeParameter, includeContent *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "scopePath": autorest.Encode("path", scopePath), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(scope)) > 0 { + queryParameters["scope"] = autorest.Encode("query", scope) + } else { + queryParameters["scope"] = autorest.Encode("query", "shared") + } + if len(string(typeParameter)) > 0 { + queryParameters["type"] = autorest.Encode("query", typeParameter) + } else { + queryParameters["type"] = autorest.Encode("query", "none") + } + if includeContent != nil { + queryParameters["includeContent"] = autorest.Encode("query", *includeContent) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AnalyticsItemsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AnalyticsItemsClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentAnalyticsItem, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Put adds or Updates a specific Analytics Item within an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// scopePath - enum indicating if this item definition is owned by a specific user or is shared between all +// users with access to the Application Insights component. +// itemProperties - properties that need to be specified to create a new item and add it to an Application +// Insights component. +// overrideItem - flag indicating whether or not to force save an item. This allows overriding an item if it +// already exists. +func (client AnalyticsItemsClient) Put(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, itemProperties ApplicationInsightsComponentAnalyticsItem, overrideItem *bool) (result ApplicationInsightsComponentAnalyticsItem, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AnalyticsItemsClient.Put") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AnalyticsItemsClient", "Put", err.Error()) + } + + req, err := client.PutPreparer(ctx, resourceGroupName, resourceName, scopePath, itemProperties, overrideItem) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Put", nil, "Failure preparing request") + return + } + + resp, err := client.PutSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Put", resp, "Failure sending request") + return + } + + result, err = client.PutResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnalyticsItemsClient", "Put", resp, "Failure responding to request") + return + } + + return +} + +// PutPreparer prepares the Put request. +func (client AnalyticsItemsClient) PutPreparer(ctx context.Context, resourceGroupName string, resourceName string, scopePath ItemScopePath, itemProperties ApplicationInsightsComponentAnalyticsItem, overrideItem *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "scopePath": autorest.Encode("path", scopePath), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if overrideItem != nil { + queryParameters["overrideItem"] = autorest.Encode("query", *overrideItem) + } + + itemProperties.Version = nil + itemProperties.TimeCreated = nil + itemProperties.TimeModified = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/{scopePath}/item", pathParameters), + autorest.WithJSON(itemProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PutSender sends the Put request. The method will close the +// http.Response Body if it receives an error. +func (client AnalyticsItemsClient) PutSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// PutResponder handles the response to the Put request. The method always +// closes the http.Response Body. +func (client AnalyticsItemsClient) PutResponder(resp *http.Response) (result ApplicationInsightsComponentAnalyticsItem, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/annotations.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/annotations.go new file mode 100644 index 000000000000..aa31fd7d0e74 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/annotations.go @@ -0,0 +1,383 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AnnotationsClient is the composite Swagger for Application Insights Management Client +type AnnotationsClient struct { + BaseClient +} + +// NewAnnotationsClient creates an instance of the AnnotationsClient client. +func NewAnnotationsClient(subscriptionID string) AnnotationsClient { + return NewAnnotationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAnnotationsClientWithBaseURI creates an instance of the AnnotationsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAnnotationsClientWithBaseURI(baseURI string, subscriptionID string) AnnotationsClient { + return AnnotationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create an Annotation of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// annotationProperties - properties that need to be specified to create an annotation of a Application +// Insights component. +func (client AnnotationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, annotationProperties Annotation) (result ListAnnotation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AnnotationsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AnnotationsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, annotationProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client AnnotationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, annotationProperties Annotation) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations", pathParameters), + autorest.WithJSON(annotationProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client AnnotationsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client AnnotationsClient) CreateResponder(resp *http.Response) (result ListAnnotation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an Annotation of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// annotationID - the unique annotation ID. This is unique within a Application Insights component. +func (client AnnotationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AnnotationsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AnnotationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, annotationID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AnnotationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "annotationId": autorest.Encode("path", annotationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AnnotationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AnnotationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the annotation for given id. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// annotationID - the unique annotation ID. This is unique within a Application Insights component. +func (client AnnotationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (result ListAnnotation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AnnotationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AnnotationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, annotationID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AnnotationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "annotationId": autorest.Encode("path", annotationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations/{annotationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AnnotationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AnnotationsClient) GetResponder(resp *http.Response) (result ListAnnotation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the list of annotations for a component for given time range +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// start - the start time to query from for annotations, cannot be older than 90 days from current date. +// end - the end time to query for annotations. +func (client AnnotationsClient) List(ctx context.Context, resourceGroupName string, resourceName string, start string, end string) (result AnnotationsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AnnotationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AnnotationsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName, start, end) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AnnotationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AnnotationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string, start string, end string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "end": autorest.Encode("query", end), + "start": autorest.Encode("query", start), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/Annotations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AnnotationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AnnotationsClient) ListResponder(resp *http.Response) (result AnnotationsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/apikeys.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/apikeys.go new file mode 100644 index 000000000000..ca33d3c4c68d --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/apikeys.go @@ -0,0 +1,380 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIKeysClient is the composite Swagger for Application Insights Management Client +type APIKeysClient struct { + BaseClient +} + +// NewAPIKeysClient creates an instance of the APIKeysClient client. +func NewAPIKeysClient(subscriptionID string) APIKeysClient { + return NewAPIKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIKeysClientWithBaseURI creates an instance of the APIKeysClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAPIKeysClientWithBaseURI(baseURI string, subscriptionID string) APIKeysClient { + return APIKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create an API Key of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// APIKeyProperties - properties that need to be specified to create an API key of a Application Insights +// component. +func (client APIKeysClient) Create(ctx context.Context, resourceGroupName string, resourceName string, APIKeyProperties APIKeyRequest) (result ApplicationInsightsComponentAPIKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeysClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.APIKeysClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, APIKeyProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client APIKeysClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, APIKeyProperties APIKeyRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys", pathParameters), + autorest.WithJSON(APIKeyProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client APIKeysClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client APIKeysClient) CreateResponder(resp *http.Response) (result ApplicationInsightsComponentAPIKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an API Key of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// keyID - the API Key ID. This is unique within a Application Insights component. +func (client APIKeysClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (result ApplicationInsightsComponentAPIKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeysClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.APIKeysClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, keyID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client APIKeysClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyId": autorest.Encode("path", keyID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client APIKeysClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client APIKeysClient) DeleteResponder(resp *http.Response) (result ApplicationInsightsComponentAPIKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the API Key for this key id. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// keyID - the API Key ID. This is unique within a Application Insights component. +func (client APIKeysClient) Get(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (result ApplicationInsightsComponentAPIKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.APIKeysClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, keyID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client APIKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyId": autorest.Encode("path", keyID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/APIKeys/{keyId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client APIKeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client APIKeysClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentAPIKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of API keys of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client APIKeysClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentAPIKeyListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeysClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.APIKeysClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.APIKeysClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client APIKeysClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ApiKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client APIKeysClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client APIKeysClient) ListResponder(resp *http.Response) (result ApplicationInsightsComponentAPIKeyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/client.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/client.go new file mode 100644 index 000000000000..9203ed850c0c --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/client.go @@ -0,0 +1,41 @@ +// Package insights implements the Azure ARM Insights service API version . +// +// Composite Swagger for Application Insights Management Client +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Insights + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Insights. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentavailablefeatures.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentavailablefeatures.go new file mode 100644 index 000000000000..997a483b327f --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentavailablefeatures.go @@ -0,0 +1,118 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ComponentAvailableFeaturesClient is the composite Swagger for Application Insights Management Client +type ComponentAvailableFeaturesClient struct { + BaseClient +} + +// NewComponentAvailableFeaturesClient creates an instance of the ComponentAvailableFeaturesClient client. +func NewComponentAvailableFeaturesClient(subscriptionID string) ComponentAvailableFeaturesClient { + return NewComponentAvailableFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewComponentAvailableFeaturesClientWithBaseURI creates an instance of the ComponentAvailableFeaturesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewComponentAvailableFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentAvailableFeaturesClient { + return ComponentAvailableFeaturesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get returns all available features of the application insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ComponentAvailableFeaturesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentAvailableFeatures, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentAvailableFeaturesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentAvailableFeaturesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentAvailableFeaturesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentAvailableFeaturesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentAvailableFeaturesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ComponentAvailableFeaturesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/getavailablebillingfeatures", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentAvailableFeaturesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ComponentAvailableFeaturesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentAvailableFeatures, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentcurrentbillingfeatures.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentcurrentbillingfeatures.go new file mode 100644 index 000000000000..3416a616be9c --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentcurrentbillingfeatures.go @@ -0,0 +1,207 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ComponentCurrentBillingFeaturesClient is the composite Swagger for Application Insights Management Client +type ComponentCurrentBillingFeaturesClient struct { + BaseClient +} + +// NewComponentCurrentBillingFeaturesClient creates an instance of the ComponentCurrentBillingFeaturesClient client. +func NewComponentCurrentBillingFeaturesClient(subscriptionID string) ComponentCurrentBillingFeaturesClient { + return NewComponentCurrentBillingFeaturesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewComponentCurrentBillingFeaturesClientWithBaseURI creates an instance of the ComponentCurrentBillingFeaturesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewComponentCurrentBillingFeaturesClientWithBaseURI(baseURI string, subscriptionID string) ComponentCurrentBillingFeaturesClient { + return ComponentCurrentBillingFeaturesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get returns current billing features for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ComponentCurrentBillingFeaturesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentBillingFeatures, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentCurrentBillingFeaturesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentCurrentBillingFeaturesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ComponentCurrentBillingFeaturesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentCurrentBillingFeaturesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ComponentCurrentBillingFeaturesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update current billing features for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// billingFeaturesProperties - properties that need to be specified to update billing features for an +// Application Insights component. +func (client ComponentCurrentBillingFeaturesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (result ApplicationInsightsComponentBillingFeatures, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentCurrentBillingFeaturesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentCurrentBillingFeaturesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, billingFeaturesProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentCurrentBillingFeaturesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ComponentCurrentBillingFeaturesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties ApplicationInsightsComponentBillingFeatures) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/currentbillingfeatures", pathParameters), + autorest.WithJSON(billingFeaturesProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentCurrentBillingFeaturesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ComponentCurrentBillingFeaturesClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentBillingFeatures, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentfeaturecapabilities.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentfeaturecapabilities.go new file mode 100644 index 000000000000..0620681495e8 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentfeaturecapabilities.go @@ -0,0 +1,118 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ComponentFeatureCapabilitiesClient is the composite Swagger for Application Insights Management Client +type ComponentFeatureCapabilitiesClient struct { + BaseClient +} + +// NewComponentFeatureCapabilitiesClient creates an instance of the ComponentFeatureCapabilitiesClient client. +func NewComponentFeatureCapabilitiesClient(subscriptionID string) ComponentFeatureCapabilitiesClient { + return NewComponentFeatureCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewComponentFeatureCapabilitiesClientWithBaseURI creates an instance of the ComponentFeatureCapabilitiesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewComponentFeatureCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) ComponentFeatureCapabilitiesClient { + return ComponentFeatureCapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get returns feature capabilities of the application insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ComponentFeatureCapabilitiesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentFeatureCapabilities, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentFeatureCapabilitiesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentFeatureCapabilitiesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentFeatureCapabilitiesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentFeatureCapabilitiesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentFeatureCapabilitiesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ComponentFeatureCapabilitiesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/featurecapabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentFeatureCapabilitiesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ComponentFeatureCapabilitiesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentFeatureCapabilities, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentlinkedstorageaccounts.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentlinkedstorageaccounts.go new file mode 100644 index 000000000000..52a5a107c3fd --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentlinkedstorageaccounts.go @@ -0,0 +1,384 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ComponentLinkedStorageAccountsClient is the composite Swagger for Application Insights Management Client +type ComponentLinkedStorageAccountsClient struct { + BaseClient +} + +// NewComponentLinkedStorageAccountsClient creates an instance of the ComponentLinkedStorageAccountsClient client. +func NewComponentLinkedStorageAccountsClient(subscriptionID string) ComponentLinkedStorageAccountsClient { + return NewComponentLinkedStorageAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewComponentLinkedStorageAccountsClientWithBaseURI creates an instance of the ComponentLinkedStorageAccountsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewComponentLinkedStorageAccountsClientWithBaseURI(baseURI string, subscriptionID string) ComponentLinkedStorageAccountsClient { + return ComponentLinkedStorageAccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateAndUpdate replace current linked storage account for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// linkedStorageAccountsProperties - properties that need to be specified to update linked storage accounts for +// an Application Insights component. +func (client ComponentLinkedStorageAccountsClient) CreateAndUpdate(ctx context.Context, resourceGroupName string, resourceName string, linkedStorageAccountsProperties ComponentLinkedStorageAccounts) (result ComponentLinkedStorageAccounts, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentLinkedStorageAccountsClient.CreateAndUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentLinkedStorageAccountsClient", "CreateAndUpdate", err.Error()) + } + + req, err := client.CreateAndUpdatePreparer(ctx, resourceGroupName, resourceName, linkedStorageAccountsProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "CreateAndUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateAndUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "CreateAndUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateAndUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "CreateAndUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateAndUpdatePreparer prepares the CreateAndUpdate request. +func (client ComponentLinkedStorageAccountsClient) CreateAndUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, linkedStorageAccountsProperties ComponentLinkedStorageAccounts) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "storageType": autorest.Encode("path", "ServiceProfiler"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", pathParameters), + autorest.WithJSON(linkedStorageAccountsProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateAndUpdateSender sends the CreateAndUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentLinkedStorageAccountsClient) CreateAndUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateAndUpdateResponder handles the response to the CreateAndUpdate request. The method always +// closes the http.Response Body. +func (client ComponentLinkedStorageAccountsClient) CreateAndUpdateResponder(resp *http.Response) (result ComponentLinkedStorageAccounts, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete linked storage accounts for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ComponentLinkedStorageAccountsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentLinkedStorageAccountsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentLinkedStorageAccountsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ComponentLinkedStorageAccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "storageType": autorest.Encode("path", "ServiceProfiler"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentLinkedStorageAccountsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ComponentLinkedStorageAccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns the current linked storage settings for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ComponentLinkedStorageAccountsClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ComponentLinkedStorageAccounts, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentLinkedStorageAccountsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentLinkedStorageAccountsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ComponentLinkedStorageAccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "storageType": autorest.Encode("path", "ServiceProfiler"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentLinkedStorageAccountsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ComponentLinkedStorageAccountsClient) GetResponder(resp *http.Response) (result ComponentLinkedStorageAccounts, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update linked storage accounts for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// linkedStorageAccountsProperties - properties that need to be specified to update a linked storage accounts +// for an Application Insights component. +func (client ComponentLinkedStorageAccountsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, linkedStorageAccountsProperties ComponentLinkedStorageAccountsPatch) (result ComponentLinkedStorageAccounts, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentLinkedStorageAccountsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentLinkedStorageAccountsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, linkedStorageAccountsProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentLinkedStorageAccountsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ComponentLinkedStorageAccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, linkedStorageAccountsProperties ComponentLinkedStorageAccountsPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "storageType": autorest.Encode("path", "ServiceProfiler"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{resourceName}/linkedStorageAccounts/{storageType}", pathParameters), + autorest.WithJSON(linkedStorageAccountsProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentLinkedStorageAccountsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ComponentLinkedStorageAccountsClient) UpdateResponder(resp *http.Response) (result ComponentLinkedStorageAccounts, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentquotastatus.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentquotastatus.go new file mode 100644 index 000000000000..98d79dda19cd --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/componentquotastatus.go @@ -0,0 +1,118 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ComponentQuotaStatusClient is the composite Swagger for Application Insights Management Client +type ComponentQuotaStatusClient struct { + BaseClient +} + +// NewComponentQuotaStatusClient creates an instance of the ComponentQuotaStatusClient client. +func NewComponentQuotaStatusClient(subscriptionID string) ComponentQuotaStatusClient { + return NewComponentQuotaStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewComponentQuotaStatusClientWithBaseURI creates an instance of the ComponentQuotaStatusClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewComponentQuotaStatusClientWithBaseURI(baseURI string, subscriptionID string) ComponentQuotaStatusClient { + return ComponentQuotaStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get returns daily data volume cap (quota) status for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ComponentQuotaStatusClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponentQuotaStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentQuotaStatusClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentQuotaStatusClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentQuotaStatusClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentQuotaStatusClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentQuotaStatusClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ComponentQuotaStatusClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/quotastatus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentQuotaStatusClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ComponentQuotaStatusClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentQuotaStatus, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/components.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/components.go new file mode 100644 index 000000000000..edd860490ce2 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/components.go @@ -0,0 +1,807 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ComponentsClient is the composite Swagger for Application Insights Management Client +type ComponentsClient struct { + BaseClient +} + +// NewComponentsClient creates an instance of the ComponentsClient client. +func NewComponentsClient(subscriptionID string) ComponentsClient { + return NewComponentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewComponentsClientWithBaseURI creates an instance of the ComponentsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewComponentsClientWithBaseURI(baseURI string, subscriptionID string) ComponentsClient { + return ComponentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates (or updates) an Application Insights component. Note: You cannot specify a different value +// for InstrumentationKey nor AppId in the Put operation. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// insightProperties - properties that need to be specified to create an Application Insights component. +func (client ComponentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (result ApplicationInsightsComponent, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: insightProperties, + Constraints: []validation.Constraint{{Target: "insightProperties.Kind", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, insightProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ComponentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, insightProperties ApplicationInsightsComponent) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", pathParameters), + autorest.WithJSON(insightProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ComponentsClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ComponentsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ComponentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ComponentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ComponentsClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsComponent, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ComponentsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ComponentsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetPurgeStatus get status for an ongoing purge operation. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// purgeID - in a purge status request, this is the Id of the operation the status of which is returned. +func (client ComponentsClient) GetPurgeStatus(ctx context.Context, resourceGroupName string, resourceName string, purgeID string) (result ComponentPurgeStatusResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.GetPurgeStatus") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentsClient", "GetPurgeStatus", err.Error()) + } + + req, err := client.GetPurgeStatusPreparer(ctx, resourceGroupName, resourceName, purgeID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "GetPurgeStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetPurgeStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "GetPurgeStatus", resp, "Failure sending request") + return + } + + result, err = client.GetPurgeStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "GetPurgeStatus", resp, "Failure responding to request") + return + } + + return +} + +// GetPurgeStatusPreparer prepares the GetPurgeStatus request. +func (client ComponentsClient) GetPurgeStatusPreparer(ctx context.Context, resourceGroupName string, resourceName string, purgeID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "purgeId": autorest.Encode("path", purgeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/operations/{purgeId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetPurgeStatusSender sends the GetPurgeStatus request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) GetPurgeStatusSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetPurgeStatusResponder handles the response to the GetPurgeStatus request. The method always +// closes the http.Response Body. +func (client ComponentsClient) GetPurgeStatusResponder(resp *http.Response) (result ComponentPurgeStatusResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all Application Insights components within a subscription. +func (client ComponentsClient) List(ctx context.Context) (result ApplicationInsightsComponentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.List") + defer func() { + sc := -1 + if result.aiclr.Response.Response != nil { + sc = result.aiclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aiclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "List", resp, "Failure sending request") + return + } + + result.aiclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "List", resp, "Failure responding to request") + return + } + if result.aiclr.hasNextLink() && result.aiclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ComponentsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ComponentsClient) ListResponder(resp *http.Response) (result ApplicationInsightsComponentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ComponentsClient) listNextResults(ctx context.Context, lastResults ApplicationInsightsComponentListResult) (result ApplicationInsightsComponentListResult, err error) { + req, err := lastResults.applicationInsightsComponentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ComponentsClient) ListComplete(ctx context.Context) (result ApplicationInsightsComponentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of Application Insights components within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ComponentsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ApplicationInsightsComponentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.aiclr.Response.Response != nil { + sc = result.aiclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.aiclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.aiclr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.aiclr.hasNextLink() && result.aiclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ComponentsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ComponentsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationInsightsComponentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ComponentsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ApplicationInsightsComponentListResult) (result ApplicationInsightsComponentListResult, err error) { + req, err := lastResults.applicationInsightsComponentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.ComponentsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ComponentsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ApplicationInsightsComponentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Purge purges data in an Application Insights component by a set of user-defined filters. +// +// In order to manage system resources, purge requests are throttled at 50 requests per hour. You should batch the +// execution of purge requests by sending a single command whose predicate includes all user identities that require +// purging. Use the in operator to specify multiple identities. You should run the query prior to using for a purge +// request to verify that the results are expected. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// body - describes the body of a request to purge data in a single table of an Application Insights component +func (client ComponentsClient) Purge(ctx context.Context, resourceGroupName string, resourceName string, body ComponentPurgeBody) (result ComponentPurgeResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.Purge") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Table", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.Filters", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentsClient", "Purge", err.Error()) + } + + req, err := client.PurgePreparer(ctx, resourceGroupName, resourceName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Purge", nil, "Failure preparing request") + return + } + + resp, err := client.PurgeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Purge", resp, "Failure sending request") + return + } + + result, err = client.PurgeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "Purge", resp, "Failure responding to request") + return + } + + return +} + +// PurgePreparer prepares the Purge request. +func (client ComponentsClient) PurgePreparer(ctx context.Context, resourceGroupName string, resourceName string, body ComponentPurgeBody) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/purge", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PurgeSender sends the Purge request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) PurgeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// PurgeResponder handles the response to the Purge request. The method always +// closes the http.Response Body. +func (client ComponentsClient) PurgeResponder(resp *http.Response) (result ComponentPurgeResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateTags updates an existing component's tags. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// componentTags - updated tag information to set into the component instance. +func (client ComponentsClient) UpdateTags(ctx context.Context, resourceGroupName string, resourceName string, componentTags TagsResource) (result ApplicationInsightsComponent, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComponentsClient.UpdateTags") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ComponentsClient", "UpdateTags", err.Error()) + } + + req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, resourceName, componentTags) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "UpdateTags", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateTagsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "UpdateTags", resp, "Failure sending request") + return + } + + result, err = client.UpdateTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ComponentsClient", "UpdateTags", resp, "Failure responding to request") + return + } + + return +} + +// UpdateTagsPreparer prepares the UpdateTags request. +func (client ComponentsClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, resourceName string, componentTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-02" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}", pathParameters), + autorest.WithJSON(componentTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateTagsSender sends the UpdateTags request. The method will close the +// http.Response Body if it receives an error. +func (client ComponentsClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateTagsResponder handles the response to the UpdateTags request. The method always +// closes the http.Response Body. +func (client ComponentsClient) UpdateTagsResponder(resp *http.Response) (result ApplicationInsightsComponent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/enums.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/enums.go new file mode 100644 index 000000000000..f1909b5bbfbc --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/enums.go @@ -0,0 +1,256 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +// ApplicationType enumerates the values for application type. +type ApplicationType string + +const ( + // ApplicationTypeOther ... + ApplicationTypeOther ApplicationType = "other" + // ApplicationTypeWeb ... + ApplicationTypeWeb ApplicationType = "web" +) + +// PossibleApplicationTypeValues returns an array of possible values for the ApplicationType const type. +func PossibleApplicationTypeValues() []ApplicationType { + return []ApplicationType{ApplicationTypeOther, ApplicationTypeWeb} +} + +// CategoryType enumerates the values for category type. +type CategoryType string + +const ( + // CategoryTypePerformance ... + CategoryTypePerformance CategoryType = "performance" + // CategoryTypeRetention ... + CategoryTypeRetention CategoryType = "retention" + // CategoryTypeTSG ... + CategoryTypeTSG CategoryType = "TSG" + // CategoryTypeWorkbook ... + CategoryTypeWorkbook CategoryType = "workbook" +) + +// PossibleCategoryTypeValues returns an array of possible values for the CategoryType const type. +func PossibleCategoryTypeValues() []CategoryType { + return []CategoryType{CategoryTypePerformance, CategoryTypeRetention, CategoryTypeTSG, CategoryTypeWorkbook} +} + +// FavoriteSourceType enumerates the values for favorite source type. +type FavoriteSourceType string + +const ( + // FavoriteSourceTypeEvents ... + FavoriteSourceTypeEvents FavoriteSourceType = "events" + // FavoriteSourceTypeFunnel ... + FavoriteSourceTypeFunnel FavoriteSourceType = "funnel" + // FavoriteSourceTypeImpact ... + FavoriteSourceTypeImpact FavoriteSourceType = "impact" + // FavoriteSourceTypeNotebook ... + FavoriteSourceTypeNotebook FavoriteSourceType = "notebook" + // FavoriteSourceTypeRetention ... + FavoriteSourceTypeRetention FavoriteSourceType = "retention" + // FavoriteSourceTypeSegmentation ... + FavoriteSourceTypeSegmentation FavoriteSourceType = "segmentation" + // FavoriteSourceTypeSessions ... + FavoriteSourceTypeSessions FavoriteSourceType = "sessions" + // FavoriteSourceTypeUserflows ... + FavoriteSourceTypeUserflows FavoriteSourceType = "userflows" +) + +// PossibleFavoriteSourceTypeValues returns an array of possible values for the FavoriteSourceType const type. +func PossibleFavoriteSourceTypeValues() []FavoriteSourceType { + return []FavoriteSourceType{FavoriteSourceTypeEvents, FavoriteSourceTypeFunnel, FavoriteSourceTypeImpact, FavoriteSourceTypeNotebook, FavoriteSourceTypeRetention, FavoriteSourceTypeSegmentation, FavoriteSourceTypeSessions, FavoriteSourceTypeUserflows} +} + +// FavoriteType enumerates the values for favorite type. +type FavoriteType string + +const ( + // FavoriteTypeShared ... + FavoriteTypeShared FavoriteType = "shared" + // FavoriteTypeUser ... + FavoriteTypeUser FavoriteType = "user" +) + +// PossibleFavoriteTypeValues returns an array of possible values for the FavoriteType const type. +func PossibleFavoriteTypeValues() []FavoriteType { + return []FavoriteType{FavoriteTypeShared, FavoriteTypeUser} +} + +// FlowType enumerates the values for flow type. +type FlowType string + +const ( + // FlowTypeBluefield ... + FlowTypeBluefield FlowType = "Bluefield" +) + +// PossibleFlowTypeValues returns an array of possible values for the FlowType const type. +func PossibleFlowTypeValues() []FlowType { + return []FlowType{FlowTypeBluefield} +} + +// IngestionMode enumerates the values for ingestion mode. +type IngestionMode string + +const ( + // IngestionModeApplicationInsights ... + IngestionModeApplicationInsights IngestionMode = "ApplicationInsights" + // IngestionModeApplicationInsightsWithDiagnosticSettings ... + IngestionModeApplicationInsightsWithDiagnosticSettings IngestionMode = "ApplicationInsightsWithDiagnosticSettings" + // IngestionModeLogAnalytics ... + IngestionModeLogAnalytics IngestionMode = "LogAnalytics" +) + +// PossibleIngestionModeValues returns an array of possible values for the IngestionMode const type. +func PossibleIngestionModeValues() []IngestionMode { + return []IngestionMode{IngestionModeApplicationInsights, IngestionModeApplicationInsightsWithDiagnosticSettings, IngestionModeLogAnalytics} +} + +// ItemScope enumerates the values for item scope. +type ItemScope string + +const ( + // ItemScopeShared ... + ItemScopeShared ItemScope = "shared" + // ItemScopeUser ... + ItemScopeUser ItemScope = "user" +) + +// PossibleItemScopeValues returns an array of possible values for the ItemScope const type. +func PossibleItemScopeValues() []ItemScope { + return []ItemScope{ItemScopeShared, ItemScopeUser} +} + +// ItemScopePath enumerates the values for item scope path. +type ItemScopePath string + +const ( + // ItemScopePathAnalyticsItems ... + ItemScopePathAnalyticsItems ItemScopePath = "analyticsItems" + // ItemScopePathMyanalyticsItems ... + ItemScopePathMyanalyticsItems ItemScopePath = "myanalyticsItems" +) + +// PossibleItemScopePathValues returns an array of possible values for the ItemScopePath const type. +func PossibleItemScopePathValues() []ItemScopePath { + return []ItemScopePath{ItemScopePathAnalyticsItems, ItemScopePathMyanalyticsItems} +} + +// ItemType enumerates the values for item type. +type ItemType string + +const ( + // ItemTypeFolder ... + ItemTypeFolder ItemType = "folder" + // ItemTypeFunction ... + ItemTypeFunction ItemType = "function" + // ItemTypeQuery ... + ItemTypeQuery ItemType = "query" + // ItemTypeRecent ... + ItemTypeRecent ItemType = "recent" +) + +// PossibleItemTypeValues returns an array of possible values for the ItemType const type. +func PossibleItemTypeValues() []ItemType { + return []ItemType{ItemTypeFolder, ItemTypeFunction, ItemTypeQuery, ItemTypeRecent} +} + +// ItemTypeParameter enumerates the values for item type parameter. +type ItemTypeParameter string + +const ( + // ItemTypeParameterFolder ... + ItemTypeParameterFolder ItemTypeParameter = "folder" + // ItemTypeParameterFunction ... + ItemTypeParameterFunction ItemTypeParameter = "function" + // ItemTypeParameterNone ... + ItemTypeParameterNone ItemTypeParameter = "none" + // ItemTypeParameterQuery ... + ItemTypeParameterQuery ItemTypeParameter = "query" + // ItemTypeParameterRecent ... + ItemTypeParameterRecent ItemTypeParameter = "recent" +) + +// PossibleItemTypeParameterValues returns an array of possible values for the ItemTypeParameter const type. +func PossibleItemTypeParameterValues() []ItemTypeParameter { + return []ItemTypeParameter{ItemTypeParameterFolder, ItemTypeParameterFunction, ItemTypeParameterNone, ItemTypeParameterQuery, ItemTypeParameterRecent} +} + +// PublicNetworkAccessType enumerates the values for public network access type. +type PublicNetworkAccessType string + +const ( + // PublicNetworkAccessTypeDisabled Disables public connectivity to Application Insights through public DNS. + PublicNetworkAccessTypeDisabled PublicNetworkAccessType = "Disabled" + // PublicNetworkAccessTypeEnabled Enables connectivity to Application Insights through public DNS. + PublicNetworkAccessTypeEnabled PublicNetworkAccessType = "Enabled" +) + +// PossiblePublicNetworkAccessTypeValues returns an array of possible values for the PublicNetworkAccessType const type. +func PossiblePublicNetworkAccessTypeValues() []PublicNetworkAccessType { + return []PublicNetworkAccessType{PublicNetworkAccessTypeDisabled, PublicNetworkAccessTypeEnabled} +} + +// PurgeState enumerates the values for purge state. +type PurgeState string + +const ( + // PurgeStateCompleted ... + PurgeStateCompleted PurgeState = "completed" + // PurgeStatePending ... + PurgeStatePending PurgeState = "pending" +) + +// PossiblePurgeStateValues returns an array of possible values for the PurgeState const type. +func PossiblePurgeStateValues() []PurgeState { + return []PurgeState{PurgeStateCompleted, PurgeStatePending} +} + +// RequestSource enumerates the values for request source. +type RequestSource string + +const ( + // RequestSourceRest ... + RequestSourceRest RequestSource = "rest" +) + +// PossibleRequestSourceValues returns an array of possible values for the RequestSource const type. +func PossibleRequestSourceValues() []RequestSource { + return []RequestSource{RequestSourceRest} +} + +// SharedTypeKind enumerates the values for shared type kind. +type SharedTypeKind string + +const ( + // SharedTypeKindShared ... + SharedTypeKindShared SharedTypeKind = "shared" + // SharedTypeKindUser ... + SharedTypeKindUser SharedTypeKind = "user" +) + +// PossibleSharedTypeKindValues returns an array of possible values for the SharedTypeKind const type. +func PossibleSharedTypeKindValues() []SharedTypeKind { + return []SharedTypeKind{SharedTypeKindShared, SharedTypeKindUser} +} + +// WebTestKind enumerates the values for web test kind. +type WebTestKind string + +const ( + // WebTestKindMultistep ... + WebTestKindMultistep WebTestKind = "multistep" + // WebTestKindPing ... + WebTestKindPing WebTestKind = "ping" +) + +// PossibleWebTestKindValues returns an array of possible values for the WebTestKind const type. +func PossibleWebTestKindValues() []WebTestKind { + return []WebTestKind{WebTestKindMultistep, WebTestKindPing} +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/exportconfigurations.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/exportconfigurations.go new file mode 100644 index 000000000000..8543b8d411df --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/exportconfigurations.go @@ -0,0 +1,471 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ExportConfigurationsClient is the composite Swagger for Application Insights Management Client +type ExportConfigurationsClient struct { + BaseClient +} + +// NewExportConfigurationsClient creates an instance of the ExportConfigurationsClient client. +func NewExportConfigurationsClient(subscriptionID string) ExportConfigurationsClient { + return NewExportConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewExportConfigurationsClientWithBaseURI creates an instance of the ExportConfigurationsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewExportConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ExportConfigurationsClient { + return ExportConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a Continuous Export configuration of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// exportProperties - properties that need to be specified to create a Continuous Export configuration of a +// Application Insights component. +func (client ExportConfigurationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, exportProperties ApplicationInsightsComponentExportRequest) (result ListApplicationInsightsComponentExportConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ExportConfigurationsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, exportProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ExportConfigurationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, exportProperties ApplicationInsightsComponentExportRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration", pathParameters), + autorest.WithJSON(exportProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ExportConfigurationsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ExportConfigurationsClient) CreateResponder(resp *http.Response) (result ListApplicationInsightsComponentExportConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a Continuous Export configuration of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// exportID - the Continuous Export configuration ID. This is unique within a Application Insights component. +func (client ExportConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (result ApplicationInsightsComponentExportConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ExportConfigurationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, exportID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ExportConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "exportId": autorest.Encode("path", exportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ExportConfigurationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ExportConfigurationsClient) DeleteResponder(resp *http.Response) (result ApplicationInsightsComponentExportConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the Continuous Export configuration for this export id. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// exportID - the Continuous Export configuration ID. This is unique within a Application Insights component. +func (client ExportConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (result ApplicationInsightsComponentExportConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ExportConfigurationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, exportID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ExportConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "exportId": autorest.Encode("path", exportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ExportConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ExportConfigurationsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentExportConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of Continuous Export configuration of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ExportConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ListApplicationInsightsComponentExportConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ExportConfigurationsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ExportConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ExportConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ExportConfigurationsClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentExportConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update the Continuous Export configuration for this export id. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// exportID - the Continuous Export configuration ID. This is unique within a Application Insights component. +// exportProperties - properties that need to be specified to update the Continuous Export configuration. +func (client ExportConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, exportID string, exportProperties ApplicationInsightsComponentExportRequest) (result ApplicationInsightsComponentExportConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportConfigurationsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ExportConfigurationsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, exportID, exportProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ExportConfigurationsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ExportConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, exportID string, exportProperties ApplicationInsightsComponentExportRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "exportId": autorest.Encode("path", exportID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/exportconfiguration/{exportId}", pathParameters), + autorest.WithJSON(exportProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ExportConfigurationsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ExportConfigurationsClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentExportConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/favorites.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/favorites.go new file mode 100644 index 000000000000..732fca754804 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/favorites.go @@ -0,0 +1,497 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FavoritesClient is the composite Swagger for Application Insights Management Client +type FavoritesClient struct { + BaseClient +} + +// NewFavoritesClient creates an instance of the FavoritesClient client. +func NewFavoritesClient(subscriptionID string) FavoritesClient { + return NewFavoritesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFavoritesClientWithBaseURI creates an instance of the FavoritesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewFavoritesClientWithBaseURI(baseURI string, subscriptionID string) FavoritesClient { + return FavoritesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Add adds a new favorites to an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// favoriteID - the Id of a specific favorite defined in the Application Insights component +// favoriteProperties - properties that need to be specified to create a new favorite and add it to an +// Application Insights component. +func (client FavoritesClient) Add(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (result ApplicationInsightsComponentFavorite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.Add") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.FavoritesClient", "Add", err.Error()) + } + + req, err := client.AddPreparer(ctx, resourceGroupName, resourceName, favoriteID, favoriteProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Add", nil, "Failure preparing request") + return + } + + resp, err := client.AddSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Add", resp, "Failure sending request") + return + } + + result, err = client.AddResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Add", resp, "Failure responding to request") + return + } + + return +} + +// AddPreparer prepares the Add request. +func (client FavoritesClient) AddPreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "favoriteId": autorest.Encode("path", favoriteID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + favoriteProperties.FavoriteID = nil + favoriteProperties.TimeModified = nil + favoriteProperties.UserID = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", pathParameters), + autorest.WithJSON(favoriteProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AddSender sends the Add request. The method will close the +// http.Response Body if it receives an error. +func (client FavoritesClient) AddSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// AddResponder handles the response to the Add request. The method always +// closes the http.Response Body. +func (client FavoritesClient) AddResponder(resp *http.Response) (result ApplicationInsightsComponentFavorite, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete remove a favorite that is associated to an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// favoriteID - the Id of a specific favorite defined in the Application Insights component +func (client FavoritesClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.FavoritesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, favoriteID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FavoritesClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "favoriteId": autorest.Encode("path", favoriteID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FavoritesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FavoritesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a single favorite by its FavoriteId, defined within an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// favoriteID - the Id of a specific favorite defined in the Application Insights component +func (client FavoritesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (result ApplicationInsightsComponentFavorite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.FavoritesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, favoriteID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FavoritesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "favoriteId": autorest.Encode("path", favoriteID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FavoritesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FavoritesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentFavorite, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of favorites defined within an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// favoriteType - the type of favorite. Value can be either shared or user. +// sourceType - source type of favorite to return. When left out, the source type defaults to 'other' (not +// present in this enum). +// canFetchContent - flag indicating whether or not to return the full content for each applicable favorite. If +// false, only return summary content for favorites. +// tags - tags that must be present on each favorite returned. +func (client FavoritesClient) List(ctx context.Context, resourceGroupName string, resourceName string, favoriteType FavoriteType, sourceType FavoriteSourceType, canFetchContent *bool, tags []string) (result ListApplicationInsightsComponentFavorite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.FavoritesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName, favoriteType, sourceType, canFetchContent, tags) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client FavoritesClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteType FavoriteType, sourceType FavoriteSourceType, canFetchContent *bool, tags []string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(favoriteType)) > 0 { + queryParameters["favoriteType"] = autorest.Encode("query", favoriteType) + } else { + queryParameters["favoriteType"] = autorest.Encode("query", "shared") + } + if len(string(sourceType)) > 0 { + queryParameters["sourceType"] = autorest.Encode("query", sourceType) + } + if canFetchContent != nil { + queryParameters["canFetchContent"] = autorest.Encode("query", *canFetchContent) + } + if tags != nil && len(tags) > 0 { + queryParameters["tags"] = autorest.Encode("query", tags, ",") + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client FavoritesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client FavoritesClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentFavorite, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a favorite that has already been added to an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// favoriteID - the Id of a specific favorite defined in the Application Insights component +// favoriteProperties - properties that need to be specified to update the existing favorite. +func (client FavoritesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (result ApplicationInsightsComponentFavorite, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.FavoritesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, favoriteID, favoriteProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client FavoritesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "favoriteId": autorest.Encode("path", favoriteID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + favoriteProperties.FavoriteID = nil + favoriteProperties.TimeModified = nil + favoriteProperties.UserID = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", pathParameters), + autorest.WithJSON(favoriteProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client FavoritesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client FavoritesClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentFavorite, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/insightsapi/interfaces.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/insightsapi/interfaces.go new file mode 100644 index 000000000000..2147306911a8 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/insightsapi/interfaces.go @@ -0,0 +1,195 @@ +package insightsapi + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/appinsights/mgmt/2020-02-02-preview/insights" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result insights.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result insights.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*insights.OperationsClient)(nil) + +// AnnotationsClientAPI contains the set of methods on the AnnotationsClient type. +type AnnotationsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, resourceName string, annotationProperties insights.Annotation) (result insights.ListAnnotation, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, annotationID string) (result insights.ListAnnotation, err error) + List(ctx context.Context, resourceGroupName string, resourceName string, start string, end string) (result insights.AnnotationsListResult, err error) +} + +var _ AnnotationsClientAPI = (*insights.AnnotationsClient)(nil) + +// APIKeysClientAPI contains the set of methods on the APIKeysClient type. +type APIKeysClientAPI interface { + Create(ctx context.Context, resourceGroupName string, resourceName string, APIKeyProperties insights.APIKeyRequest) (result insights.ApplicationInsightsComponentAPIKey, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (result insights.ApplicationInsightsComponentAPIKey, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, keyID string) (result insights.ApplicationInsightsComponentAPIKey, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ApplicationInsightsComponentAPIKeyListResult, err error) +} + +var _ APIKeysClientAPI = (*insights.APIKeysClient)(nil) + +// ExportConfigurationsClientAPI contains the set of methods on the ExportConfigurationsClient type. +type ExportConfigurationsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, resourceName string, exportProperties insights.ApplicationInsightsComponentExportRequest) (result insights.ListApplicationInsightsComponentExportConfiguration, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (result insights.ApplicationInsightsComponentExportConfiguration, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, exportID string) (result insights.ApplicationInsightsComponentExportConfiguration, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ListApplicationInsightsComponentExportConfiguration, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, exportID string, exportProperties insights.ApplicationInsightsComponentExportRequest) (result insights.ApplicationInsightsComponentExportConfiguration, err error) +} + +var _ ExportConfigurationsClientAPI = (*insights.ExportConfigurationsClient)(nil) + +// ComponentCurrentBillingFeaturesClientAPI contains the set of methods on the ComponentCurrentBillingFeaturesClient type. +type ComponentCurrentBillingFeaturesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ApplicationInsightsComponentBillingFeatures, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, billingFeaturesProperties insights.ApplicationInsightsComponentBillingFeatures) (result insights.ApplicationInsightsComponentBillingFeatures, err error) +} + +var _ ComponentCurrentBillingFeaturesClientAPI = (*insights.ComponentCurrentBillingFeaturesClient)(nil) + +// ComponentQuotaStatusClientAPI contains the set of methods on the ComponentQuotaStatusClient type. +type ComponentQuotaStatusClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ApplicationInsightsComponentQuotaStatus, err error) +} + +var _ ComponentQuotaStatusClientAPI = (*insights.ComponentQuotaStatusClient)(nil) + +// ComponentFeatureCapabilitiesClientAPI contains the set of methods on the ComponentFeatureCapabilitiesClient type. +type ComponentFeatureCapabilitiesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ApplicationInsightsComponentFeatureCapabilities, err error) +} + +var _ ComponentFeatureCapabilitiesClientAPI = (*insights.ComponentFeatureCapabilitiesClient)(nil) + +// ComponentAvailableFeaturesClientAPI contains the set of methods on the ComponentAvailableFeaturesClient type. +type ComponentAvailableFeaturesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ApplicationInsightsComponentAvailableFeatures, err error) +} + +var _ ComponentAvailableFeaturesClientAPI = (*insights.ComponentAvailableFeaturesClient)(nil) + +// ProactiveDetectionConfigurationsClientAPI contains the set of methods on the ProactiveDetectionConfigurationsClient type. +type ProactiveDetectionConfigurationsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string, configurationID string) (result insights.ApplicationInsightsComponentProactiveDetectionConfiguration, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ListApplicationInsightsComponentProactiveDetectionConfiguration, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties insights.ApplicationInsightsComponentProactiveDetectionConfiguration) (result insights.ApplicationInsightsComponentProactiveDetectionConfiguration, err error) +} + +var _ ProactiveDetectionConfigurationsClientAPI = (*insights.ProactiveDetectionConfigurationsClient)(nil) + +// WorkItemConfigurationsClientAPI contains the set of methods on the WorkItemConfigurationsClient type. +type WorkItemConfigurationsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigurationProperties insights.WorkItemCreateConfiguration) (result insights.WorkItemConfiguration, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (result autorest.Response, err error) + GetDefault(ctx context.Context, resourceGroupName string, resourceName string) (result insights.WorkItemConfiguration, err error) + GetItem(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (result insights.WorkItemConfiguration, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result insights.WorkItemConfigurationsListResult, err error) + UpdateItem(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string, workItemConfigurationProperties insights.WorkItemCreateConfiguration) (result insights.WorkItemConfiguration, err error) +} + +var _ WorkItemConfigurationsClientAPI = (*insights.WorkItemConfigurationsClient)(nil) + +// FavoritesClientAPI contains the set of methods on the FavoritesClient type. +type FavoritesClientAPI interface { + Add(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties insights.ApplicationInsightsComponentFavorite) (result insights.ApplicationInsightsComponentFavorite, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (result insights.ApplicationInsightsComponentFavorite, err error) + List(ctx context.Context, resourceGroupName string, resourceName string, favoriteType insights.FavoriteType, sourceType insights.FavoriteSourceType, canFetchContent *bool, tags []string) (result insights.ListApplicationInsightsComponentFavorite, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties insights.ApplicationInsightsComponentFavorite) (result insights.ApplicationInsightsComponentFavorite, err error) +} + +var _ FavoritesClientAPI = (*insights.FavoritesClient)(nil) + +// WebTestLocationsClientAPI contains the set of methods on the WebTestLocationsClient type. +type WebTestLocationsClientAPI interface { + List(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ApplicationInsightsWebTestLocationsListResult, err error) +} + +var _ WebTestLocationsClientAPI = (*insights.WebTestLocationsClient)(nil) + +// WebTestsClientAPI contains the set of methods on the WebTestsClient type. +type WebTestsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, webTestName string, webTestDefinition insights.WebTest) (result insights.WebTest, err error) + Delete(ctx context.Context, resourceGroupName string, webTestName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, webTestName string) (result insights.WebTest, err error) + List(ctx context.Context) (result insights.WebTestListResultPage, err error) + ListComplete(ctx context.Context) (result insights.WebTestListResultIterator, err error) + ListByComponent(ctx context.Context, componentName string, resourceGroupName string) (result insights.WebTestListResultPage, err error) + ListByComponentComplete(ctx context.Context, componentName string, resourceGroupName string) (result insights.WebTestListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.WebTestListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.WebTestListResultIterator, err error) + UpdateTags(ctx context.Context, resourceGroupName string, webTestName string, webTestTags insights.TagsResource) (result insights.WebTest, err error) +} + +var _ WebTestsClientAPI = (*insights.WebTestsClient)(nil) + +// AnalyticsItemsClientAPI contains the set of methods on the AnalyticsItemsClient type. +type AnalyticsItemsClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, resourceName string, scopePath insights.ItemScopePath, ID string, name string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, scopePath insights.ItemScopePath, ID string, name string) (result insights.ApplicationInsightsComponentAnalyticsItem, err error) + List(ctx context.Context, resourceGroupName string, resourceName string, scopePath insights.ItemScopePath, scope insights.ItemScope, typeParameter insights.ItemTypeParameter, includeContent *bool) (result insights.ListApplicationInsightsComponentAnalyticsItem, err error) + Put(ctx context.Context, resourceGroupName string, resourceName string, scopePath insights.ItemScopePath, itemProperties insights.ApplicationInsightsComponentAnalyticsItem, overrideItem *bool) (result insights.ApplicationInsightsComponentAnalyticsItem, err error) +} + +var _ AnalyticsItemsClientAPI = (*insights.AnalyticsItemsClient)(nil) + +// WorkbooksClientAPI contains the set of methods on the WorkbooksClient type. +type WorkbooksClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties insights.Workbook) (result insights.Workbook, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result insights.Workbook, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, category insights.CategoryType, tags []string, canFetchContent *bool) (result insights.WorkbooksListResult, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties insights.Workbook) (result insights.Workbook, err error) +} + +var _ WorkbooksClientAPI = (*insights.WorkbooksClient)(nil) + +// MyWorkbooksClientAPI contains the set of methods on the MyWorkbooksClient type. +type MyWorkbooksClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties insights.MyWorkbook) (result insights.MyWorkbook, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result insights.MyWorkbook, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, category insights.CategoryType, tags []string, canFetchContent *bool) (result insights.MyWorkbooksListResult, err error) + ListBySubscription(ctx context.Context, category insights.CategoryType, tags []string, canFetchContent *bool) (result insights.MyWorkbooksListResult, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties insights.MyWorkbook) (result insights.MyWorkbook, err error) +} + +var _ MyWorkbooksClientAPI = (*insights.MyWorkbooksClient)(nil) + +// ComponentsClientAPI contains the set of methods on the ComponentsClient type. +type ComponentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, insightProperties insights.ApplicationInsightsComponent) (result insights.ApplicationInsightsComponent, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ApplicationInsightsComponent, err error) + GetPurgeStatus(ctx context.Context, resourceGroupName string, resourceName string, purgeID string) (result insights.ComponentPurgeStatusResponse, err error) + List(ctx context.Context) (result insights.ApplicationInsightsComponentListResultPage, err error) + ListComplete(ctx context.Context) (result insights.ApplicationInsightsComponentListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.ApplicationInsightsComponentListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.ApplicationInsightsComponentListResultIterator, err error) + Purge(ctx context.Context, resourceGroupName string, resourceName string, body insights.ComponentPurgeBody) (result insights.ComponentPurgeResponse, err error) + UpdateTags(ctx context.Context, resourceGroupName string, resourceName string, componentTags insights.TagsResource) (result insights.ApplicationInsightsComponent, err error) +} + +var _ ComponentsClientAPI = (*insights.ComponentsClient)(nil) + +// ComponentLinkedStorageAccountsClientAPI contains the set of methods on the ComponentLinkedStorageAccountsClient type. +type ComponentLinkedStorageAccountsClientAPI interface { + CreateAndUpdate(ctx context.Context, resourceGroupName string, resourceName string, linkedStorageAccountsProperties insights.ComponentLinkedStorageAccounts) (result insights.ComponentLinkedStorageAccounts, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result insights.ComponentLinkedStorageAccounts, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, linkedStorageAccountsProperties insights.ComponentLinkedStorageAccountsPatch) (result insights.ComponentLinkedStorageAccounts, err error) +} + +var _ ComponentLinkedStorageAccountsClientAPI = (*insights.ComponentLinkedStorageAccountsClient)(nil) diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/models.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/models.go new file mode 100644 index 000000000000..baea235a4143 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/models.go @@ -0,0 +1,2376 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/appinsights/mgmt/2020-02-02-preview/insights" + +// Annotation annotation associated with an application insights resource. +type Annotation struct { + // AnnotationName - Name of annotation + AnnotationName *string `json:"AnnotationName,omitempty"` + // Category - Category of annotation, free form + Category *string `json:"Category,omitempty"` + // EventTime - Time when event occurred + EventTime *date.Time `json:"EventTime,omitempty"` + // ID - Unique Id for annotation + ID *string `json:"Id,omitempty"` + // Properties - Serialized JSON object for detailed properties + Properties *string `json:"Properties,omitempty"` + // RelatedAnnotation - Related parent annotation if any + RelatedAnnotation *string `json:"RelatedAnnotation,omitempty"` +} + +// AnnotationError error associated with trying to create annotation with Id that already exist +type AnnotationError struct { + // Code - Error detail code and explanation + Code *string `json:"code,omitempty"` + // Message - Error message + Message *string `json:"message,omitempty"` + Innererror *InnerError `json:"innererror,omitempty"` +} + +// AnnotationsListResult annotations list result. +type AnnotationsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; An array of annotations. + Value *[]Annotation `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for AnnotationsListResult. +func (alr AnnotationsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// APIKeyRequest an Application Insights component API Key creation request definition. +type APIKeyRequest struct { + // Name - The name of the API Key. + Name *string `json:"name,omitempty"` + // LinkedReadProperties - The read access rights of this API Key. + LinkedReadProperties *[]string `json:"linkedReadProperties,omitempty"` + // LinkedWriteProperties - The write access rights of this API Key. + LinkedWriteProperties *[]string `json:"linkedWriteProperties,omitempty"` +} + +// ApplicationInsightsComponent an Application Insights component definition. +type ApplicationInsightsComponent struct { + autorest.Response `json:"-"` + // Kind - The kind of application that this component refers to, used to customize UI. This value is a freeform string, values should typically be one of the following: web, ios, other, store, java, phone. + Kind *string `json:"kind,omitempty"` + // Etag - Resource etag + Etag *string `json:"etag,omitempty"` + // ApplicationInsightsComponentProperties - Properties that define an Application Insights component resource. + *ApplicationInsightsComponentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponent. +func (aic ApplicationInsightsComponent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aic.Kind != nil { + objectMap["kind"] = aic.Kind + } + if aic.Etag != nil { + objectMap["etag"] = aic.Etag + } + if aic.ApplicationInsightsComponentProperties != nil { + objectMap["properties"] = aic.ApplicationInsightsComponentProperties + } + if aic.Location != nil { + objectMap["location"] = aic.Location + } + if aic.Tags != nil { + objectMap["tags"] = aic.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationInsightsComponent struct. +func (aic *ApplicationInsightsComponent) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + aic.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + aic.Etag = &etag + } + case "properties": + if v != nil { + var applicationInsightsComponentProperties ApplicationInsightsComponentProperties + err = json.Unmarshal(*v, &applicationInsightsComponentProperties) + if err != nil { + return err + } + aic.ApplicationInsightsComponentProperties = &applicationInsightsComponentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + aic.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + aic.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + aic.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + aic.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + aic.Tags = tags + } + } + } + + return nil +} + +// ApplicationInsightsComponentAnalyticsItem properties that define an Analytics item that is associated to +// an Application Insights component. +type ApplicationInsightsComponentAnalyticsItem struct { + autorest.Response `json:"-"` + // ID - Internally assigned unique id of the item definition. + ID *string `json:"Id,omitempty"` + // Name - The user-defined name of the item. + Name *string `json:"Name,omitempty"` + // Content - The content of this item + Content *string `json:"Content,omitempty"` + // Version - READ-ONLY; This instance's version of the data model. This can change as new features are added. + Version *string `json:"Version,omitempty"` + // Scope - Enum indicating if this item definition is owned by a specific user or is shared between all users with access to the Application Insights component. Possible values include: 'ItemScopeShared', 'ItemScopeUser' + Scope ItemScope `json:"Scope,omitempty"` + // Type - Enum indicating the type of the Analytics item. Possible values include: 'ItemTypeQuery', 'ItemTypeFunction', 'ItemTypeFolder', 'ItemTypeRecent' + Type ItemType `json:"Type,omitempty"` + // TimeCreated - READ-ONLY; Date and time in UTC when this item was created. + TimeCreated *string `json:"TimeCreated,omitempty"` + // TimeModified - READ-ONLY; Date and time in UTC of the last modification that was made to this item. + TimeModified *string `json:"TimeModified,omitempty"` + Properties *ApplicationInsightsComponentAnalyticsItemProperties `json:"Properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentAnalyticsItem. +func (aicai ApplicationInsightsComponentAnalyticsItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aicai.ID != nil { + objectMap["Id"] = aicai.ID + } + if aicai.Name != nil { + objectMap["Name"] = aicai.Name + } + if aicai.Content != nil { + objectMap["Content"] = aicai.Content + } + if aicai.Scope != "" { + objectMap["Scope"] = aicai.Scope + } + if aicai.Type != "" { + objectMap["Type"] = aicai.Type + } + if aicai.Properties != nil { + objectMap["Properties"] = aicai.Properties + } + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentAnalyticsItemProperties a set of properties that can be defined in the +// context of a specific item type. Each type may have its own properties. +type ApplicationInsightsComponentAnalyticsItemProperties struct { + // FunctionAlias - A function alias, used when the type of the item is Function + FunctionAlias *string `json:"functionAlias,omitempty"` +} + +// ApplicationInsightsComponentAPIKey properties that define an API key of an Application Insights +// Component. +type ApplicationInsightsComponentAPIKey struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The unique ID of the API key inside an Application Insights component. It is auto generated when the API key is created. + ID *string `json:"id,omitempty"` + // APIKey - READ-ONLY; The API key value. It will be only return once when the API Key was created. + APIKey *string `json:"apiKey,omitempty"` + // CreatedDate - The create date of this API key. + CreatedDate *string `json:"createdDate,omitempty"` + // Name - The name of the API key. + Name *string `json:"name,omitempty"` + // LinkedReadProperties - The read access rights of this API Key. + LinkedReadProperties *[]string `json:"linkedReadProperties,omitempty"` + // LinkedWriteProperties - The write access rights of this API Key. + LinkedWriteProperties *[]string `json:"linkedWriteProperties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentAPIKey. +func (aicak ApplicationInsightsComponentAPIKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aicak.CreatedDate != nil { + objectMap["createdDate"] = aicak.CreatedDate + } + if aicak.Name != nil { + objectMap["name"] = aicak.Name + } + if aicak.LinkedReadProperties != nil { + objectMap["linkedReadProperties"] = aicak.LinkedReadProperties + } + if aicak.LinkedWriteProperties != nil { + objectMap["linkedWriteProperties"] = aicak.LinkedWriteProperties + } + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentAPIKeyListResult describes the list of API Keys of an Application Insights +// Component. +type ApplicationInsightsComponentAPIKeyListResult struct { + autorest.Response `json:"-"` + // Value - List of API Key definitions. + Value *[]ApplicationInsightsComponentAPIKey `json:"value,omitempty"` +} + +// ApplicationInsightsComponentAvailableFeatures an Application Insights component available features. +type ApplicationInsightsComponentAvailableFeatures struct { + autorest.Response `json:"-"` + // Result - READ-ONLY; A list of Application Insights component feature. + Result *[]ApplicationInsightsComponentFeature `json:"Result,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentAvailableFeatures. +func (aicaf ApplicationInsightsComponentAvailableFeatures) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentBillingFeatures an Application Insights component billing features +type ApplicationInsightsComponentBillingFeatures struct { + autorest.Response `json:"-"` + // DataVolumeCap - An Application Insights component daily data volume cap + DataVolumeCap *ApplicationInsightsComponentDataVolumeCap `json:"DataVolumeCap,omitempty"` + // CurrentBillingFeatures - Current enabled pricing plan. When the component is in the Enterprise plan, this will list both 'Basic' and 'Application Insights Enterprise'. + CurrentBillingFeatures *[]string `json:"CurrentBillingFeatures,omitempty"` +} + +// ApplicationInsightsComponentDataVolumeCap an Application Insights component daily data volume cap +type ApplicationInsightsComponentDataVolumeCap struct { + // Cap - Daily data volume cap in GB. + Cap *float64 `json:"Cap,omitempty"` + // ResetTime - READ-ONLY; Daily data volume cap UTC reset hour. + ResetTime *int32 `json:"ResetTime,omitempty"` + // WarningThreshold - Reserved, not used for now. + WarningThreshold *int32 `json:"WarningThreshold,omitempty"` + // StopSendNotificationWhenHitThreshold - Reserved, not used for now. + StopSendNotificationWhenHitThreshold *bool `json:"StopSendNotificationWhenHitThreshold,omitempty"` + // StopSendNotificationWhenHitCap - Do not send a notification email when the daily data volume cap is met. + StopSendNotificationWhenHitCap *bool `json:"StopSendNotificationWhenHitCap,omitempty"` + // MaxHistoryCap - READ-ONLY; Maximum daily data volume cap that the user can set for this component. + MaxHistoryCap *float64 `json:"MaxHistoryCap,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentDataVolumeCap. +func (aicdvc ApplicationInsightsComponentDataVolumeCap) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aicdvc.Cap != nil { + objectMap["Cap"] = aicdvc.Cap + } + if aicdvc.WarningThreshold != nil { + objectMap["WarningThreshold"] = aicdvc.WarningThreshold + } + if aicdvc.StopSendNotificationWhenHitThreshold != nil { + objectMap["StopSendNotificationWhenHitThreshold"] = aicdvc.StopSendNotificationWhenHitThreshold + } + if aicdvc.StopSendNotificationWhenHitCap != nil { + objectMap["StopSendNotificationWhenHitCap"] = aicdvc.StopSendNotificationWhenHitCap + } + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentExportConfiguration properties that define a Continuous Export +// configuration. +type ApplicationInsightsComponentExportConfiguration struct { + autorest.Response `json:"-"` + // ExportID - READ-ONLY; The unique ID of the export configuration inside an Application Insights component. It is auto generated when the Continuous Export configuration is created. + ExportID *string `json:"ExportId,omitempty"` + // InstrumentationKey - READ-ONLY; The instrumentation key of the Application Insights component. + InstrumentationKey *string `json:"InstrumentationKey,omitempty"` + // RecordTypes - This comma separated list of document types that will be exported. The possible values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. + RecordTypes *string `json:"RecordTypes,omitempty"` + // ApplicationName - READ-ONLY; The name of the Application Insights component. + ApplicationName *string `json:"ApplicationName,omitempty"` + // SubscriptionID - READ-ONLY; The subscription of the Application Insights component. + SubscriptionID *string `json:"SubscriptionId,omitempty"` + // ResourceGroup - READ-ONLY; The resource group of the Application Insights component. + ResourceGroup *string `json:"ResourceGroup,omitempty"` + // DestinationStorageSubscriptionID - READ-ONLY; The destination storage account subscription ID. + DestinationStorageSubscriptionID *string `json:"DestinationStorageSubscriptionId,omitempty"` + // DestinationStorageLocationID - READ-ONLY; The destination account location ID. + DestinationStorageLocationID *string `json:"DestinationStorageLocationId,omitempty"` + // DestinationAccountID - READ-ONLY; The name of destination account. + DestinationAccountID *string `json:"DestinationAccountId,omitempty"` + // DestinationType - READ-ONLY; The destination type. + DestinationType *string `json:"DestinationType,omitempty"` + // IsUserEnabled - READ-ONLY; This will be 'true' if the Continuous Export configuration is enabled, otherwise it will be 'false'. + IsUserEnabled *string `json:"IsUserEnabled,omitempty"` + // LastUserUpdate - READ-ONLY; Last time the Continuous Export configuration was updated. + LastUserUpdate *string `json:"LastUserUpdate,omitempty"` + // NotificationQueueEnabled - Deprecated + NotificationQueueEnabled *string `json:"NotificationQueueEnabled,omitempty"` + // ExportStatus - READ-ONLY; This indicates current Continuous Export configuration status. The possible values are 'Preparing', 'Success', 'Failure'. + ExportStatus *string `json:"ExportStatus,omitempty"` + // LastSuccessTime - READ-ONLY; The last time data was successfully delivered to the destination storage container for this Continuous Export configuration. + LastSuccessTime *string `json:"LastSuccessTime,omitempty"` + // LastGapTime - READ-ONLY; The last time the Continuous Export configuration started failing. + LastGapTime *string `json:"LastGapTime,omitempty"` + // PermanentErrorReason - READ-ONLY; This is the reason the Continuous Export configuration started failing. It can be 'AzureStorageNotFound' or 'AzureStorageAccessDenied'. + PermanentErrorReason *string `json:"PermanentErrorReason,omitempty"` + // StorageName - READ-ONLY; The name of the destination storage account. + StorageName *string `json:"StorageName,omitempty"` + // ContainerName - READ-ONLY; The name of the destination storage container. + ContainerName *string `json:"ContainerName,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentExportConfiguration. +func (aicec ApplicationInsightsComponentExportConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aicec.RecordTypes != nil { + objectMap["RecordTypes"] = aicec.RecordTypes + } + if aicec.NotificationQueueEnabled != nil { + objectMap["NotificationQueueEnabled"] = aicec.NotificationQueueEnabled + } + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentExportRequest an Application Insights component Continuous Export +// configuration request definition. +type ApplicationInsightsComponentExportRequest struct { + // RecordTypes - The document types to be exported, as comma separated values. Allowed values include 'Requests', 'Event', 'Exceptions', 'Metrics', 'PageViews', 'PageViewPerformance', 'Rdd', 'PerformanceCounters', 'Availability', 'Messages'. + RecordTypes *string `json:"RecordTypes,omitempty"` + // DestinationType - The Continuous Export destination type. This has to be 'Blob'. + DestinationType *string `json:"DestinationType,omitempty"` + // DestinationAddress - The SAS URL for the destination storage container. It must grant write permission. + DestinationAddress *string `json:"DestinationAddress,omitempty"` + // IsEnabled - Set to 'true' to create a Continuous Export configuration as enabled, otherwise set it to 'false'. + IsEnabled *string `json:"IsEnabled,omitempty"` + // NotificationQueueEnabled - Deprecated + NotificationQueueEnabled *string `json:"NotificationQueueEnabled,omitempty"` + // NotificationQueueURI - Deprecated + NotificationQueueURI *string `json:"NotificationQueueUri,omitempty"` + // DestinationStorageSubscriptionID - The subscription ID of the destination storage container. + DestinationStorageSubscriptionID *string `json:"DestinationStorageSubscriptionId,omitempty"` + // DestinationStorageLocationID - The location ID of the destination storage container. + DestinationStorageLocationID *string `json:"DestinationStorageLocationId,omitempty"` + // DestinationAccountID - The name of destination storage account. + DestinationAccountID *string `json:"DestinationAccountId,omitempty"` +} + +// ApplicationInsightsComponentFavorite properties that define a favorite that is associated to an +// Application Insights component. +type ApplicationInsightsComponentFavorite struct { + autorest.Response `json:"-"` + // Name - The user-defined name of the favorite. + Name *string `json:"Name,omitempty"` + // Config - Configuration of this particular favorite, which are driven by the Azure portal UX. Configuration data is a string containing valid JSON + Config *string `json:"Config,omitempty"` + // Version - This instance's version of the data model. This can change as new features are added that can be marked favorite. Current examples include MetricsExplorer (ME) and Search. + Version *string `json:"Version,omitempty"` + // FavoriteID - READ-ONLY; Internally assigned unique id of the favorite definition. + FavoriteID *string `json:"FavoriteId,omitempty"` + // FavoriteType - Enum indicating if this favorite definition is owned by a specific user or is shared between all users with access to the Application Insights component. Possible values include: 'FavoriteTypeShared', 'FavoriteTypeUser' + FavoriteType FavoriteType `json:"FavoriteType,omitempty"` + // SourceType - The source of the favorite definition. + SourceType *string `json:"SourceType,omitempty"` + // TimeModified - READ-ONLY; Date and time in UTC of the last modification that was made to this favorite definition. + TimeModified *string `json:"TimeModified,omitempty"` + // Tags - A list of 0 or more tags that are associated with this favorite definition + Tags *[]string `json:"Tags,omitempty"` + // Category - Favorite category, as defined by the user at creation time. + Category *string `json:"Category,omitempty"` + // IsGeneratedFromTemplate - Flag denoting wether or not this favorite was generated from a template. + IsGeneratedFromTemplate *bool `json:"IsGeneratedFromTemplate,omitempty"` + // UserID - READ-ONLY; Unique user id of the specific user that owns this favorite. + UserID *string `json:"UserId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentFavorite. +func (aicf ApplicationInsightsComponentFavorite) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aicf.Name != nil { + objectMap["Name"] = aicf.Name + } + if aicf.Config != nil { + objectMap["Config"] = aicf.Config + } + if aicf.Version != nil { + objectMap["Version"] = aicf.Version + } + if aicf.FavoriteType != "" { + objectMap["FavoriteType"] = aicf.FavoriteType + } + if aicf.SourceType != nil { + objectMap["SourceType"] = aicf.SourceType + } + if aicf.Tags != nil { + objectMap["Tags"] = aicf.Tags + } + if aicf.Category != nil { + objectMap["Category"] = aicf.Category + } + if aicf.IsGeneratedFromTemplate != nil { + objectMap["IsGeneratedFromTemplate"] = aicf.IsGeneratedFromTemplate + } + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentFeature an Application Insights component daily data volume cap status +type ApplicationInsightsComponentFeature struct { + // FeatureName - READ-ONLY; The pricing feature name. + FeatureName *string `json:"FeatureName,omitempty"` + // MeterID - READ-ONLY; The meter id used for the feature. + MeterID *string `json:"MeterId,omitempty"` + // MeterRateFrequency - READ-ONLY; The meter rate for the feature's meter. + MeterRateFrequency *string `json:"MeterRateFrequency,omitempty"` + // ResouceID - READ-ONLY; Reserved, not used now. + ResouceID *string `json:"ResouceId,omitempty"` + // IsHidden - READ-ONLY; Reserved, not used now. + IsHidden *bool `json:"IsHidden,omitempty"` + // Capabilities - READ-ONLY; A list of Application Insights component feature capability. + Capabilities *[]ApplicationInsightsComponentFeatureCapability `json:"Capabilities,omitempty"` + // Title - READ-ONLY; Display name of the feature. + Title *string `json:"Title,omitempty"` + // IsMainFeature - READ-ONLY; Whether can apply addon feature on to it. + IsMainFeature *bool `json:"IsMainFeature,omitempty"` + // SupportedAddonFeatures - READ-ONLY; The add on features on main feature. + SupportedAddonFeatures *string `json:"SupportedAddonFeatures,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentFeature. +func (aicf ApplicationInsightsComponentFeature) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentFeatureCapabilities an Application Insights component feature capabilities +type ApplicationInsightsComponentFeatureCapabilities struct { + autorest.Response `json:"-"` + // SupportExportData - READ-ONLY; Whether allow to use continuous export feature. + SupportExportData *bool `json:"SupportExportData,omitempty"` + // BurstThrottlePolicy - READ-ONLY; Reserved, not used now. + BurstThrottlePolicy *string `json:"BurstThrottlePolicy,omitempty"` + // MetadataClass - READ-ONLY; Reserved, not used now. + MetadataClass *string `json:"MetadataClass,omitempty"` + // LiveStreamMetrics - READ-ONLY; Reserved, not used now. + LiveStreamMetrics *bool `json:"LiveStreamMetrics,omitempty"` + // ApplicationMap - READ-ONLY; Reserved, not used now. + ApplicationMap *bool `json:"ApplicationMap,omitempty"` + // WorkItemIntegration - READ-ONLY; Whether allow to use work item integration feature. + WorkItemIntegration *bool `json:"WorkItemIntegration,omitempty"` + // PowerBIIntegration - READ-ONLY; Reserved, not used now. + PowerBIIntegration *bool `json:"PowerBIIntegration,omitempty"` + // OpenSchema - READ-ONLY; Reserved, not used now. + OpenSchema *bool `json:"OpenSchema,omitempty"` + // ProactiveDetection - READ-ONLY; Reserved, not used now. + ProactiveDetection *bool `json:"ProactiveDetection,omitempty"` + // AnalyticsIntegration - READ-ONLY; Reserved, not used now. + AnalyticsIntegration *bool `json:"AnalyticsIntegration,omitempty"` + // MultipleStepWebTest - READ-ONLY; Whether allow to use multiple steps web test feature. + MultipleStepWebTest *bool `json:"MultipleStepWebTest,omitempty"` + // APIAccessLevel - READ-ONLY; Reserved, not used now. + APIAccessLevel *string `json:"ApiAccessLevel,omitempty"` + // TrackingType - READ-ONLY; The application insights component used tracking type. + TrackingType *string `json:"TrackingType,omitempty"` + // DailyCap - READ-ONLY; Daily data volume cap in GB. + DailyCap *float64 `json:"DailyCap,omitempty"` + // DailyCapResetTime - READ-ONLY; Daily data volume cap UTC reset hour. + DailyCapResetTime *float64 `json:"DailyCapResetTime,omitempty"` + // ThrottleRate - READ-ONLY; Reserved, not used now. + ThrottleRate *float64 `json:"ThrottleRate,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentFeatureCapabilities. +func (aicfc ApplicationInsightsComponentFeatureCapabilities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentFeatureCapability an Application Insights component feature capability +type ApplicationInsightsComponentFeatureCapability struct { + // Name - READ-ONLY; The name of the capability. + Name *string `json:"Name,omitempty"` + // Description - READ-ONLY; The description of the capability. + Description *string `json:"Description,omitempty"` + // Value - READ-ONLY; The value of the capability. + Value *string `json:"Value,omitempty"` + // Unit - READ-ONLY; The unit of the capability. + Unit *string `json:"Unit,omitempty"` + // MeterID - READ-ONLY; The meter used for the capability. + MeterID *string `json:"MeterId,omitempty"` + // MeterRateFrequency - READ-ONLY; The meter rate of the meter. + MeterRateFrequency *string `json:"MeterRateFrequency,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentFeatureCapability. +func (aicfc ApplicationInsightsComponentFeatureCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentListResult describes the list of Application Insights Resources. +type ApplicationInsightsComponentListResult struct { + autorest.Response `json:"-"` + // Value - List of Application Insights component definitions. + Value *[]ApplicationInsightsComponent `json:"value,omitempty"` + // NextLink - The URI to get the next set of Application Insights component definitions if too many components where returned in the result set. + NextLink *string `json:"nextLink,omitempty"` +} + +// ApplicationInsightsComponentListResultIterator provides access to a complete listing of +// ApplicationInsightsComponent values. +type ApplicationInsightsComponentListResultIterator struct { + i int + page ApplicationInsightsComponentListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ApplicationInsightsComponentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationInsightsComponentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ApplicationInsightsComponentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ApplicationInsightsComponentListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ApplicationInsightsComponentListResultIterator) Response() ApplicationInsightsComponentListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ApplicationInsightsComponentListResultIterator) Value() ApplicationInsightsComponent { + if !iter.page.NotDone() { + return ApplicationInsightsComponent{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ApplicationInsightsComponentListResultIterator type. +func NewApplicationInsightsComponentListResultIterator(page ApplicationInsightsComponentListResultPage) ApplicationInsightsComponentListResultIterator { + return ApplicationInsightsComponentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aiclr ApplicationInsightsComponentListResult) IsEmpty() bool { + return aiclr.Value == nil || len(*aiclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (aiclr ApplicationInsightsComponentListResult) hasNextLink() bool { + return aiclr.NextLink != nil && len(*aiclr.NextLink) != 0 +} + +// applicationInsightsComponentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aiclr ApplicationInsightsComponentListResult) applicationInsightsComponentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !aiclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aiclr.NextLink))) +} + +// ApplicationInsightsComponentListResultPage contains a page of ApplicationInsightsComponent values. +type ApplicationInsightsComponentListResultPage struct { + fn func(context.Context, ApplicationInsightsComponentListResult) (ApplicationInsightsComponentListResult, error) + aiclr ApplicationInsightsComponentListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ApplicationInsightsComponentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationInsightsComponentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.aiclr) + if err != nil { + return err + } + page.aiclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ApplicationInsightsComponentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ApplicationInsightsComponentListResultPage) NotDone() bool { + return !page.aiclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ApplicationInsightsComponentListResultPage) Response() ApplicationInsightsComponentListResult { + return page.aiclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ApplicationInsightsComponentListResultPage) Values() []ApplicationInsightsComponent { + if page.aiclr.IsEmpty() { + return nil + } + return *page.aiclr.Value +} + +// Creates a new instance of the ApplicationInsightsComponentListResultPage type. +func NewApplicationInsightsComponentListResultPage(cur ApplicationInsightsComponentListResult, getNextPage func(context.Context, ApplicationInsightsComponentListResult) (ApplicationInsightsComponentListResult, error)) ApplicationInsightsComponentListResultPage { + return ApplicationInsightsComponentListResultPage{ + fn: getNextPage, + aiclr: cur, + } +} + +// ApplicationInsightsComponentProactiveDetectionConfiguration properties that define a ProactiveDetection +// configuration. +type ApplicationInsightsComponentProactiveDetectionConfiguration struct { + autorest.Response `json:"-"` + // Name - The rule name + Name *string `json:"Name,omitempty"` + // Enabled - A flag that indicates whether this rule is enabled by the user + Enabled *bool `json:"Enabled,omitempty"` + // SendEmailsToSubscriptionOwners - A flag that indicated whether notifications on this rule should be sent to subscription owners + SendEmailsToSubscriptionOwners *bool `json:"SendEmailsToSubscriptionOwners,omitempty"` + // CustomEmails - Custom email addresses for this rule notifications + CustomEmails *[]string `json:"CustomEmails,omitempty"` + // LastUpdatedTime - The last time this rule was updated + LastUpdatedTime *string `json:"LastUpdatedTime,omitempty"` + // RuleDefinitions - Static definitions of the ProactiveDetection configuration rule (same values for all components). + RuleDefinitions *ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions `json:"RuleDefinitions,omitempty"` +} + +// ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions static definitions of the +// ProactiveDetection configuration rule (same values for all components). +type ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions struct { + // Name - The rule name + Name *string `json:"Name,omitempty"` + // DisplayName - The rule name as it is displayed in UI + DisplayName *string `json:"DisplayName,omitempty"` + // Description - The rule description + Description *string `json:"Description,omitempty"` + // HelpURL - URL which displays additional info about the proactive detection rule + HelpURL *string `json:"HelpUrl,omitempty"` + // IsHidden - A flag indicating whether the rule is hidden (from the UI) + IsHidden *bool `json:"IsHidden,omitempty"` + // IsEnabledByDefault - A flag indicating whether the rule is enabled by default + IsEnabledByDefault *bool `json:"IsEnabledByDefault,omitempty"` + // IsInPreview - A flag indicating whether the rule is in preview + IsInPreview *bool `json:"IsInPreview,omitempty"` + // SupportsEmailNotifications - A flag indicating whether email notifications are supported for detections for this rule + SupportsEmailNotifications *bool `json:"SupportsEmailNotifications,omitempty"` +} + +// ApplicationInsightsComponentProperties properties that define an Application Insights component +// resource. +type ApplicationInsightsComponentProperties struct { + // ApplicationID - READ-ONLY; The unique ID of your application. This field mirrors the 'Name' field and cannot be changed. + ApplicationID *string `json:"ApplicationId,omitempty"` + // AppID - READ-ONLY; Application Insights Unique ID for your Application. + AppID *string `json:"AppId,omitempty"` + // Name - READ-ONLY; Application name. + Name *string `json:"Name,omitempty"` + // ApplicationType - Type of application being monitored. Possible values include: 'ApplicationTypeWeb', 'ApplicationTypeOther' + ApplicationType ApplicationType `json:"Application_Type,omitempty"` + // FlowType - Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API. Possible values include: 'FlowTypeBluefield' + FlowType FlowType `json:"Flow_Type,omitempty"` + // RequestSource - Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'. Possible values include: 'RequestSourceRest' + RequestSource RequestSource `json:"Request_Source,omitempty"` + // InstrumentationKey - READ-ONLY; Application Insights Instrumentation key. A read-only value that applications can use to identify the destination for all telemetry sent to Azure Application Insights. This value will be supplied upon construction of each new Application Insights component. + InstrumentationKey *string `json:"InstrumentationKey,omitempty"` + // CreationDate - READ-ONLY; Creation Date for the Application Insights component, in ISO 8601 format. + CreationDate *date.Time `json:"CreationDate,omitempty"` + // TenantID - READ-ONLY; Azure Tenant Id. + TenantID *string `json:"TenantId,omitempty"` + // HockeyAppID - The unique application ID created when a new application is added to HockeyApp, used for communications with HockeyApp. + HockeyAppID *string `json:"HockeyAppId,omitempty"` + // HockeyAppToken - READ-ONLY; Token used to authenticate communications with between Application Insights and HockeyApp. + HockeyAppToken *string `json:"HockeyAppToken,omitempty"` + // ProvisioningState - READ-ONLY; Current state of this component: whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. + ProvisioningState *string `json:"provisioningState,omitempty"` + // SamplingPercentage - Percentage of the data produced by the application being monitored that is being sampled for Application Insights telemetry. + SamplingPercentage *float64 `json:"SamplingPercentage,omitempty"` + // ConnectionString - READ-ONLY; Application Insights component connection string. + ConnectionString *string `json:"ConnectionString,omitempty"` + // RetentionInDays - READ-ONLY; Retention period in days. + RetentionInDays *int32 `json:"RetentionInDays,omitempty"` + // DisableIPMasking - Disable IP masking. + DisableIPMasking *bool `json:"DisableIpMasking,omitempty"` + // ImmediatePurgeDataOn30Days - Purge data immediately after 30 days. + ImmediatePurgeDataOn30Days *bool `json:"ImmediatePurgeDataOn30Days,omitempty"` + // WorkspaceResourceID - Resource Id of the log analytics workspace which the data will be ingested to. This property is required to create an application with this API version. Applications from older versions will not have this property. + WorkspaceResourceID *string `json:"WorkspaceResourceId,omitempty"` + // LaMigrationDate - READ-ONLY; The date which the component got migrated to LA, in ISO 8601 format. + LaMigrationDate *date.Time `json:"LaMigrationDate,omitempty"` + // PrivateLinkScopedResources - READ-ONLY; List of linked private link scope resources. + PrivateLinkScopedResources *[]PrivateLinkScopedResource `json:"PrivateLinkScopedResources,omitempty"` + // PublicNetworkAccessForIngestion - The network access type for accessing Application Insights ingestion. Possible values include: 'PublicNetworkAccessTypeEnabled', 'PublicNetworkAccessTypeDisabled' + PublicNetworkAccessForIngestion PublicNetworkAccessType `json:"publicNetworkAccessForIngestion,omitempty"` + // PublicNetworkAccessForQuery - The network access type for accessing Application Insights query. Possible values include: 'PublicNetworkAccessTypeEnabled', 'PublicNetworkAccessTypeDisabled' + PublicNetworkAccessForQuery PublicNetworkAccessType `json:"publicNetworkAccessForQuery,omitempty"` + // IngestionMode - Indicates the flow of the ingestion. Possible values include: 'IngestionModeApplicationInsights', 'IngestionModeApplicationInsightsWithDiagnosticSettings', 'IngestionModeLogAnalytics' + IngestionMode IngestionMode `json:"IngestionMode,omitempty"` + // DisableLocalAuth - Disable Non-AAD based Auth. + DisableLocalAuth *bool `json:"DisableLocalAuth,omitempty"` + // ForceCustomerStorageForProfiler - Force users to create their own storage account for profiler and debugger. + ForceCustomerStorageForProfiler *bool `json:"ForceCustomerStorageForProfiler,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentProperties. +func (aicp ApplicationInsightsComponentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aicp.ApplicationType != "" { + objectMap["Application_Type"] = aicp.ApplicationType + } + if aicp.FlowType != "" { + objectMap["Flow_Type"] = aicp.FlowType + } + if aicp.RequestSource != "" { + objectMap["Request_Source"] = aicp.RequestSource + } + if aicp.HockeyAppID != nil { + objectMap["HockeyAppId"] = aicp.HockeyAppID + } + if aicp.SamplingPercentage != nil { + objectMap["SamplingPercentage"] = aicp.SamplingPercentage + } + if aicp.DisableIPMasking != nil { + objectMap["DisableIpMasking"] = aicp.DisableIPMasking + } + if aicp.ImmediatePurgeDataOn30Days != nil { + objectMap["ImmediatePurgeDataOn30Days"] = aicp.ImmediatePurgeDataOn30Days + } + if aicp.WorkspaceResourceID != nil { + objectMap["WorkspaceResourceId"] = aicp.WorkspaceResourceID + } + if aicp.PublicNetworkAccessForIngestion != "" { + objectMap["publicNetworkAccessForIngestion"] = aicp.PublicNetworkAccessForIngestion + } + if aicp.PublicNetworkAccessForQuery != "" { + objectMap["publicNetworkAccessForQuery"] = aicp.PublicNetworkAccessForQuery + } + if aicp.IngestionMode != "" { + objectMap["IngestionMode"] = aicp.IngestionMode + } + if aicp.DisableLocalAuth != nil { + objectMap["DisableLocalAuth"] = aicp.DisableLocalAuth + } + if aicp.ForceCustomerStorageForProfiler != nil { + objectMap["ForceCustomerStorageForProfiler"] = aicp.ForceCustomerStorageForProfiler + } + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentQuotaStatus an Application Insights component daily data volume cap status +type ApplicationInsightsComponentQuotaStatus struct { + autorest.Response `json:"-"` + // AppID - READ-ONLY; The Application ID for the Application Insights component. + AppID *string `json:"AppId,omitempty"` + // ShouldBeThrottled - READ-ONLY; The daily data volume cap is met, and data ingestion will be stopped. + ShouldBeThrottled *bool `json:"ShouldBeThrottled,omitempty"` + // ExpirationTime - READ-ONLY; Date and time when the daily data volume cap will be reset, and data ingestion will resume. + ExpirationTime *string `json:"ExpirationTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentQuotaStatus. +func (aicqs ApplicationInsightsComponentQuotaStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ApplicationInsightsComponentWebTestLocation properties that define a web test location available to an +// Application Insights Component. +type ApplicationInsightsComponentWebTestLocation struct { + // DisplayName - READ-ONLY; The display name of the web test location. + DisplayName *string `json:"DisplayName,omitempty"` + // Tag - READ-ONLY; Internally defined geographic location tag. + Tag *string `json:"Tag,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationInsightsComponentWebTestLocation. +func (aicwtl ApplicationInsightsComponentWebTestLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ApplicationInsightsWebTestLocationsListResult describes the list of web test locations available to an +// Application Insights Component. +type ApplicationInsightsWebTestLocationsListResult struct { + autorest.Response `json:"-"` + // Value - List of web test locations. + Value *[]ApplicationInsightsComponentWebTestLocation `json:"value,omitempty"` +} + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ComponentLinkedStorageAccounts an Application Insights component linked storage accounts +type ComponentLinkedStorageAccounts struct { + autorest.Response `json:"-"` + // LinkedStorageAccountsProperties - The properties of the linked storage accounts. + *LinkedStorageAccountsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ComponentLinkedStorageAccounts. +func (clsa ComponentLinkedStorageAccounts) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if clsa.LinkedStorageAccountsProperties != nil { + objectMap["properties"] = clsa.LinkedStorageAccountsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ComponentLinkedStorageAccounts struct. +func (clsa *ComponentLinkedStorageAccounts) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var linkedStorageAccountsProperties LinkedStorageAccountsProperties + err = json.Unmarshal(*v, &linkedStorageAccountsProperties) + if err != nil { + return err + } + clsa.LinkedStorageAccountsProperties = &linkedStorageAccountsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + clsa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + clsa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + clsa.Type = &typeVar + } + } + } + + return nil +} + +// ComponentLinkedStorageAccountsPatch an Application Insights component linked storage accounts patch +type ComponentLinkedStorageAccountsPatch struct { + // LinkedStorageAccountsProperties - The properties of the linked storage accounts. + *LinkedStorageAccountsProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ComponentLinkedStorageAccountsPatch. +func (clsap ComponentLinkedStorageAccountsPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if clsap.LinkedStorageAccountsProperties != nil { + objectMap["properties"] = clsap.LinkedStorageAccountsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ComponentLinkedStorageAccountsPatch struct. +func (clsap *ComponentLinkedStorageAccountsPatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var linkedStorageAccountsProperties LinkedStorageAccountsProperties + err = json.Unmarshal(*v, &linkedStorageAccountsProperties) + if err != nil { + return err + } + clsap.LinkedStorageAccountsProperties = &linkedStorageAccountsProperties + } + } + } + + return nil +} + +// ComponentPurgeBody describes the body of a purge request for an App Insights component +type ComponentPurgeBody struct { + // Table - Table from which to purge data. + Table *string `json:"table,omitempty"` + // Filters - The set of columns and filters (queries) to run over them to purge the resulting data. + Filters *[]ComponentPurgeBodyFilters `json:"filters,omitempty"` +} + +// ComponentPurgeBodyFilters user-defined filters to return data which will be purged from the table. +type ComponentPurgeBodyFilters struct { + // Column - The column of the table over which the given query should run + Column *string `json:"column,omitempty"` + // Operator - A query operator to evaluate over the provided column and value(s). Supported operators are ==, =~, in, in~, >, >=, <, <=, between, and have the same behavior as they would in a KQL query. + Operator *string `json:"operator,omitempty"` + // Value - the value for the operator to function over. This can be a number (e.g., > 100), a string (timestamp >= '2017-09-01') or array of values. + Value interface{} `json:"value,omitempty"` + // Key - When filtering over custom dimensions, this key will be used as the name of the custom dimension. + Key *string `json:"key,omitempty"` +} + +// ComponentPurgeResponse response containing operationId for a specific purge action. +type ComponentPurgeResponse struct { + autorest.Response `json:"-"` + // OperationID - Id to use when querying for status for a particular purge operation. + OperationID *string `json:"operationId,omitempty"` +} + +// ComponentPurgeStatusResponse response containing status for a specific purge operation. +type ComponentPurgeStatusResponse struct { + autorest.Response `json:"-"` + // Status - Status of the operation represented by the requested Id. Possible values include: 'PurgeStatePending', 'PurgeStateCompleted' + Status PurgeState `json:"status,omitempty"` +} + +// ComponentsResource an azure resource object +type ComponentsResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ComponentsResource. +func (cr ComponentsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cr.Location != nil { + objectMap["location"] = cr.Location + } + if cr.Tags != nil { + objectMap["tags"] = cr.Tags + } + return json.Marshal(objectMap) +} + +// ErrorFieldContract error Field contract. +type ErrorFieldContract struct { + // Code - Property level error code. + Code *string `json:"code,omitempty"` + // Message - Human-readable representation of property-level error. + Message *string `json:"message,omitempty"` + // Target - Property name. + Target *string `json:"target,omitempty"` +} + +// ErrorResponse error response indicates Insights service is not able to process the incoming request. The +// reason is provided in the error message. +type ErrorResponse struct { + // Code - Error code. + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// ErrorResponseComponents ... +type ErrorResponseComponents struct { + // Error - Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. + Error *ErrorResponseComponentsError `json:"error,omitempty"` +} + +// ErrorResponseComponentsError error response indicates Insights service is not able to process the +// incoming request. The reason is provided in the error message. +type ErrorResponseComponentsError struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorResponseComponentsError. +func (erc ErrorResponseComponentsError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponseLinkedStorage ... +type ErrorResponseLinkedStorage struct { + // Error - Error response indicates Insights service is not able to process the incoming request. The reason is provided in the error message. + Error *ErrorResponseLinkedStorageError `json:"error,omitempty"` +} + +// ErrorResponseLinkedStorageError error response indicates Insights service is not able to process the +// incoming request. The reason is provided in the error message. +type ErrorResponseLinkedStorageError struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorResponseLinkedStorageError. +func (erls ErrorResponseLinkedStorageError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// InnerError inner error +type InnerError struct { + // Diagnosticcontext - Provides correlation for request + Diagnosticcontext *string `json:"diagnosticcontext,omitempty"` + // Time - Request time + Time *date.Time `json:"time,omitempty"` +} + +// LinkedStorageAccountsProperties an Application Insights component linked storage account +type LinkedStorageAccountsProperties struct { + // LinkedStorageAccount - Linked storage account resource ID + LinkedStorageAccount *string `json:"linkedStorageAccount,omitempty"` +} + +// LinkProperties contains a sourceId and workbook resource id to link two resources. +type LinkProperties struct { + // SourceID - The source Azure resource id + SourceID *string `json:"sourceId,omitempty"` + // TargetID - The workbook Azure resource id + TargetID *string `json:"targetId,omitempty"` + // Category - The category of workbook + Category *string `json:"category,omitempty"` +} + +// ListAnnotation ... +type ListAnnotation struct { + autorest.Response `json:"-"` + Value *[]Annotation `json:"value,omitempty"` +} + +// ListApplicationInsightsComponentAnalyticsItem ... +type ListApplicationInsightsComponentAnalyticsItem struct { + autorest.Response `json:"-"` + Value *[]ApplicationInsightsComponentAnalyticsItem `json:"value,omitempty"` +} + +// ListApplicationInsightsComponentExportConfiguration ... +type ListApplicationInsightsComponentExportConfiguration struct { + autorest.Response `json:"-"` + Value *[]ApplicationInsightsComponentExportConfiguration `json:"value,omitempty"` +} + +// ListApplicationInsightsComponentFavorite ... +type ListApplicationInsightsComponentFavorite struct { + autorest.Response `json:"-"` + Value *[]ApplicationInsightsComponentFavorite `json:"value,omitempty"` +} + +// ListApplicationInsightsComponentProactiveDetectionConfiguration ... +type ListApplicationInsightsComponentProactiveDetectionConfiguration struct { + autorest.Response `json:"-"` + Value *[]ApplicationInsightsComponentProactiveDetectionConfiguration `json:"value,omitempty"` +} + +// MyWorkbook an Application Insights private workbook definition. +type MyWorkbook struct { + autorest.Response `json:"-"` + // Kind - The kind of workbook. Choices are user and shared. Possible values include: 'SharedTypeKindUser', 'SharedTypeKindShared' + Kind SharedTypeKind `json:"kind,omitempty"` + // MyWorkbookProperties - Metadata describing a workbook for an Azure resource. + *MyWorkbookProperties `json:"properties,omitempty"` + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for MyWorkbook. +func (mw MyWorkbook) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mw.Kind != "" { + objectMap["kind"] = mw.Kind + } + if mw.MyWorkbookProperties != nil { + objectMap["properties"] = mw.MyWorkbookProperties + } + if mw.ID != nil { + objectMap["id"] = mw.ID + } + if mw.Name != nil { + objectMap["name"] = mw.Name + } + if mw.Type != nil { + objectMap["type"] = mw.Type + } + if mw.Location != nil { + objectMap["location"] = mw.Location + } + if mw.Tags != nil { + objectMap["tags"] = mw.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MyWorkbook struct. +func (mw *MyWorkbook) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind SharedTypeKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + mw.Kind = kind + } + case "properties": + if v != nil { + var myWorkbookProperties MyWorkbookProperties + err = json.Unmarshal(*v, &myWorkbookProperties) + if err != nil { + return err + } + mw.MyWorkbookProperties = &myWorkbookProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mw.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mw.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mw.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mw.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mw.Tags = tags + } + } + } + + return nil +} + +// MyWorkbookError error message body that will indicate why the operation failed. +type MyWorkbookError struct { + // Code - Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. + Code *string `json:"code,omitempty"` + // Message - Human-readable representation of the error. + Message *string `json:"message,omitempty"` + // Details - The list of invalid fields send in request, in case of validation error. + Details *[]ErrorFieldContract `json:"details,omitempty"` +} + +// MyWorkbookProperties properties that contain a private workbook. +type MyWorkbookProperties struct { + // DisplayName - The user-defined name of the private workbook. + DisplayName *string `json:"displayName,omitempty"` + // SerializedData - Configuration of this particular private workbook. Configuration data is a string containing valid JSON + SerializedData *string `json:"serializedData,omitempty"` + // Version - This instance's version of the data model. This can change as new features are added that can be marked private workbook. + Version *string `json:"version,omitempty"` + // TimeModified - READ-ONLY; Date and time in UTC of the last modification that was made to this private workbook definition. + TimeModified *string `json:"timeModified,omitempty"` + // Category - Workbook category, as defined by the user at creation time. + Category *string `json:"category,omitempty"` + // Tags - A list of 0 or more tags that are associated with this private workbook definition + Tags *[]string `json:"tags,omitempty"` + // UserID - READ-ONLY; Unique user id of the specific user that owns this private workbook. + UserID *string `json:"userId,omitempty"` + // SourceID - Optional resourceId for a source resource. + SourceID *string `json:"sourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for MyWorkbookProperties. +func (mwp MyWorkbookProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mwp.DisplayName != nil { + objectMap["displayName"] = mwp.DisplayName + } + if mwp.SerializedData != nil { + objectMap["serializedData"] = mwp.SerializedData + } + if mwp.Version != nil { + objectMap["version"] = mwp.Version + } + if mwp.Category != nil { + objectMap["category"] = mwp.Category + } + if mwp.Tags != nil { + objectMap["tags"] = mwp.Tags + } + if mwp.SourceID != nil { + objectMap["sourceId"] = mwp.SourceID + } + return json.Marshal(objectMap) +} + +// MyWorkbookResource an azure resource object +type MyWorkbookResource struct { + // ID - Azure resource Id + ID *string `json:"id,omitempty"` + // Name - Azure resource name + Name *string `json:"name,omitempty"` + // Type - Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for MyWorkbookResource. +func (mwr MyWorkbookResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mwr.ID != nil { + objectMap["id"] = mwr.ID + } + if mwr.Name != nil { + objectMap["name"] = mwr.Name + } + if mwr.Type != nil { + objectMap["type"] = mwr.Type + } + if mwr.Location != nil { + objectMap["location"] = mwr.Location + } + if mwr.Tags != nil { + objectMap["tags"] = mwr.Tags + } + return json.Marshal(objectMap) +} + +// MyWorkbooksListResult workbook list result. +type MyWorkbooksListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; An array of private workbooks. + Value *[]MyWorkbook `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for MyWorkbooksListResult. +func (mwlr MyWorkbooksListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Operation CDN REST API operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Cdn + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: Profile, endpoint, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result of the request to list CDN operations. It contains a list of operations and a +// URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of CDN operations supported by the CDN resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// PrivateLinkScopedResource the private link scope resource reference. +type PrivateLinkScopedResource struct { + // ResourceID - The full resource Id of the private link scope resource. + ResourceID *string `json:"ResourceId,omitempty"` + // ScopeID - The private link scope unique Identifier. + ScopeID *string `json:"ScopeId,omitempty"` +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on a +// WebTest instance. +type TagsResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsResource. +func (tr TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// WebTest an Application Insights web test definition. +type WebTest struct { + autorest.Response `json:"-"` + // Kind - The kind of web test that this web test watches. Choices are ping and multistep. Possible values include: 'WebTestKindPing', 'WebTestKindMultistep' + Kind WebTestKind `json:"kind,omitempty"` + // WebTestProperties - Metadata describing a web test for an Azure resource. + *WebTestProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for WebTest. +func (wt WebTest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wt.Kind != "" { + objectMap["kind"] = wt.Kind + } + if wt.WebTestProperties != nil { + objectMap["properties"] = wt.WebTestProperties + } + if wt.Location != nil { + objectMap["location"] = wt.Location + } + if wt.Tags != nil { + objectMap["tags"] = wt.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WebTest struct. +func (wt *WebTest) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind WebTestKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + wt.Kind = kind + } + case "properties": + if v != nil { + var webTestProperties WebTestProperties + err = json.Unmarshal(*v, &webTestProperties) + if err != nil { + return err + } + wt.WebTestProperties = &webTestProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wt.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wt.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wt.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + wt.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + wt.Tags = tags + } + } + } + + return nil +} + +// WebTestGeolocation geo-physical location to run a web test from. You must specify one or more locations +// for the test to run from. +type WebTestGeolocation struct { + // Location - Location ID for the webtest to run from. + Location *string `json:"Id,omitempty"` +} + +// WebTestListResult a list of 0 or more Application Insights web test definitions. +type WebTestListResult struct { + autorest.Response `json:"-"` + // Value - Set of Application Insights web test definitions. + Value *[]WebTest `json:"value,omitempty"` + // NextLink - The link to get the next part of the returned list of web tests, should the return set be too large for a single request. May be null. + NextLink *string `json:"nextLink,omitempty"` +} + +// WebTestListResultIterator provides access to a complete listing of WebTest values. +type WebTestListResultIterator struct { + i int + page WebTestListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WebTestListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WebTestListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WebTestListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WebTestListResultIterator) Response() WebTestListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WebTestListResultIterator) Value() WebTest { + if !iter.page.NotDone() { + return WebTest{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WebTestListResultIterator type. +func NewWebTestListResultIterator(page WebTestListResultPage) WebTestListResultIterator { + return WebTestListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wtlr WebTestListResult) IsEmpty() bool { + return wtlr.Value == nil || len(*wtlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wtlr WebTestListResult) hasNextLink() bool { + return wtlr.NextLink != nil && len(*wtlr.NextLink) != 0 +} + +// webTestListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wtlr WebTestListResult) webTestListResultPreparer(ctx context.Context) (*http.Request, error) { + if !wtlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wtlr.NextLink))) +} + +// WebTestListResultPage contains a page of WebTest values. +type WebTestListResultPage struct { + fn func(context.Context, WebTestListResult) (WebTestListResult, error) + wtlr WebTestListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WebTestListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wtlr) + if err != nil { + return err + } + page.wtlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WebTestListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WebTestListResultPage) NotDone() bool { + return !page.wtlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WebTestListResultPage) Response() WebTestListResult { + return page.wtlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WebTestListResultPage) Values() []WebTest { + if page.wtlr.IsEmpty() { + return nil + } + return *page.wtlr.Value +} + +// Creates a new instance of the WebTestListResultPage type. +func NewWebTestListResultPage(cur WebTestListResult, getNextPage func(context.Context, WebTestListResult) (WebTestListResult, error)) WebTestListResultPage { + return WebTestListResultPage{ + fn: getNextPage, + wtlr: cur, + } +} + +// WebTestProperties metadata describing a web test for an Azure resource. +type WebTestProperties struct { + // SyntheticMonitorID - Unique ID of this WebTest. This is typically the same value as the Name field. + SyntheticMonitorID *string `json:"SyntheticMonitorId,omitempty"` + // WebTestName - User defined name if this WebTest. + WebTestName *string `json:"Name,omitempty"` + // Description - Purpose/user defined descriptive test for this WebTest. + Description *string `json:"Description,omitempty"` + // Enabled - Is the test actively being monitored. + Enabled *bool `json:"Enabled,omitempty"` + // Frequency - Interval in seconds between test runs for this WebTest. Default value is 300. + Frequency *int32 `json:"Frequency,omitempty"` + // Timeout - Seconds until this WebTest will timeout and fail. Default value is 30. + Timeout *int32 `json:"Timeout,omitempty"` + // WebTestKind - The kind of web test this is, valid choices are ping and multistep. Possible values include: 'WebTestKindPing', 'WebTestKindMultistep' + WebTestKind WebTestKind `json:"Kind,omitempty"` + // RetryEnabled - Allow for retries should this WebTest fail. + RetryEnabled *bool `json:"RetryEnabled,omitempty"` + // Locations - A list of where to physically run the tests from to give global coverage for accessibility of your application. + Locations *[]WebTestGeolocation `json:"Locations,omitempty"` + // Configuration - An XML configuration specification for a WebTest. + Configuration *WebTestPropertiesConfiguration `json:"Configuration,omitempty"` + // ProvisioningState - READ-ONLY; Current state of this component, whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebTestProperties. +func (wtp WebTestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wtp.SyntheticMonitorID != nil { + objectMap["SyntheticMonitorId"] = wtp.SyntheticMonitorID + } + if wtp.WebTestName != nil { + objectMap["Name"] = wtp.WebTestName + } + if wtp.Description != nil { + objectMap["Description"] = wtp.Description + } + if wtp.Enabled != nil { + objectMap["Enabled"] = wtp.Enabled + } + if wtp.Frequency != nil { + objectMap["Frequency"] = wtp.Frequency + } + if wtp.Timeout != nil { + objectMap["Timeout"] = wtp.Timeout + } + if wtp.WebTestKind != "" { + objectMap["Kind"] = wtp.WebTestKind + } + if wtp.RetryEnabled != nil { + objectMap["RetryEnabled"] = wtp.RetryEnabled + } + if wtp.Locations != nil { + objectMap["Locations"] = wtp.Locations + } + if wtp.Configuration != nil { + objectMap["Configuration"] = wtp.Configuration + } + return json.Marshal(objectMap) +} + +// WebTestPropertiesConfiguration an XML configuration specification for a WebTest. +type WebTestPropertiesConfiguration struct { + // WebTest - The XML specification of a WebTest to run against an application. + WebTest *string `json:"WebTest,omitempty"` +} + +// WebtestsResource an azure resource object +type WebtestsResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for WebtestsResource. +func (wr WebtestsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wr.Location != nil { + objectMap["location"] = wr.Location + } + if wr.Tags != nil { + objectMap["tags"] = wr.Tags + } + return json.Marshal(objectMap) +} + +// Workbook an Application Insights workbook definition. +type Workbook struct { + autorest.Response `json:"-"` + // Kind - The kind of workbook. Choices are user and shared. Possible values include: 'SharedTypeKindUser', 'SharedTypeKindShared' + Kind SharedTypeKind `json:"kind,omitempty"` + // WorkbookProperties - Metadata describing a web test for an Azure resource. + *WorkbookProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Workbook. +func (w Workbook) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if w.Kind != "" { + objectMap["kind"] = w.Kind + } + if w.WorkbookProperties != nil { + objectMap["properties"] = w.WorkbookProperties + } + if w.Location != nil { + objectMap["location"] = w.Location + } + if w.Tags != nil { + objectMap["tags"] = w.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Workbook struct. +func (w *Workbook) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind SharedTypeKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + w.Kind = kind + } + case "properties": + if v != nil { + var workbookProperties WorkbookProperties + err = json.Unmarshal(*v, &workbookProperties) + if err != nil { + return err + } + w.WorkbookProperties = &workbookProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + w.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + w.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + w.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + w.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + w.Tags = tags + } + } + } + + return nil +} + +// WorkbookError error message body that will indicate why the operation failed. +type WorkbookError struct { + // Code - Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. + Code *string `json:"code,omitempty"` + // Message - Human-readable representation of the error. + Message *string `json:"message,omitempty"` + // Details - The list of invalid fields send in request, in case of validation error. + Details *[]ErrorFieldContract `json:"details,omitempty"` +} + +// WorkbookProperties properties that contain a workbook. +type WorkbookProperties struct { + // Name - The user-defined name of the workbook. + Name *string `json:"name,omitempty"` + // SerializedData - Configuration of this particular workbook. Configuration data is a string containing valid JSON + SerializedData *string `json:"serializedData,omitempty"` + // Version - This instance's version of the data model. This can change as new features are added that can be marked workbook. + Version *string `json:"version,omitempty"` + // WorkbookID - Internally assigned unique id of the workbook definition. + WorkbookID *string `json:"workbookId,omitempty"` + // SharedTypeKind - Enum indicating if this workbook definition is owned by a specific user or is shared between all users with access to the Application Insights component. Possible values include: 'SharedTypeKindUser', 'SharedTypeKindShared' + SharedTypeKind SharedTypeKind `json:"kind,omitempty"` + // TimeModified - READ-ONLY; Date and time in UTC of the last modification that was made to this workbook definition. + TimeModified *string `json:"timeModified,omitempty"` + // Category - Workbook category, as defined by the user at creation time. + Category *string `json:"category,omitempty"` + // Tags - A list of 0 or more tags that are associated with this workbook definition + Tags *[]string `json:"tags,omitempty"` + // UserID - Unique user id of the specific user that owns this workbook. + UserID *string `json:"userId,omitempty"` + // SourceResourceID - Optional resourceId for a source resource. + SourceResourceID *string `json:"sourceResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkbookProperties. +func (wp WorkbookProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wp.Name != nil { + objectMap["name"] = wp.Name + } + if wp.SerializedData != nil { + objectMap["serializedData"] = wp.SerializedData + } + if wp.Version != nil { + objectMap["version"] = wp.Version + } + if wp.WorkbookID != nil { + objectMap["workbookId"] = wp.WorkbookID + } + if wp.SharedTypeKind != "" { + objectMap["kind"] = wp.SharedTypeKind + } + if wp.Category != nil { + objectMap["category"] = wp.Category + } + if wp.Tags != nil { + objectMap["tags"] = wp.Tags + } + if wp.UserID != nil { + objectMap["userId"] = wp.UserID + } + if wp.SourceResourceID != nil { + objectMap["sourceResourceId"] = wp.SourceResourceID + } + return json.Marshal(objectMap) +} + +// WorkbookResource an azure resource object +type WorkbookResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for WorkbookResource. +func (wr WorkbookResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wr.Location != nil { + objectMap["location"] = wr.Location + } + if wr.Tags != nil { + objectMap["tags"] = wr.Tags + } + return json.Marshal(objectMap) +} + +// WorkbooksListResult workbook list result. +type WorkbooksListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; An array of workbooks. + Value *[]Workbook `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkbooksListResult. +func (wlr WorkbooksListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WorkItemConfiguration work item configuration associated with an application insights resource. +type WorkItemConfiguration struct { + autorest.Response `json:"-"` + // ConnectorID - Connector identifier where work item is created + ConnectorID *string `json:"ConnectorId,omitempty"` + // ConfigDisplayName - Configuration friendly name + ConfigDisplayName *string `json:"ConfigDisplayName,omitempty"` + // IsDefault - Boolean value indicating whether configuration is default + IsDefault *bool `json:"IsDefault,omitempty"` + // ID - Unique Id for work item + ID *string `json:"Id,omitempty"` + // ConfigProperties - Serialized JSON object for detailed properties + ConfigProperties *string `json:"ConfigProperties,omitempty"` +} + +// WorkItemConfigurationError error associated with trying to get work item configuration or configurations +type WorkItemConfigurationError struct { + // Code - Error detail code and explanation + Code *string `json:"code,omitempty"` + // Message - Error message + Message *string `json:"message,omitempty"` + Innererror *InnerError `json:"innererror,omitempty"` +} + +// WorkItemConfigurationsListResult work item configuration list result. +type WorkItemConfigurationsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; An array of work item configurations. + Value *[]WorkItemConfiguration `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkItemConfigurationsListResult. +func (wiclr WorkItemConfigurationsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WorkItemCreateConfiguration work item configuration creation payload +type WorkItemCreateConfiguration struct { + // ConnectorID - Unique connector id + ConnectorID *string `json:"ConnectorId,omitempty"` + // ConnectorDataConfiguration - Serialized JSON object for detailed properties + ConnectorDataConfiguration *string `json:"ConnectorDataConfiguration,omitempty"` + // ValidateOnly - Boolean indicating validate only + ValidateOnly *bool `json:"ValidateOnly,omitempty"` + // WorkItemProperties - Custom work item properties + WorkItemProperties map[string]*string `json:"WorkItemProperties"` +} + +// MarshalJSON is the custom marshaler for WorkItemCreateConfiguration. +func (wicc WorkItemCreateConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wicc.ConnectorID != nil { + objectMap["ConnectorId"] = wicc.ConnectorID + } + if wicc.ConnectorDataConfiguration != nil { + objectMap["ConnectorDataConfiguration"] = wicc.ConnectorDataConfiguration + } + if wicc.ValidateOnly != nil { + objectMap["ValidateOnly"] = wicc.ValidateOnly + } + if wicc.WorkItemProperties != nil { + objectMap["WorkItemProperties"] = wicc.WorkItemProperties + } + return json.Marshal(objectMap) +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/myworkbooks.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/myworkbooks.go new file mode 100644 index 000000000000..0f11b643e8bc --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/myworkbooks.go @@ -0,0 +1,566 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MyWorkbooksClient is the composite Swagger for Application Insights Management Client +type MyWorkbooksClient struct { + BaseClient +} + +// NewMyWorkbooksClient creates an instance of the MyWorkbooksClient client. +func NewMyWorkbooksClient(subscriptionID string) MyWorkbooksClient { + return NewMyWorkbooksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMyWorkbooksClientWithBaseURI creates an instance of the MyWorkbooksClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewMyWorkbooksClientWithBaseURI(baseURI string, subscriptionID string) MyWorkbooksClient { + return MyWorkbooksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new private workbook. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workbookProperties - properties that need to be specified to create a new private workbook. +func (client MyWorkbooksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (result MyWorkbook, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: workbookProperties, + Constraints: []validation.Constraint{{Target: "workbookProperties.MyWorkbookProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "workbookProperties.MyWorkbookProperties.DisplayName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.MyWorkbookProperties.SerializedData", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.MyWorkbookProperties.Category", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client MyWorkbooksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", pathParameters), + autorest.WithJSON(workbookProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client MyWorkbooksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) CreateOrUpdateResponder(resp *http.Response) (result MyWorkbook, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a private workbook. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client MyWorkbooksClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client MyWorkbooksClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client MyWorkbooksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a single private workbook by its resourceName. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client MyWorkbooksClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result MyWorkbook, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client MyWorkbooksClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client MyWorkbooksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) GetResponder(resp *http.Response) (result MyWorkbook, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get all private workbooks defined within a specified resource group and category. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// category - category of workbook to return. +// tags - tags presents on each workbook returned. +// canFetchContent - flag indicating whether or not to return the full content for each applicable workbook. If +// false, only return summary content for workbooks. +func (client MyWorkbooksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (result MyWorkbooksListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, category, tags, canFetchContent) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client MyWorkbooksClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "category": autorest.Encode("query", category), + } + if tags != nil && len(tags) > 0 { + queryParameters["tags"] = autorest.Encode("query", tags, ",") + } + if canFetchContent != nil { + queryParameters["canFetchContent"] = autorest.Encode("query", *canFetchContent) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client MyWorkbooksClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) ListByResourceGroupResponder(resp *http.Response) (result MyWorkbooksListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription get all private workbooks defined within a specified subscription and category. +// Parameters: +// category - category of workbook to return. +// tags - tags presents on each workbook returned. +// canFetchContent - flag indicating whether or not to return the full content for each applicable workbook. If +// false, only return summary content for workbooks. +func (client MyWorkbooksClient) ListBySubscription(ctx context.Context, category CategoryType, tags []string, canFetchContent *bool) (result MyWorkbooksListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx, category, tags, canFetchContent) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client MyWorkbooksClient) ListBySubscriptionPreparer(ctx context.Context, category CategoryType, tags []string, canFetchContent *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "category": autorest.Encode("query", category), + } + if tags != nil && len(tags) > 0 { + queryParameters["tags"] = autorest.Encode("query", tags, ",") + } + if canFetchContent != nil { + queryParameters["canFetchContent"] = autorest.Encode("query", *canFetchContent) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/myWorkbooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client MyWorkbooksClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) ListBySubscriptionResponder(resp *http.Response) (result MyWorkbooksListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a private workbook that has already been added. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workbookProperties - properties that need to be specified to create a new private workbook. +func (client MyWorkbooksClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (result MyWorkbook, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MyWorkbooksClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MyWorkbooksClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MyWorkbooksClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client MyWorkbooksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties MyWorkbook) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/myWorkbooks/{resourceName}", pathParameters), + autorest.WithJSON(workbookProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client MyWorkbooksClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client MyWorkbooksClient) UpdateResponder(resp *http.Response) (result MyWorkbook, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/operations.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/operations.go new file mode 100644 index 000000000000..b7459628872f --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/operations.go @@ -0,0 +1,140 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the composite Swagger for Application Insights Management Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available insights REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Insights/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/proactivedetectionconfigurations.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/proactivedetectionconfigurations.go new file mode 100644 index 000000000000..78223d23395b --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/proactivedetectionconfigurations.go @@ -0,0 +1,298 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProactiveDetectionConfigurationsClient is the composite Swagger for Application Insights Management Client +type ProactiveDetectionConfigurationsClient struct { + BaseClient +} + +// NewProactiveDetectionConfigurationsClient creates an instance of the ProactiveDetectionConfigurationsClient client. +func NewProactiveDetectionConfigurationsClient(subscriptionID string) ProactiveDetectionConfigurationsClient { + return NewProactiveDetectionConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProactiveDetectionConfigurationsClientWithBaseURI creates an instance of the +// ProactiveDetectionConfigurationsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewProactiveDetectionConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ProactiveDetectionConfigurationsClient { + return ProactiveDetectionConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the ProactiveDetection configuration for this configuration id. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// configurationID - the ProactiveDetection configuration ID. This is unique within a Application Insights +// component. +func (client ProactiveDetectionConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, configurationID string) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProactiveDetectionConfigurationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ProactiveDetectionConfigurationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, configurationID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProactiveDetectionConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, configurationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ConfigurationId": autorest.Encode("path", configurationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ProactiveDetectionConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ProactiveDetectionConfigurationsClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of ProactiveDetection configurations of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client ProactiveDetectionConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ListApplicationInsightsComponentProactiveDetectionConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProactiveDetectionConfigurationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ProactiveDetectionConfigurationsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ProactiveDetectionConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ProactiveDetectionConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ProactiveDetectionConfigurationsClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentProactiveDetectionConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update the ProactiveDetection configuration for this configuration id. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// configurationID - the ProactiveDetection configuration ID. This is unique within a Application Insights +// component. +// proactiveDetectionProperties - properties that need to be specified to update the ProactiveDetection +// configuration. +func (client ProactiveDetectionConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties ApplicationInsightsComponentProactiveDetectionConfiguration) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProactiveDetectionConfigurationsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ProactiveDetectionConfigurationsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, configurationID, proactiveDetectionProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ProactiveDetectionConfigurationsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ProactiveDetectionConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, configurationID string, proactiveDetectionProperties ApplicationInsightsComponentProactiveDetectionConfiguration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ConfigurationId": autorest.Encode("path", configurationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/ProactiveDetectionConfigs/{ConfigurationId}", pathParameters), + autorest.WithJSON(proactiveDetectionProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ProactiveDetectionConfigurationsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ProactiveDetectionConfigurationsClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentProactiveDetectionConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/version.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/version.go new file mode 100644 index 000000000000..531d11c5c18a --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/version.go @@ -0,0 +1,19 @@ +package insights + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " insights/2020-02-02-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/webtestlocations.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/webtestlocations.go new file mode 100644 index 000000000000..dcb3923ba146 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/webtestlocations.go @@ -0,0 +1,118 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WebTestLocationsClient is the composite Swagger for Application Insights Management Client +type WebTestLocationsClient struct { + BaseClient +} + +// NewWebTestLocationsClient creates an instance of the WebTestLocationsClient client. +func NewWebTestLocationsClient(subscriptionID string) WebTestLocationsClient { + return NewWebTestLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWebTestLocationsClientWithBaseURI creates an instance of the WebTestLocationsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewWebTestLocationsClientWithBaseURI(baseURI string, subscriptionID string) WebTestLocationsClient { + return WebTestLocationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List gets a list of web test locations available to this Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client WebTestLocationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result ApplicationInsightsWebTestLocationsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestLocationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WebTestLocationsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestLocationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WebTestLocationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestLocationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client WebTestLocationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/syntheticmonitorlocations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestLocationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client WebTestLocationsClient) ListResponder(resp *http.Response) (result ApplicationInsightsWebTestLocationsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/webtests.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/webtests.go new file mode 100644 index 000000000000..cb9450fdee91 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/webtests.go @@ -0,0 +1,755 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WebTestsClient is the composite Swagger for Application Insights Management Client +type WebTestsClient struct { + BaseClient +} + +// NewWebTestsClient creates an instance of the WebTestsClient client. +func NewWebTestsClient(subscriptionID string) WebTestsClient { + return NewWebTestsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWebTestsClientWithBaseURI creates an instance of the WebTestsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWebTestsClientWithBaseURI(baseURI string, subscriptionID string) WebTestsClient { + return WebTestsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an Application Insights web test definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// webTestName - the name of the Application Insights webtest resource. +// webTestDefinition - properties that need to be specified to create or update an Application Insights web +// test definition. +func (client WebTestsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, webTestName string, webTestDefinition WebTest) (result WebTest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: webTestDefinition, + Constraints: []validation.Constraint{{Target: "webTestDefinition.WebTestProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "webTestDefinition.WebTestProperties.SyntheticMonitorID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "webTestDefinition.WebTestProperties.WebTestName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "webTestDefinition.WebTestProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.WebTestsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, webTestName, webTestDefinition) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WebTestsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, webTestName string, webTestDefinition WebTest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webTestName": autorest.Encode("path", webTestName), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}", pathParameters), + autorest.WithJSON(webTestDefinition), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WebTestsClient) CreateOrUpdateResponder(resp *http.Response) (result WebTest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an Application Insights web test. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// webTestName - the name of the Application Insights webtest resource. +func (client WebTestsClient) Delete(ctx context.Context, resourceGroupName string, webTestName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WebTestsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, webTestName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WebTestsClient) DeletePreparer(ctx context.Context, resourceGroupName string, webTestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webTestName": autorest.Encode("path", webTestName), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WebTestsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a specific Application Insights web test definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// webTestName - the name of the Application Insights webtest resource. +func (client WebTestsClient) Get(ctx context.Context, resourceGroupName string, webTestName string) (result WebTest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WebTestsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, webTestName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client WebTestsClient) GetPreparer(ctx context.Context, resourceGroupName string, webTestName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webTestName": autorest.Encode("path", webTestName), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WebTestsClient) GetResponder(resp *http.Response) (result WebTest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all Application Insights web test alerts definitions within a subscription. +func (client WebTestsClient) List(ctx context.Context) (result WebTestListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.List") + defer func() { + sc := -1 + if result.wtlr.Response.Response != nil { + sc = result.wtlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WebTestsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.wtlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "List", resp, "Failure sending request") + return + } + + result.wtlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "List", resp, "Failure responding to request") + return + } + if result.wtlr.hasNextLink() && result.wtlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client WebTestsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/webtests", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client WebTestsClient) ListResponder(resp *http.Response) (result WebTestListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client WebTestsClient) listNextResults(ctx context.Context, lastResults WebTestListResult) (result WebTestListResult, err error) { + req, err := lastResults.webTestListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client WebTestsClient) ListComplete(ctx context.Context) (result WebTestListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByComponent get all Application Insights web tests defined for the specified component. +// Parameters: +// componentName - the name of the Application Insights component resource. +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client WebTestsClient) ListByComponent(ctx context.Context, componentName string, resourceGroupName string) (result WebTestListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.ListByComponent") + defer func() { + sc := -1 + if result.wtlr.Response.Response != nil { + sc = result.wtlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WebTestsClient", "ListByComponent", err.Error()) + } + + result.fn = client.listByComponentNextResults + req, err := client.ListByComponentPreparer(ctx, componentName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "ListByComponent", nil, "Failure preparing request") + return + } + + resp, err := client.ListByComponentSender(req) + if err != nil { + result.wtlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "ListByComponent", resp, "Failure sending request") + return + } + + result.wtlr, err = client.ListByComponentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "ListByComponent", resp, "Failure responding to request") + return + } + if result.wtlr.hasNextLink() && result.wtlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByComponentPreparer prepares the ListByComponent request. +func (client WebTestsClient) ListByComponentPreparer(ctx context.Context, componentName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "componentName": autorest.Encode("path", componentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{componentName}/webtests", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByComponentSender sends the ListByComponent request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) ListByComponentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByComponentResponder handles the response to the ListByComponent request. The method always +// closes the http.Response Body. +func (client WebTestsClient) ListByComponentResponder(resp *http.Response) (result WebTestListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByComponentNextResults retrieves the next set of results, if any. +func (client WebTestsClient) listByComponentNextResults(ctx context.Context, lastResults WebTestListResult) (result WebTestListResult, err error) { + req, err := lastResults.webTestListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listByComponentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByComponentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listByComponentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByComponentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "listByComponentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByComponentComplete enumerates all values, automatically crossing page boundaries as required. +func (client WebTestsClient) ListByComponentComplete(ctx context.Context, componentName string, resourceGroupName string) (result WebTestListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.ListByComponent") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByComponent(ctx, componentName, resourceGroupName) + return +} + +// ListByResourceGroup get all Application Insights web tests defined within a specified resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client WebTestsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result WebTestListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.wtlr.Response.Response != nil { + sc = result.wtlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WebTestsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.wtlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.wtlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.wtlr.hasNextLink() && result.wtlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client WebTestsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client WebTestsClient) ListByResourceGroupResponder(resp *http.Response) (result WebTestListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client WebTestsClient) listByResourceGroupNextResults(ctx context.Context, lastResults WebTestListResult) (result WebTestListResult, err error) { + req, err := lastResults.webTestListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.WebTestsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client WebTestsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result WebTestListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// UpdateTags creates or updates an Application Insights web test definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// webTestName - the name of the Application Insights webtest resource. +// webTestTags - updated tag information to set into the web test instance. +func (client WebTestsClient) UpdateTags(ctx context.Context, resourceGroupName string, webTestName string, webTestTags TagsResource) (result WebTest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WebTestsClient.UpdateTags") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WebTestsClient", "UpdateTags", err.Error()) + } + + req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, webTestName, webTestTags) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "UpdateTags", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateTagsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "UpdateTags", resp, "Failure sending request") + return + } + + result, err = client.UpdateTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WebTestsClient", "UpdateTags", resp, "Failure responding to request") + return + } + + return +} + +// UpdateTagsPreparer prepares the UpdateTags request. +func (client WebTestsClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, webTestName string, webTestTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "webTestName": autorest.Encode("path", webTestName), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/webtests/{webTestName}", pathParameters), + autorest.WithJSON(webTestTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateTagsSender sends the UpdateTags request. The method will close the +// http.Response Body if it receives an error. +func (client WebTestsClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateTagsResponder handles the response to the UpdateTags request. The method always +// closes the http.Response Body. +func (client WebTestsClient) UpdateTagsResponder(resp *http.Response) (result WebTest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/workbooks.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/workbooks.go new file mode 100644 index 000000000000..e30bd2ce8bb4 --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/workbooks.go @@ -0,0 +1,479 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkbooksClient is the composite Swagger for Application Insights Management Client +type WorkbooksClient struct { + BaseClient +} + +// NewWorkbooksClient creates an instance of the WorkbooksClient client. +func NewWorkbooksClient(subscriptionID string) WorkbooksClient { + return NewWorkbooksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkbooksClientWithBaseURI creates an instance of the WorkbooksClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWorkbooksClientWithBaseURI(baseURI string, subscriptionID string) WorkbooksClient { + return WorkbooksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new workbook. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workbookProperties - properties that need to be specified to create a new workbook. +func (client WorkbooksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (result Workbook, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkbooksClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: workbookProperties, + Constraints: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "workbookProperties.WorkbookProperties.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.SerializedData", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.WorkbookID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.Category", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workbookProperties.WorkbookProperties.UserID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.WorkbooksClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkbooksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), + autorest.WithJSON(workbookProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WorkbooksClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkbooksClient) CreateOrUpdateResponder(resp *http.Response) (result Workbook, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a workbook. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client WorkbooksClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkbooksClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkbooksClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkbooksClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WorkbooksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkbooksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a single workbook by its resourceName. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client WorkbooksClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result Workbook, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkbooksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkbooksClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkbooksClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WorkbooksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkbooksClient) GetResponder(resp *http.Response) (result Workbook, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get all Workbooks defined within a specified resource group and category. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// category - category of workbook to return. +// tags - tags presents on each workbook returned. +// canFetchContent - flag indicating whether or not to return the full content for each applicable workbook. If +// false, only return summary content for workbooks. +func (client WorkbooksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (result WorkbooksListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkbooksClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkbooksClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, category, tags, canFetchContent) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client WorkbooksClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, category CategoryType, tags []string, canFetchContent *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "category": autorest.Encode("query", category), + } + if tags != nil && len(tags) > 0 { + queryParameters["tags"] = autorest.Encode("query", tags, ",") + } + if canFetchContent != nil { + queryParameters["canFetchContent"] = autorest.Encode("query", *canFetchContent) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WorkbooksClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client WorkbooksClient) ListByResourceGroupResponder(resp *http.Response) (result WorkbooksListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a workbook that has already been added. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workbookProperties - properties that need to be specified to create a new workbook. +func (client WorkbooksClient) Update(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (result Workbook, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkbooksClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkbooksClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, workbookProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkbooksClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WorkbooksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workbookProperties Workbook) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}", pathParameters), + autorest.WithJSON(workbookProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WorkbooksClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WorkbooksClient) UpdateResponder(resp *http.Response) (result Workbook, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/appinsights/mgmt/2020-02-02-preview/insights/workitemconfigurations.go b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/workitemconfigurations.go new file mode 100644 index 000000000000..c46789bddc6e --- /dev/null +++ b/services/preview/appinsights/mgmt/2020-02-02-preview/insights/workitemconfigurations.go @@ -0,0 +1,559 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkItemConfigurationsClient is the composite Swagger for Application Insights Management Client +type WorkItemConfigurationsClient struct { + BaseClient +} + +// NewWorkItemConfigurationsClient creates an instance of the WorkItemConfigurationsClient client. +func NewWorkItemConfigurationsClient(subscriptionID string) WorkItemConfigurationsClient { + return NewWorkItemConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkItemConfigurationsClientWithBaseURI creates an instance of the WorkItemConfigurationsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewWorkItemConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) WorkItemConfigurationsClient { + return WorkItemConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a work item configuration for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workItemConfigurationProperties - properties that need to be specified to create a work item configuration +// of a Application Insights component. +func (client WorkItemConfigurationsClient) Create(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigurationProperties WorkItemCreateConfiguration) (result WorkItemConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkItemConfigurationsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, workItemConfigurationProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client WorkItemConfigurationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigurationProperties WorkItemCreateConfiguration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs", pathParameters), + autorest.WithJSON(workItemConfigurationProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client WorkItemConfigurationsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client WorkItemConfigurationsClient) CreateResponder(resp *http.Response) (result WorkItemConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a work item configuration of an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workItemConfigID - the unique work item configuration Id. This can be either friendly name of connector as +// defined in connector configuration +func (client WorkItemConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkItemConfigurationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, workItemConfigID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkItemConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workItemConfigId": autorest.Encode("path", workItemConfigID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WorkItemConfigurationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkItemConfigurationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetDefault gets default work item configurations that exist for the application +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client WorkItemConfigurationsClient) GetDefault(ctx context.Context, resourceGroupName string, resourceName string) (result WorkItemConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.GetDefault") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkItemConfigurationsClient", "GetDefault", err.Error()) + } + + req, err := client.GetDefaultPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetDefault", nil, "Failure preparing request") + return + } + + resp, err := client.GetDefaultSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetDefault", resp, "Failure sending request") + return + } + + result, err = client.GetDefaultResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetDefault", resp, "Failure responding to request") + return + } + + return +} + +// GetDefaultPreparer prepares the GetDefault request. +func (client WorkItemConfigurationsClient) GetDefaultPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/DefaultWorkItemConfig", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDefaultSender sends the GetDefault request. The method will close the +// http.Response Body if it receives an error. +func (client WorkItemConfigurationsClient) GetDefaultSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetDefaultResponder handles the response to the GetDefault request. The method always +// closes the http.Response Body. +func (client WorkItemConfigurationsClient) GetDefaultResponder(resp *http.Response) (result WorkItemConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetItem gets specified work item configuration for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workItemConfigID - the unique work item configuration Id. This can be either friendly name of connector as +// defined in connector configuration +func (client WorkItemConfigurationsClient) GetItem(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (result WorkItemConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.GetItem") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkItemConfigurationsClient", "GetItem", err.Error()) + } + + req, err := client.GetItemPreparer(ctx, resourceGroupName, resourceName, workItemConfigID) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetItem", nil, "Failure preparing request") + return + } + + resp, err := client.GetItemSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetItem", resp, "Failure sending request") + return + } + + result, err = client.GetItemResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "GetItem", resp, "Failure responding to request") + return + } + + return +} + +// GetItemPreparer prepares the GetItem request. +func (client WorkItemConfigurationsClient) GetItemPreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workItemConfigId": autorest.Encode("path", workItemConfigID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetItemSender sends the GetItem request. The method will close the +// http.Response Body if it receives an error. +func (client WorkItemConfigurationsClient) GetItemSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetItemResponder handles the response to the GetItem request. The method always +// closes the http.Response Body. +func (client WorkItemConfigurationsClient) GetItemResponder(resp *http.Response) (result WorkItemConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the list work item configurations that exist for the application +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +func (client WorkItemConfigurationsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result WorkItemConfigurationsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkItemConfigurationsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client WorkItemConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client WorkItemConfigurationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client WorkItemConfigurationsClient) ListResponder(resp *http.Response) (result WorkItemConfigurationsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateItem update a work item configuration for an Application Insights component. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the Application Insights component resource. +// workItemConfigID - the unique work item configuration Id. This can be either friendly name of connector as +// defined in connector configuration +// workItemConfigurationProperties - properties that need to be specified to update a work item configuration +// for this Application Insights component. +func (client WorkItemConfigurationsClient) UpdateItem(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string, workItemConfigurationProperties WorkItemCreateConfiguration) (result WorkItemConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkItemConfigurationsClient.UpdateItem") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.WorkItemConfigurationsClient", "UpdateItem", err.Error()) + } + + req, err := client.UpdateItemPreparer(ctx, resourceGroupName, resourceName, workItemConfigID, workItemConfigurationProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "UpdateItem", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateItemSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "UpdateItem", resp, "Failure sending request") + return + } + + result, err = client.UpdateItemResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.WorkItemConfigurationsClient", "UpdateItem", resp, "Failure responding to request") + return + } + + return +} + +// UpdateItemPreparer prepares the UpdateItem request. +func (client WorkItemConfigurationsClient) UpdateItemPreparer(ctx context.Context, resourceGroupName string, resourceName string, workItemConfigID string, workItemConfigurationProperties WorkItemCreateConfiguration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workItemConfigId": autorest.Encode("path", workItemConfigID), + } + + const APIVersion = "2015-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/WorkItemConfigs/{workItemConfigId}", pathParameters), + autorest.WithJSON(workItemConfigurationProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateItemSender sends the UpdateItem request. The method will close the +// http.Response Body if it receives an error. +func (client WorkItemConfigurationsClient) UpdateItemSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateItemResponder handles the response to the UpdateItem request. The method always +// closes the http.Response Body. +func (client WorkItemConfigurationsClient) UpdateItemResponder(resp *http.Response) (result WorkItemConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/CHANGELOG.md b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/_meta.json b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/_meta.json new file mode 100644 index 000000000000..0570a17719bb --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "b548283ea6f4b3d797e85432fcc6e3ff2a2ac224", + "readme": "/_/azure-rest-api-specs/specification/signalr/resource-manager/readme.md", + "tag": "package-2021-06-01-preview", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2021-06-01-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/signalr/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/client.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/client.go new file mode 100644 index 000000000000..00ead9fdc934 --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/client.go @@ -0,0 +1,41 @@ +// Package signalr implements the Azure ARM Signalr service API version 2021-06-01-preview. +// +// REST API for Azure SignalR Service +package signalr + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Signalr + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Signalr. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/enums.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/enums.go new file mode 100644 index 000000000000..5eddf8f43337 --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/enums.go @@ -0,0 +1,229 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights 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. + +// ACLAction enumerates the values for acl action. +type ACLAction string + +const ( + // ACLActionAllow ... + ACLActionAllow ACLAction = "Allow" + // ACLActionDeny ... + ACLActionDeny ACLAction = "Deny" +) + +// PossibleACLActionValues returns an array of possible values for the ACLAction const type. +func PossibleACLActionValues() []ACLAction { + return []ACLAction{ACLActionAllow, ACLActionDeny} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// FeatureFlags enumerates the values for feature flags. +type FeatureFlags string + +const ( + // FeatureFlagsEnableConnectivityLogs ... + FeatureFlagsEnableConnectivityLogs FeatureFlags = "EnableConnectivityLogs" + // FeatureFlagsEnableLiveTrace ... + FeatureFlagsEnableLiveTrace FeatureFlags = "EnableLiveTrace" + // FeatureFlagsEnableMessagingLogs ... + FeatureFlagsEnableMessagingLogs FeatureFlags = "EnableMessagingLogs" + // FeatureFlagsServiceMode ... + FeatureFlagsServiceMode FeatureFlags = "ServiceMode" +) + +// PossibleFeatureFlagsValues returns an array of possible values for the FeatureFlags const type. +func PossibleFeatureFlagsValues() []FeatureFlags { + return []FeatureFlags{FeatureFlagsEnableConnectivityLogs, FeatureFlagsEnableLiveTrace, FeatureFlagsEnableMessagingLogs, FeatureFlagsServiceMode} +} + +// KeyType enumerates the values for key type. +type KeyType string + +const ( + // KeyTypePrimary ... + KeyTypePrimary KeyType = "Primary" + // KeyTypeSecondary ... + KeyTypeSecondary KeyType = "Secondary" +) + +// PossibleKeyTypeValues returns an array of possible values for the KeyType const type. +func PossibleKeyTypeValues() []KeyType { + return []KeyType{KeyTypePrimary, KeyTypeSecondary} +} + +// ManagedIdentityType enumerates the values for managed identity type. +type ManagedIdentityType string + +const ( + // ManagedIdentityTypeNone ... + ManagedIdentityTypeNone ManagedIdentityType = "None" + // ManagedIdentityTypeSystemAssigned ... + ManagedIdentityTypeSystemAssigned ManagedIdentityType = "SystemAssigned" + // ManagedIdentityTypeUserAssigned ... + ManagedIdentityTypeUserAssigned ManagedIdentityType = "UserAssigned" +) + +// PossibleManagedIdentityTypeValues returns an array of possible values for the ManagedIdentityType const type. +func PossibleManagedIdentityTypeValues() []ManagedIdentityType { + return []ManagedIdentityType{ManagedIdentityTypeNone, ManagedIdentityTypeSystemAssigned, ManagedIdentityTypeUserAssigned} +} + +// PrivateLinkServiceConnectionStatus enumerates the values for private link service connection status. +type PrivateLinkServiceConnectionStatus string + +const ( + // PrivateLinkServiceConnectionStatusApproved ... + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + // PrivateLinkServiceConnectionStatusDisconnected ... + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + // PrivateLinkServiceConnectionStatusPending ... + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + // PrivateLinkServiceConnectionStatusRejected ... + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{PrivateLinkServiceConnectionStatusApproved, PrivateLinkServiceConnectionStatusDisconnected, PrivateLinkServiceConnectionStatusPending, PrivateLinkServiceConnectionStatusRejected} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating ... + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting ... + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateMoving ... + ProvisioningStateMoving ProvisioningState = "Moving" + // ProvisioningStateRunning ... + ProvisioningStateRunning ProvisioningState = "Running" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUnknown ... + ProvisioningStateUnknown ProvisioningState = "Unknown" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCanceled, ProvisioningStateCreating, ProvisioningStateDeleting, ProvisioningStateFailed, ProvisioningStateMoving, ProvisioningStateRunning, ProvisioningStateSucceeded, ProvisioningStateUnknown, ProvisioningStateUpdating} +} + +// RequestType enumerates the values for request type. +type RequestType string + +const ( + // RequestTypeClientConnection ... + RequestTypeClientConnection RequestType = "ClientConnection" + // RequestTypeRESTAPI ... + RequestTypeRESTAPI RequestType = "RESTAPI" + // RequestTypeServerConnection ... + RequestTypeServerConnection RequestType = "ServerConnection" + // RequestTypeTrace ... + RequestTypeTrace RequestType = "Trace" +) + +// PossibleRequestTypeValues returns an array of possible values for the RequestType const type. +func PossibleRequestTypeValues() []RequestType { + return []RequestType{RequestTypeClientConnection, RequestTypeRESTAPI, RequestTypeServerConnection, RequestTypeTrace} +} + +// ServiceKind enumerates the values for service kind. +type ServiceKind string + +const ( + // ServiceKindRawWebSockets ... + ServiceKindRawWebSockets ServiceKind = "RawWebSockets" + // ServiceKindSignalR ... + ServiceKindSignalR ServiceKind = "SignalR" +) + +// PossibleServiceKindValues returns an array of possible values for the ServiceKind const type. +func PossibleServiceKindValues() []ServiceKind { + return []ServiceKind{ServiceKindRawWebSockets, ServiceKindSignalR} +} + +// SharedPrivateLinkResourceStatus enumerates the values for shared private link resource status. +type SharedPrivateLinkResourceStatus string + +const ( + // SharedPrivateLinkResourceStatusApproved ... + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + // SharedPrivateLinkResourceStatusDisconnected ... + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + // SharedPrivateLinkResourceStatusPending ... + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + // SharedPrivateLinkResourceStatusRejected ... + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" + // SharedPrivateLinkResourceStatusTimeout ... + SharedPrivateLinkResourceStatusTimeout SharedPrivateLinkResourceStatus = "Timeout" +) + +// PossibleSharedPrivateLinkResourceStatusValues returns an array of possible values for the SharedPrivateLinkResourceStatus const type. +func PossibleSharedPrivateLinkResourceStatusValues() []SharedPrivateLinkResourceStatus { + return []SharedPrivateLinkResourceStatus{SharedPrivateLinkResourceStatusApproved, SharedPrivateLinkResourceStatusDisconnected, SharedPrivateLinkResourceStatusPending, SharedPrivateLinkResourceStatusRejected, SharedPrivateLinkResourceStatusTimeout} +} + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // SkuTierBasic ... + SkuTierBasic SkuTier = "Basic" + // SkuTierFree ... + SkuTierFree SkuTier = "Free" + // SkuTierPremium ... + SkuTierPremium SkuTier = "Premium" + // SkuTierStandard ... + SkuTierStandard SkuTier = "Standard" +) + +// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. +func PossibleSkuTierValues() []SkuTier { + return []SkuTier{SkuTierBasic, SkuTierFree, SkuTierPremium, SkuTierStandard} +} + +// UpstreamAuthType enumerates the values for upstream auth type. +type UpstreamAuthType string + +const ( + // UpstreamAuthTypeManagedIdentity ... + UpstreamAuthTypeManagedIdentity UpstreamAuthType = "ManagedIdentity" + // UpstreamAuthTypeNone ... + UpstreamAuthTypeNone UpstreamAuthType = "None" +) + +// PossibleUpstreamAuthTypeValues returns an array of possible values for the UpstreamAuthType const type. +func PossibleUpstreamAuthTypeValues() []UpstreamAuthType { + return []UpstreamAuthType{UpstreamAuthTypeManagedIdentity, UpstreamAuthTypeNone} +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/models.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/models.go new file mode 100644 index 000000000000..2917ffc18c13 --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/models.go @@ -0,0 +1,2323 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/signalr/mgmt/2021-06-01-preview/signalr" + +// CorsSettings cross-Origin Resource Sharing (CORS) settings. +type CorsSettings struct { + // AllowedOrigins - Gets or sets the list of origins that should be allowed to make cross-origin calls (for example: http://example.com:12345). Use "*" to allow all. If omitted, allow all by default. + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` +} + +// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (ResourceType, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CreateOrUpdateFuture.Result. +func (future *CreateOrUpdateFuture) result(client Client) (rt ResourceType, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + rt.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("signalr.CreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rt.Response.Response, err = future.GetResult(sender); err == nil && rt.Response.Response.StatusCode != http.StatusNoContent { + rt, err = client.CreateOrUpdateResponder(rt.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.CreateOrUpdateFuture", "Result", rt.Response.Response, "Failure responding to request") + } + } + return +} + +// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DeleteFuture.Result. +func (future *DeleteFuture) result(client Client) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.DeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("signalr.DeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// Dimension specifications of the Dimension of metrics. +type Dimension struct { + // Name - The public facing name of the dimension. + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the dimension. + DisplayName *string `json:"displayName,omitempty"` + // InternalName - Name of the dimension as it appears in MDM. + InternalName *string `json:"internalName,omitempty"` + // ToBeExportedForShoebox - A Boolean flag indicating whether this dimension should be included for the shoebox export scenario. + ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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 { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// Feature feature of a resource, which controls the runtime behavior. +type Feature struct { + // Flag - FeatureFlags is the supported features of Azure SignalR service. + // - ServiceMode: Flag for backend server for SignalR service. Values allowed: "Default": have your own backend server; "Serverless": your application doesn't have a backend server; "Classic": for backward compatibility. Support both Default and Serverless mode but not recommended; "PredefinedOnly": for future use. + // - EnableConnectivityLogs: "true"/"false", to enable/disable the connectivity log category respectively. + // - EnableMessagingLogs: "true"/"false", to enable/disable the connectivity log category respectively. + // - EnableLiveTrace: Live Trace allows you to know what's happening inside Azure SignalR service, it will give you live traces in real time, it will be helpful when you developing your own Azure SignalR based web application or self-troubleshooting some issues. Please note that live traces are counted as outbound messages that will be charged. Values allowed: "true"/"false", to enable/disable live trace feature. Possible values include: 'FeatureFlagsServiceMode', 'FeatureFlagsEnableConnectivityLogs', 'FeatureFlagsEnableMessagingLogs', 'FeatureFlagsEnableLiveTrace' + Flag FeatureFlags `json:"flag,omitempty"` + // Value - Value of the feature flag. See Azure SignalR service document https://docs.microsoft.com/azure/azure-signalr/ for allowed values. + Value *string `json:"value,omitempty"` + // Properties - Optional properties related to this feature. + Properties map[string]*string `json:"properties"` +} + +// MarshalJSON is the custom marshaler for Feature. +func (f Feature) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if f.Flag != "" { + objectMap["flag"] = f.Flag + } + if f.Value != nil { + objectMap["value"] = f.Value + } + if f.Properties != nil { + objectMap["properties"] = f.Properties + } + return json.Marshal(objectMap) +} + +// Keys a class represents the access keys of the resource. +type Keys struct { + autorest.Response `json:"-"` + // PrimaryKey - The primary access key. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - The secondary access key. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // PrimaryConnectionString - Connection string constructed via the primaryKey + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + // SecondaryConnectionString - Connection string constructed via the secondaryKey + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` +} + +// LogSpecification specifications of the Logs for Azure Monitoring. +type LogSpecification struct { + // Name - Name of the log. + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the log. + DisplayName *string `json:"displayName,omitempty"` +} + +// ManagedIdentity a class represent managed identities used for request and response +type ManagedIdentity struct { + // Type - Represent the identity type: systemAssigned, userAssigned, None. Possible values include: 'ManagedIdentityTypeNone', 'ManagedIdentityTypeSystemAssigned', 'ManagedIdentityTypeUserAssigned' + Type ManagedIdentityType `json:"type,omitempty"` + // UserAssignedIdentities - Get or set the user assigned identities + UserAssignedIdentities map[string]*UserAssignedIdentityProperty `json:"userAssignedIdentities"` + // PrincipalID - READ-ONLY; Get the principal id for the system assigned identity. + // Only be used in response. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; Get the tenant id for the system assigned identity. + // Only be used in response + TenantID *string `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedIdentity. +func (mi ManagedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mi.Type != "" { + objectMap["type"] = mi.Type + } + if mi.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = mi.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// ManagedIdentitySettings managed identity settings for upstream. +type ManagedIdentitySettings struct { + // Resource - The Resource indicating the App ID URI of the target resource. + // It also appears in the aud (audience) claim of the issued token. + Resource *string `json:"resource,omitempty"` +} + +// MetricSpecification specifications of the Metrics for Azure Monitoring. +type MetricSpecification struct { + // Name - Name of the metric. + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // DisplayDescription - Localized friendly description of the metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + // Unit - The unit that makes sense for the metric. + Unit *string `json:"unit,omitempty"` + // AggregationType - Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count. + AggregationType *string `json:"aggregationType,omitempty"` + // FillGapWithZero - Optional. If set to true, then zero will be returned for time duration where no metric is emitted/published. + // Ex. a metric that returns the number of times a particular error code was emitted. The error code may not appear + // often, instead of the RP publishing 0, Shoebox can auto fill in 0s for time periods where nothing was emitted. + FillGapWithZero *string `json:"fillGapWithZero,omitempty"` + // Category - The name of the metric category that the metric belongs to. A metric can only belong to a single category. + Category *string `json:"category,omitempty"` + // Dimensions - The dimensions of the metrics. + Dimensions *[]Dimension `json:"dimensions,omitempty"` +} + +// NameAvailability result of the request to check name availability. It contains a flag and possible +// reason of failure. +type NameAvailability struct { + autorest.Response `json:"-"` + // NameAvailable - Indicates whether the name is available or not. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - The reason of the availability. Required if name is not available. + Reason *string `json:"reason,omitempty"` + // Message - The message of the operation. + Message *string `json:"message,omitempty"` +} + +// NameAvailabilityParameters data POST-ed to the nameAvailability action +type NameAvailabilityParameters struct { + // Type - The resource type. Can be "Microsoft.SignalRService/SignalR" or "Microsoft.SignalRService/webPubSub" + Type *string `json:"type,omitempty"` + // Name - The resource name to validate. e.g."my-resource-name" + Name *string `json:"name,omitempty"` +} + +// NetworkACL network ACL +type NetworkACL struct { + // Allow - Allowed request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Allow *[]RequestType `json:"allow,omitempty"` + // Deny - Denied request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Deny *[]RequestType `json:"deny,omitempty"` +} + +// NetworkACLs network ACLs for the resource +type NetworkACLs struct { + // DefaultAction - Default action when no other rule matches. Possible values include: 'ACLActionAllow', 'ACLActionDeny' + DefaultAction ACLAction `json:"defaultAction,omitempty"` + // PublicNetwork - ACL for requests from public network + PublicNetwork *NetworkACL `json:"publicNetwork,omitempty"` + // PrivateEndpoints - ACLs for requests from private endpoints + PrivateEndpoints *[]PrivateEndpointACL `json:"privateEndpoints,omitempty"` +} + +// Operation REST API operation supported by resource provider. +type Operation struct { + // Name - Name of the operation with format: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // IsDataAction - If the operation is a data action. (for data plane rbac) + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - The object that describes the operation. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - Optional. The intended executor of the operation; governs the display of the operation in the RBAC UX and the audit logs UX. + Origin *string `json:"origin,omitempty"` + // Properties - Extra properties for the operation. + Properties *OperationProperties `json:"properties,omitempty"` +} + +// OperationDisplay the object that describes a operation. +type OperationDisplay struct { + // Provider - Friendly name of the resource provider + Provider *string `json:"provider,omitempty"` + // Resource - Resource type on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - The localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - The localized friendly description for the operation + Description *string `json:"description,omitempty"` +} + +// OperationList result of the request to list REST API operations. It contains a list of operations. +type OperationList struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - The URL the client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListIterator) Response() OperationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{ + fn: getNextPage, + ol: cur, + } +} + +// OperationProperties extra Operation properties. +type OperationProperties struct { + // ServiceSpecification - The service specifications. + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// PrivateEndpoint private endpoint +type PrivateEndpoint struct { + // ID - Full qualified Id of the private endpoint + ID *string `json:"id,omitempty"` +} + +// PrivateEndpointACL ACL for a private endpoint +type PrivateEndpointACL struct { + // Name - Name of the private endpoint connection + Name *string `json:"name,omitempty"` + // Allow - Allowed request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Allow *[]RequestType `json:"allow,omitempty"` + // Deny - Denied request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Deny *[]RequestType `json:"deny,omitempty"` +} + +// PrivateEndpointConnection a private endpoint connection to an azure resource +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // PrivateEndpointConnectionProperties - Properties of the private endpoint connection + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + pec.SystemData = &systemData + } + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionList a list of private endpoint connections +type PrivateEndpointConnectionList struct { + autorest.Response `json:"-"` + // Value - The list of the private endpoint connections + Value *[]PrivateEndpointConnection `json:"value,omitempty"` + // NextLink - Request URL that can be used to query next page of private endpoint connections. Returned when the total number of requested private endpoint connections exceed maximum page size. + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateEndpointConnectionListIterator provides access to a complete listing of PrivateEndpointConnection +// values. +type PrivateEndpointConnectionListIterator struct { + i int + page PrivateEndpointConnectionListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateEndpointConnectionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateEndpointConnectionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateEndpointConnectionListIterator) Response() PrivateEndpointConnectionList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateEndpointConnectionListIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListIterator type. +func NewPrivateEndpointConnectionListIterator(page PrivateEndpointConnectionListPage) PrivateEndpointConnectionListIterator { + return PrivateEndpointConnectionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pecl PrivateEndpointConnectionList) IsEmpty() bool { + return pecl.Value == nil || len(*pecl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pecl PrivateEndpointConnectionList) hasNextLink() bool { + return pecl.NextLink != nil && len(*pecl.NextLink) != 0 +} + +// privateEndpointConnectionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pecl PrivateEndpointConnectionList) privateEndpointConnectionListPreparer(ctx context.Context) (*http.Request, error) { + if !pecl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pecl.NextLink))) +} + +// PrivateEndpointConnectionListPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListPage struct { + fn func(context.Context, PrivateEndpointConnectionList) (PrivateEndpointConnectionList, error) + pecl PrivateEndpointConnectionList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateEndpointConnectionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.pecl) + if err != nil { + return err + } + page.pecl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateEndpointConnectionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListPage) NotDone() bool { + return !page.pecl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListPage) Response() PrivateEndpointConnectionList { + return page.pecl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListPage) Values() []PrivateEndpointConnection { + if page.pecl.IsEmpty() { + return nil + } + return *page.pecl.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListPage type. +func NewPrivateEndpointConnectionListPage(cur PrivateEndpointConnectionList, getNextPage func(context.Context, PrivateEndpointConnectionList) (PrivateEndpointConnectionList, error)) PrivateEndpointConnectionListPage { + return PrivateEndpointConnectionListPage{ + fn: getNextPage, + pecl: cur, + } +} + +// PrivateEndpointConnectionProperties private endpoint connection properties +type PrivateEndpointConnectionProperties struct { + // ProvisioningState - READ-ONLY; Provisioning state of the private endpoint connection. Possible values include: 'ProvisioningStateUnknown', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateRunning', 'ProvisioningStateCreating', 'ProvisioningStateUpdating', 'ProvisioningStateDeleting', 'ProvisioningStateMoving' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // PrivateEndpoint - Private endpoint associated with the private endpoint connection + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection state + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pecp.PrivateEndpoint + } + if pecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("signalr.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkResource private link resource +type PrivateLinkResource struct { + // PrivateLinkResourceProperties - Properties of a private link resource + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceList contains a list of PrivateLinkResource and a possible link to query more results +type PrivateLinkResourceList struct { + autorest.Response `json:"-"` + // Value - List of PrivateLinkResource + Value *[]PrivateLinkResource `json:"value,omitempty"` + // NextLink - The URL the client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateLinkResourceListIterator provides access to a complete listing of PrivateLinkResource values. +type PrivateLinkResourceListIterator struct { + i int + page PrivateLinkResourceListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkResourceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkResourceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkResourceListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkResourceListIterator) Response() PrivateLinkResourceList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkResourceListIterator) Value() PrivateLinkResource { + if !iter.page.NotDone() { + return PrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkResourceListIterator type. +func NewPrivateLinkResourceListIterator(page PrivateLinkResourceListPage) PrivateLinkResourceListIterator { + return PrivateLinkResourceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plrl PrivateLinkResourceList) IsEmpty() bool { + return plrl.Value == nil || len(*plrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plrl PrivateLinkResourceList) hasNextLink() bool { + return plrl.NextLink != nil && len(*plrl.NextLink) != 0 +} + +// privateLinkResourceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plrl PrivateLinkResourceList) privateLinkResourceListPreparer(ctx context.Context) (*http.Request, error) { + if !plrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plrl.NextLink))) +} + +// PrivateLinkResourceListPage contains a page of PrivateLinkResource values. +type PrivateLinkResourceListPage struct { + fn func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error) + plrl PrivateLinkResourceList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkResourceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plrl) + if err != nil { + return err + } + page.plrl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkResourceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkResourceListPage) NotDone() bool { + return !page.plrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkResourceListPage) Response() PrivateLinkResourceList { + return page.plrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkResourceListPage) Values() []PrivateLinkResource { + if page.plrl.IsEmpty() { + return nil + } + return *page.plrl.Value +} + +// Creates a new instance of the PrivateLinkResourceListPage type. +func NewPrivateLinkResourceListPage(cur PrivateLinkResourceList, getNextPage func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error)) PrivateLinkResourceListPage { + return PrivateLinkResourceListPage{ + fn: getNextPage, + plrl: cur, + } +} + +// PrivateLinkResourceProperties private link resource properties +type PrivateLinkResourceProperties struct { + // GroupID - Group Id of the private link resource + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - Required members of the private link resource + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - Required private DNS zone names + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` + // ShareablePrivateLinkResourceTypes - The list of resources that are onboarded to private link service + ShareablePrivateLinkResourceTypes *[]ShareablePrivateLinkResourceType `json:"shareablePrivateLinkResourceTypes,omitempty"` +} + +// PrivateLinkServiceConnectionState connection state of the private endpoint connection +type PrivateLinkServiceConnectionState struct { + // Status - Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. Possible values include: 'PrivateLinkServiceConnectionStatusPending', 'PrivateLinkServiceConnectionStatusApproved', 'PrivateLinkServiceConnectionStatusRejected', 'PrivateLinkServiceConnectionStatusDisconnected' + Status PrivateLinkServiceConnectionStatus `json:"status,omitempty"` + // Description - The reason for approval/rejection of the connection. + Description *string `json:"description,omitempty"` + // ActionsRequired - A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// Properties a class that describes the properties of the resource +type Properties struct { + // ProvisioningState - READ-ONLY; Provisioning state of the resource. Possible values include: 'ProvisioningStateUnknown', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateRunning', 'ProvisioningStateCreating', 'ProvisioningStateUpdating', 'ProvisioningStateDeleting', 'ProvisioningStateMoving' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ExternalIP - READ-ONLY; The publicly accessible IP of the resource. + ExternalIP *string `json:"externalIP,omitempty"` + // HostName - READ-ONLY; FQDN of the service instance. + HostName *string `json:"hostName,omitempty"` + // PublicPort - READ-ONLY; The publicly accessible port of the resource which is designed for browser/client side usage. + PublicPort *int32 `json:"publicPort,omitempty"` + // ServerPort - READ-ONLY; The publicly accessible port of the resource which is designed for customer server side usage. + ServerPort *int32 `json:"serverPort,omitempty"` + // Version - READ-ONLY; Version of the resource. Probably you need the same or higher version of client SDKs. + Version *string `json:"version,omitempty"` + // PrivateEndpointConnections - READ-ONLY; Private endpoint connections to the resource. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // SharedPrivateLinkResources - READ-ONLY; The list of shared private link resources. + SharedPrivateLinkResources *[]SharedPrivateLinkResource `json:"sharedPrivateLinkResources,omitempty"` + // TLS - TLS settings. + TLS *TLSSettings `json:"tls,omitempty"` + // Features - List of the featureFlags. + // + // FeatureFlags that are not included in the parameters for the update operation will not be modified. + // And the response will only include featureFlags that are explicitly set. + // When a featureFlag is not explicitly set, its globally default value will be used + // But keep in mind, the default value doesn't mean "false". It varies in terms of different FeatureFlags. + Features *[]Feature `json:"features,omitempty"` + // Cors - Cross-Origin Resource Sharing (CORS) settings. + Cors *CorsSettings `json:"cors,omitempty"` + // Upstream - Upstream settings when the service is in server-less mode. + Upstream *ServerlessUpstreamSettings `json:"upstream,omitempty"` + // NetworkACLs - Network ACLs + NetworkACLs *NetworkACLs `json:"networkACLs,omitempty"` + // PublicNetworkAccess - Enable or disable public network access. Default to "Enabled". + // When it's Enabled, network ACLs still apply. + // When it's Disabled, public network access is always disabled no matter what you set in network ACLs. + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + // DisableLocalAuth - DisableLocalAuth + // Enable or disable local auth with AccessKey + // When set as true, connection with AccessKey=xxx won't work. + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + // DisableAadAuth - disableAadAuth + // Enable or disable aad auth + // When set as true, connection with AuthType=aad won't work. + DisableAadAuth *bool `json:"disableAadAuth,omitempty"` +} + +// MarshalJSON is the custom marshaler for Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.TLS != nil { + objectMap["tls"] = p.TLS + } + if p.Features != nil { + objectMap["features"] = p.Features + } + if p.Cors != nil { + objectMap["cors"] = p.Cors + } + if p.Upstream != nil { + objectMap["upstream"] = p.Upstream + } + if p.NetworkACLs != nil { + objectMap["networkACLs"] = p.NetworkACLs + } + if p.PublicNetworkAccess != nil { + objectMap["publicNetworkAccess"] = p.PublicNetworkAccess + } + if p.DisableLocalAuth != nil { + objectMap["disableLocalAuth"] = p.DisableLocalAuth + } + if p.DisableAadAuth != nil { + objectMap["disableAadAuth"] = p.DisableAadAuth + } + return json.Marshal(objectMap) +} + +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RegenerateKeyFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type RegenerateKeyFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (Keys, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *RegenerateKeyFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for RegenerateKeyFuture.Result. +func (future *RegenerateKeyFuture) result(client Client) (kVar Keys, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.RegenerateKeyFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + kVar.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("signalr.RegenerateKeyFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if kVar.Response.Response, err = future.GetResult(sender); err == nil && kVar.Response.Response.StatusCode != http.StatusNoContent { + kVar, err = client.RegenerateKeyResponder(kVar.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.RegenerateKeyFuture", "Result", kVar.Response.Response, "Failure responding to request") + } + } + return +} + +// RegenerateKeyParameters parameters describes the request to regenerate access keys +type RegenerateKeyParameters struct { + // KeyType - The keyType to regenerate. Must be either 'primary' or 'secondary'(case-insensitive). Possible values include: 'KeyTypePrimary', 'KeyTypeSecondary' + KeyType KeyType `json:"keyType,omitempty"` +} + +// Resource the core properties of ARM resources. +type Resource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceList object that includes an array of resources and a possible link for next set. +type ResourceList struct { + autorest.Response `json:"-"` + // Value - List of the resources + Value *[]ResourceType `json:"value,omitempty"` + // NextLink - The URL the client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// ResourceListIterator provides access to a complete listing of ResourceType values. +type ResourceListIterator struct { + i int + page ResourceListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ResourceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ResourceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ResourceListIterator) Response() ResourceList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ResourceListIterator) Value() ResourceType { + if !iter.page.NotDone() { + return ResourceType{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ResourceListIterator type. +func NewResourceListIterator(page ResourceListPage) ResourceListIterator { + return ResourceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rl ResourceList) IsEmpty() bool { + return rl.Value == nil || len(*rl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rl ResourceList) hasNextLink() bool { + return rl.NextLink != nil && len(*rl.NextLink) != 0 +} + +// resourceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rl ResourceList) resourceListPreparer(ctx context.Context) (*http.Request, error) { + if !rl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rl.NextLink))) +} + +// ResourceListPage contains a page of ResourceType values. +type ResourceListPage struct { + fn func(context.Context, ResourceList) (ResourceList, error) + rl ResourceList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ResourceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rl) + if err != nil { + return err + } + page.rl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ResourceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceListPage) NotDone() bool { + return !page.rl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceListPage) Response() ResourceList { + return page.rl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceListPage) Values() []ResourceType { + if page.rl.IsEmpty() { + return nil + } + return *page.rl.Value +} + +// Creates a new instance of the ResourceListPage type. +func NewResourceListPage(cur ResourceList, getNextPage func(context.Context, ResourceList) (ResourceList, error)) ResourceListPage { + return ResourceListPage{ + fn: getNextPage, + rl: cur, + } +} + +// ResourceSku the billing information of the resource. +type ResourceSku struct { + // Name - The name of the SKU. Required. + // + // Allowed values: Standard_S1, Free_F1 + Name *string `json:"name,omitempty"` + // Tier - Optional tier of this particular SKU. 'Standard' or 'Free'. + // + // `Basic` is deprecated, use `Standard` instead. Possible values include: 'SkuTierFree', 'SkuTierBasic', 'SkuTierStandard', 'SkuTierPremium' + Tier SkuTier `json:"tier,omitempty"` + // Size - READ-ONLY; Not used. Retained for future use. + Size *string `json:"size,omitempty"` + // Family - READ-ONLY; Not used. Retained for future use. + Family *string `json:"family,omitempty"` + // Capacity - Optional, integer. The unit count of the resource. 1 by default. + // + // If present, following values are allowed: + // Free: 1 + // Standard: 1,2,5,10,20,50,100 + Capacity *int32 `json:"capacity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceSku. +func (rs ResourceSku) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rs.Name != nil { + objectMap["name"] = rs.Name + } + if rs.Tier != "" { + objectMap["tier"] = rs.Tier + } + if rs.Capacity != nil { + objectMap["capacity"] = rs.Capacity + } + return json.Marshal(objectMap) +} + +// ResourceType a class represent a resource. +type ResourceType struct { + autorest.Response `json:"-"` + // Sku - The billing information of the resource.(e.g. Free, Standard) + Sku *ResourceSku `json:"sku,omitempty"` + // Properties - Settings used to provision or configure the resource + *Properties `json:"properties,omitempty"` + // Kind - The kind of the service - e.g. "SignalR" for "Microsoft.SignalRService/SignalR". Possible values include: 'ServiceKindSignalR', 'ServiceKindRawWebSockets' + Kind ServiceKind `json:"kind,omitempty"` + // Identity - The managed identity response + Identity *ManagedIdentity `json:"identity,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // Location - The GEO location of the resource. e.g. West US | East US | North Central US | South Central US. + Location *string `json:"location,omitempty"` + // Tags - Tags of the service which is a list of key value pairs that describe the resource. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceType. +func (rt ResourceType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rt.Sku != nil { + objectMap["sku"] = rt.Sku + } + if rt.Properties != nil { + objectMap["properties"] = rt.Properties + } + if rt.Kind != "" { + objectMap["kind"] = rt.Kind + } + if rt.Identity != nil { + objectMap["identity"] = rt.Identity + } + if rt.Location != nil { + objectMap["location"] = rt.Location + } + if rt.Tags != nil { + objectMap["tags"] = rt.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ResourceType struct. +func (rt *ResourceType) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku ResourceSku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + rt.Sku = &sku + } + case "properties": + if v != nil { + var properties Properties + err = json.Unmarshal(*v, &properties) + if err != nil { + return err + } + rt.Properties = &properties + } + case "kind": + if v != nil { + var kind ServiceKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + rt.Kind = kind + } + case "identity": + if v != nil { + var identity ManagedIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + rt.Identity = &identity + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + rt.SystemData = &systemData + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rt.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rt.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rt.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rt.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rt.Type = &typeVar + } + } + } + + return nil +} + +// RestartFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type RestartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *RestartFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for RestartFuture.Result. +func (future *RestartFuture) result(client Client) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.RestartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("signalr.RestartFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerlessUpstreamSettings the settings for the Upstream when the service is in server-less mode. +type ServerlessUpstreamSettings struct { + // Templates - Gets or sets the list of Upstream URL templates. Order matters, and the first matching template takes effects. + Templates *[]UpstreamTemplate `json:"templates,omitempty"` +} + +// ServiceSpecification an object that describes a specification. +type ServiceSpecification struct { + // MetricSpecifications - Specifications of the Metrics for Azure Monitoring. + MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` + // LogSpecifications - Specifications of the Logs for Azure Monitoring. + LogSpecifications *[]LogSpecification `json:"logSpecifications,omitempty"` +} + +// ShareablePrivateLinkResourceProperties describes the properties of a resource type that has been +// onboarded to private link service +type ShareablePrivateLinkResourceProperties struct { + // Description - The description of the resource type that has been onboarded to private link service + Description *string `json:"description,omitempty"` + // GroupID - The resource provider group id for the resource that has been onboarded to private link service + GroupID *string `json:"groupId,omitempty"` + // Type - The resource provider type for the resource that has been onboarded to private link service + Type *string `json:"type,omitempty"` +} + +// ShareablePrivateLinkResourceType describes a resource type that has been onboarded to private link +// service +type ShareablePrivateLinkResourceType struct { + // Name - The name of the resource type that has been onboarded to private link service + Name *string `json:"name,omitempty"` + // Properties - Describes the properties of a resource type that has been onboarded to private link service + Properties *ShareablePrivateLinkResourceProperties `json:"properties,omitempty"` +} + +// SharedPrivateLinkResource describes a Shared Private Link Resource +type SharedPrivateLinkResource struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // SharedPrivateLinkResourceProperties - Describes the properties of a Shared Private Link Resource + *SharedPrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SharedPrivateLinkResource. +func (splr SharedPrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if splr.SharedPrivateLinkResourceProperties != nil { + objectMap["properties"] = splr.SharedPrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SharedPrivateLinkResource struct. +func (splr *SharedPrivateLinkResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + splr.SystemData = &systemData + } + case "properties": + if v != nil { + var sharedPrivateLinkResourceProperties SharedPrivateLinkResourceProperties + err = json.Unmarshal(*v, &sharedPrivateLinkResourceProperties) + if err != nil { + return err + } + splr.SharedPrivateLinkResourceProperties = &sharedPrivateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + splr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + splr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + splr.Type = &typeVar + } + } + } + + return nil +} + +// SharedPrivateLinkResourceList a list of shared private link resources +type SharedPrivateLinkResourceList struct { + autorest.Response `json:"-"` + // Value - The list of the shared private link resources + Value *[]SharedPrivateLinkResource `json:"value,omitempty"` + // NextLink - Request URL that can be used to query next page of private endpoint connections. Returned when the total number of requested private endpoint connections exceed maximum page size. + NextLink *string `json:"nextLink,omitempty"` +} + +// SharedPrivateLinkResourceListIterator provides access to a complete listing of SharedPrivateLinkResource +// values. +type SharedPrivateLinkResourceListIterator struct { + i int + page SharedPrivateLinkResourceListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SharedPrivateLinkResourceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourceListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SharedPrivateLinkResourceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SharedPrivateLinkResourceListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SharedPrivateLinkResourceListIterator) Response() SharedPrivateLinkResourceList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SharedPrivateLinkResourceListIterator) Value() SharedPrivateLinkResource { + if !iter.page.NotDone() { + return SharedPrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SharedPrivateLinkResourceListIterator type. +func NewSharedPrivateLinkResourceListIterator(page SharedPrivateLinkResourceListPage) SharedPrivateLinkResourceListIterator { + return SharedPrivateLinkResourceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (splrl SharedPrivateLinkResourceList) IsEmpty() bool { + return splrl.Value == nil || len(*splrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (splrl SharedPrivateLinkResourceList) hasNextLink() bool { + return splrl.NextLink != nil && len(*splrl.NextLink) != 0 +} + +// sharedPrivateLinkResourceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (splrl SharedPrivateLinkResourceList) sharedPrivateLinkResourceListPreparer(ctx context.Context) (*http.Request, error) { + if !splrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(splrl.NextLink))) +} + +// SharedPrivateLinkResourceListPage contains a page of SharedPrivateLinkResource values. +type SharedPrivateLinkResourceListPage struct { + fn func(context.Context, SharedPrivateLinkResourceList) (SharedPrivateLinkResourceList, error) + splrl SharedPrivateLinkResourceList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SharedPrivateLinkResourceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourceListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.splrl) + if err != nil { + return err + } + page.splrl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SharedPrivateLinkResourceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SharedPrivateLinkResourceListPage) NotDone() bool { + return !page.splrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SharedPrivateLinkResourceListPage) Response() SharedPrivateLinkResourceList { + return page.splrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SharedPrivateLinkResourceListPage) Values() []SharedPrivateLinkResource { + if page.splrl.IsEmpty() { + return nil + } + return *page.splrl.Value +} + +// Creates a new instance of the SharedPrivateLinkResourceListPage type. +func NewSharedPrivateLinkResourceListPage(cur SharedPrivateLinkResourceList, getNextPage func(context.Context, SharedPrivateLinkResourceList) (SharedPrivateLinkResourceList, error)) SharedPrivateLinkResourceListPage { + return SharedPrivateLinkResourceListPage{ + fn: getNextPage, + splrl: cur, + } +} + +// SharedPrivateLinkResourceProperties describes the properties of an existing Shared Private Link Resource +type SharedPrivateLinkResourceProperties struct { + // GroupID - The group id from the provider of resource the shared private link resource is for + GroupID *string `json:"groupId,omitempty"` + // PrivateLinkResourceID - The resource id of the resource the shared private link resource is for + PrivateLinkResourceID *string `json:"privateLinkResourceId,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the shared private link resource. Possible values include: 'ProvisioningStateUnknown', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateRunning', 'ProvisioningStateCreating', 'ProvisioningStateUpdating', 'ProvisioningStateDeleting', 'ProvisioningStateMoving' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // RequestMessage - The request message for requesting approval of the shared private link resource + RequestMessage *string `json:"requestMessage,omitempty"` + // Status - READ-ONLY; Status of the shared private link resource. Possible values include: 'SharedPrivateLinkResourceStatusPending', 'SharedPrivateLinkResourceStatusApproved', 'SharedPrivateLinkResourceStatusRejected', 'SharedPrivateLinkResourceStatusDisconnected', 'SharedPrivateLinkResourceStatusTimeout' + Status SharedPrivateLinkResourceStatus `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for SharedPrivateLinkResourceProperties. +func (splrp SharedPrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if splrp.GroupID != nil { + objectMap["groupId"] = splrp.GroupID + } + if splrp.PrivateLinkResourceID != nil { + objectMap["privateLinkResourceId"] = splrp.PrivateLinkResourceID + } + if splrp.RequestMessage != nil { + objectMap["requestMessage"] = splrp.RequestMessage + } + return json.Marshal(objectMap) +} + +// SharedPrivateLinkResourcesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SharedPrivateLinkResourcesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SharedPrivateLinkResourcesClient) (SharedPrivateLinkResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SharedPrivateLinkResourcesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SharedPrivateLinkResourcesCreateOrUpdateFuture.Result. +func (future *SharedPrivateLinkResourcesCreateOrUpdateFuture) result(client SharedPrivateLinkResourcesClient) (splr SharedPrivateLinkResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + splr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("signalr.SharedPrivateLinkResourcesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if splr.Response.Response, err = future.GetResult(sender); err == nil && splr.Response.Response.StatusCode != http.StatusNoContent { + splr, err = client.CreateOrUpdateResponder(splr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesCreateOrUpdateFuture", "Result", splr.Response.Response, "Failure responding to request") + } + } + return +} + +// SharedPrivateLinkResourcesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SharedPrivateLinkResourcesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SharedPrivateLinkResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SharedPrivateLinkResourcesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SharedPrivateLinkResourcesDeleteFuture.Result. +func (future *SharedPrivateLinkResourcesDeleteFuture) result(client SharedPrivateLinkResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("signalr.SharedPrivateLinkResourcesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TLSSettings TLS settings for the resource +type TLSSettings struct { + // ClientCertEnabled - Request client certificate during TLS handshake if enabled + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource. +type TrackedResource struct { + // Location - The GEO location of the resource. e.g. West US | East US | North Central US | South Central US. + Location *string `json:"location,omitempty"` + // Tags - Tags of the service which is a list of key value pairs that describe the resource. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type UpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (ResourceType, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *UpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for UpdateFuture.Result. +func (future *UpdateFuture) result(client Client) (rt ResourceType, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.UpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + rt.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("signalr.UpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rt.Response.Response, err = future.GetResult(sender); err == nil && rt.Response.Response.StatusCode != http.StatusNoContent { + rt, err = client.UpdateResponder(rt.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.UpdateFuture", "Result", rt.Response.Response, "Failure responding to request") + } + } + return +} + +// UpstreamAuthSettings upstream auth settings. +type UpstreamAuthSettings struct { + // Type - Gets or sets the type of auth. None or ManagedIdentity is supported now. Possible values include: 'UpstreamAuthTypeNone', 'UpstreamAuthTypeManagedIdentity' + Type UpstreamAuthType `json:"type,omitempty"` + // ManagedIdentity - Gets or sets the managed identity settings. It's required if the auth type is set to ManagedIdentity. + ManagedIdentity *ManagedIdentitySettings `json:"managedIdentity,omitempty"` +} + +// UpstreamTemplate upstream template item settings. It defines the Upstream URL of the incoming requests. +// The template defines the pattern of the event, the hub or the category of the incoming request that +// matches current URL template. +type UpstreamTemplate struct { + // HubPattern - Gets or sets the matching pattern for hub names. If not set, it matches any hub. + // There are 3 kind of patterns supported: + // 1. "*", it to matches any hub name + // 2. Combine multiple hubs with ",", for example "hub1,hub2", it matches "hub1" and "hub2" + // 3. The single hub name, for example, "hub1", it matches "hub1" + HubPattern *string `json:"hubPattern,omitempty"` + // EventPattern - Gets or sets the matching pattern for event names. If not set, it matches any event. + // There are 3 kind of patterns supported: + // 1. "*", it to matches any event name + // 2. Combine multiple events with ",", for example "connect,disconnect", it matches event "connect" and "disconnect" + // 3. The single event name, for example, "connect", it matches "connect" + EventPattern *string `json:"eventPattern,omitempty"` + // CategoryPattern - Gets or sets the matching pattern for category names. If not set, it matches any category. + // There are 3 kind of patterns supported: + // 1. "*", it to matches any category name + // 2. Combine multiple categories with ",", for example "connections,messages", it matches category "connections" and "messages" + // 3. The single category name, for example, "connections", it matches the category "connections" + CategoryPattern *string `json:"categoryPattern,omitempty"` + // URLTemplate - Gets or sets the Upstream URL template. You can use 3 predefined parameters {hub}, {category} {event} inside the template, the value of the Upstream URL is dynamically calculated when the client request comes in. + // For example, if the urlTemplate is `http://example.com/{hub}/api/{event}`, with a client request from hub `chat` connects, it will first POST to this URL: `http://example.com/chat/api/connect`. + URLTemplate *string `json:"urlTemplate,omitempty"` + // Auth - Gets or sets the auth settings for an upstream. If not set, no auth is used for upstream messages. + Auth *UpstreamAuthSettings `json:"auth,omitempty"` +} + +// Usage object that describes a specific usage of the resources. +type Usage struct { + // ID - Fully qualified ARM resource id + ID *string `json:"id,omitempty"` + // CurrentValue - Current value for the usage quota. + CurrentValue *int64 `json:"currentValue,omitempty"` + // Limit - The maximum permitted value for the usage quota. If there is no limit, this value will be -1. + Limit *int64 `json:"limit,omitempty"` + // Name - Localizable String object containing the name and a localized value. + Name *UsageName `json:"name,omitempty"` + // Unit - Representing the units of the usage quota. Possible values are: Count, Bytes, Seconds, Percent, CountPerSecond, BytesPerSecond. + Unit *string `json:"unit,omitempty"` +} + +// UsageList object that includes an array of the resource usages and a possible link for next set. +type UsageList struct { + autorest.Response `json:"-"` + // Value - List of the resource usages + Value *[]Usage `json:"value,omitempty"` + // NextLink - The URL the client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// UsageListIterator provides access to a complete listing of Usage values. +type UsageListIterator struct { + i int + page UsageListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *UsageListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *UsageListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter UsageListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter UsageListIterator) Response() UsageList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter UsageListIterator) Value() Usage { + if !iter.page.NotDone() { + return Usage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the UsageListIterator type. +func NewUsageListIterator(page UsageListPage) UsageListIterator { + return UsageListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ul UsageList) IsEmpty() bool { + return ul.Value == nil || len(*ul.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ul UsageList) hasNextLink() bool { + return ul.NextLink != nil && len(*ul.NextLink) != 0 +} + +// usageListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ul UsageList) usageListPreparer(ctx context.Context) (*http.Request, error) { + if !ul.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ul.NextLink))) +} + +// UsageListPage contains a page of Usage values. +type UsageListPage struct { + fn func(context.Context, UsageList) (UsageList, error) + ul UsageList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *UsageListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ul) + if err != nil { + return err + } + page.ul = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *UsageListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page UsageListPage) NotDone() bool { + return !page.ul.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page UsageListPage) Response() UsageList { + return page.ul +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page UsageListPage) Values() []Usage { + if page.ul.IsEmpty() { + return nil + } + return *page.ul.Value +} + +// Creates a new instance of the UsageListPage type. +func NewUsageListPage(cur UsageList, getNextPage func(context.Context, UsageList) (UsageList, error)) UsageListPage { + return UsageListPage{ + fn: getNextPage, + ul: cur, + } +} + +// UsageName localizable String object containing the name and a localized value. +type UsageName struct { + // Value - The identifier of the usage. + Value *string `json:"value,omitempty"` + // LocalizedValue - Localized name of the usage. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// UserAssignedIdentityProperty properties of user assigned identity. +type UserAssignedIdentityProperty struct { + // PrincipalID - READ-ONLY; Get the principal id for the user assigned identity + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - READ-ONLY; Get the client id for the user assigned identity + ClientID *string `json:"clientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserAssignedIdentityProperty. +func (uaip UserAssignedIdentityProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/operations.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/operations.go new file mode 100644 index 000000000000..fdc9420176a2 --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/operations.go @@ -0,0 +1,140 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the REST API for Azure SignalR Service +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations of the Microsoft.SignalRService provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.SignalRService/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "signalr.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "signalr.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/privateendpointconnections.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/privateendpointconnections.go new file mode 100644 index 000000000000..e8314cdaf0c6 --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/privateendpointconnections.go @@ -0,0 +1,393 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient is the REST API for Azure SignalR Service +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete the specified private endpoint connection +// Parameters: +// privateEndpointConnectionName - the name of the private endpoint connection +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, privateEndpointConnectionName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the specified private endpoint connection +// Parameters: +// privateEndpointConnectionName - the name of the private endpoint connection +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, privateEndpointConnectionName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list private endpoint connections +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") + defer func() { + sc := -1 + if result.pecl.Response.Response != nil { + sc = result.pecl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.pecl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "List", resp, "Failure sending request") + return + } + + result.pecl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "List", resp, "Failure responding to request") + return + } + if result.pecl.hasNextLink() && result.pecl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateEndpointConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result PrivateEndpointConnectionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsClient) listNextResults(ctx context.Context, lastResults PrivateEndpointConnectionList) (result PrivateEndpointConnectionList, err error) { + req, err := lastResults.privateEndpointConnectionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, resourceName) + return +} + +// Update update the state of specified private endpoint connection +// Parameters: +// privateEndpointConnectionName - the name of the private endpoint connection +// parameters - the resource of private endpoint and its properties +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateEndpointConnectionsClient) Update(ctx context.Context, privateEndpointConnectionName string, parameters PrivateEndpointConnection, resourceGroupName string, resourceName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, privateEndpointConnectionName, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateEndpointConnectionsClient) UpdatePreparer(ctx context.Context, privateEndpointConnectionName string, parameters PrivateEndpointConnection, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) UpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/privatelinkresources.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/privatelinkresources.go new file mode 100644 index 000000000000..47d3390427a0 --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/privatelinkresources.go @@ -0,0 +1,151 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the REST API for Azure SignalR Service +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the private link resources that need to be created for a resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.plrl.Response.Response != nil { + sc = result.plrl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "List", resp, "Failure sending request") + return + } + + result.plrl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "List", resp, "Failure responding to request") + return + } + if result.plrl.hasNextLink() && result.plrl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListResponder(resp *http.Response) (result PrivateLinkResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkResourcesClient) listNextResults(ctx context.Context, lastResults PrivateLinkResourceList) (result PrivateLinkResourceList, err error) { + req, err := lastResults.privateLinkResourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkResourcesClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/sharedprivatelinkresources.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/sharedprivatelinkresources.go new file mode 100644 index 000000000000..6605cd531a78 --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/sharedprivatelinkresources.go @@ -0,0 +1,405 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SharedPrivateLinkResourcesClient is the REST API for Azure SignalR Service +type SharedPrivateLinkResourcesClient struct { + BaseClient +} + +// NewSharedPrivateLinkResourcesClient creates an instance of the SharedPrivateLinkResourcesClient client. +func NewSharedPrivateLinkResourcesClient(subscriptionID string) SharedPrivateLinkResourcesClient { + return NewSharedPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSharedPrivateLinkResourcesClientWithBaseURI creates an instance of the SharedPrivateLinkResourcesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewSharedPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) SharedPrivateLinkResourcesClient { + return SharedPrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a shared private link resource +// Parameters: +// sharedPrivateLinkResourceName - the name of the shared private link resource +// parameters - the shared private link resource +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdate(ctx context.Context, sharedPrivateLinkResourceName string, parameters SharedPrivateLinkResource, resourceGroupName string, resourceName string) (result SharedPrivateLinkResourcesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SharedPrivateLinkResourceProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SharedPrivateLinkResourceProperties.GroupID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.SharedPrivateLinkResourceProperties.PrivateLinkResourceID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("signalr.SharedPrivateLinkResourcesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, sharedPrivateLinkResourceName, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdatePreparer(ctx context.Context, sharedPrivateLinkResourceName string, parameters SharedPrivateLinkResource, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "sharedPrivateLinkResourceName": autorest.Encode("path", sharedPrivateLinkResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdateSender(req *http.Request) (future SharedPrivateLinkResourcesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdateResponder(resp *http.Response) (result SharedPrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the specified shared private link resource +// Parameters: +// sharedPrivateLinkResourceName - the name of the shared private link resource +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client SharedPrivateLinkResourcesClient) Delete(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (result SharedPrivateLinkResourcesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, sharedPrivateLinkResourceName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SharedPrivateLinkResourcesClient) DeletePreparer(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "sharedPrivateLinkResourceName": autorest.Encode("path", sharedPrivateLinkResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) DeleteSender(req *http.Request) (future SharedPrivateLinkResourcesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the specified shared private link resource +// Parameters: +// sharedPrivateLinkResourceName - the name of the shared private link resource +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client SharedPrivateLinkResourcesClient) Get(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (result SharedPrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, sharedPrivateLinkResourceName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SharedPrivateLinkResourcesClient) GetPreparer(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "sharedPrivateLinkResourceName": autorest.Encode("path", sharedPrivateLinkResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) GetResponder(resp *http.Response) (result SharedPrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list shared private link resources +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client SharedPrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result SharedPrivateLinkResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.splrl.Response.Response != nil { + sc = result.splrl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.splrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "List", resp, "Failure sending request") + return + } + + result.splrl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "List", resp, "Failure responding to request") + return + } + if result.splrl.hasNextLink() && result.splrl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client SharedPrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) ListResponder(resp *http.Response) (result SharedPrivateLinkResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SharedPrivateLinkResourcesClient) listNextResults(ctx context.Context, lastResults SharedPrivateLinkResourceList) (result SharedPrivateLinkResourceList, err error) { + req, err := lastResults.sharedPrivateLinkResourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.SharedPrivateLinkResourcesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SharedPrivateLinkResourcesClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result SharedPrivateLinkResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/signalr.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/signalr.go new file mode 100644 index 000000000000..9b72cd0ee561 --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/signalr.go @@ -0,0 +1,912 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// Client is the REST API for Azure SignalR Service +type Client struct { + BaseClient +} + +// NewClient creates an instance of the Client client. +func NewClient(subscriptionID string) Client { + return NewClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClientWithBaseURI creates an instance of the Client client using a custom endpoint. Use this when interacting +// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { + return Client{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability checks that the resource name is valid and is not already in use. +// Parameters: +// location - the region +// parameters - parameters supplied to the operation. +func (client Client) CheckNameAvailability(ctx context.Context, location string, parameters NameAvailabilityParameters) (result NameAvailability, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("signalr.Client", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, location, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.Client", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client Client) CheckNameAvailabilityPreparer(ctx context.Context, location string, parameters NameAvailabilityParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client Client) CheckNameAvailabilityResponder(resp *http.Response) (result NameAvailability, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate create or update a resource. +// Parameters: +// parameters - parameters for the create or update operation +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) CreateOrUpdate(ctx context.Context, parameters ResourceType, resourceGroupName string, resourceName string) (result CreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("signalr.Client", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client Client) CreateOrUpdatePreparer(ctx context.Context, parameters ResourceType, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CreateOrUpdateSender(req *http.Request) (future CreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client Client) CreateOrUpdateResponder(resp *http.Response) (result ResourceType, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete operation to delete a resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result DeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client Client) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client Client) DeleteSender(req *http.Request) (future DeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the resource and its properties. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ResourceType, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.Client", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client Client) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client Client) GetResponder(resp *http.Response) (result ResourceType, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup handles requests to list all resources in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup") + defer func() { + sc := -1 + if result.rl.Response.Response != nil { + sc = result.rl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.rl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.Client", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.rl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.rl.hasNextLink() && result.rl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client Client) ListByResourceGroupResponder(resp *http.Response) (result ResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client Client) listByResourceGroupNextResults(ctx context.Context, lastResults ResourceList) (result ResourceList, err error) { + req, err := lastResults.resourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "signalr.Client", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "signalr.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription handles requests to list all resources in a subscription. +func (client Client) ListBySubscription(ctx context.Context) (result ResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListBySubscription") + defer func() { + sc := -1 + if result.rl.Response.Response != nil { + sc = result.rl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.rl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.Client", "ListBySubscription", resp, "Failure sending request") + return + } + + result.rl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.rl.hasNextLink() && result.rl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client Client) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client Client) ListBySubscriptionResponder(resp *http.Response) (result ResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client Client) listBySubscriptionNextResults(ctx context.Context, lastResults ResourceList) (result ResourceList, err error) { + req, err := lastResults.resourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "signalr.Client", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "signalr.Client", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListBySubscriptionComplete(ctx context.Context) (result ResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// ListKeys get the access keys of the resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) ListKeys(ctx context.Context, resourceGroupName string, resourceName string) (result Keys, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListKeysPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.Client", "ListKeys", resp, "Failure sending request") + return + } + + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "ListKeys", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client Client) ListKeysPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client Client) ListKeysResponder(resp *http.Response) (result Keys, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateKey regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated at the +// same time. +// Parameters: +// parameters - parameter that describes the Regenerate Key Operation. +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) RegenerateKey(ctx context.Context, parameters RegenerateKeyParameters, resourceGroupName string, resourceName string) (result RegenerateKeyFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.RegenerateKey") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RegenerateKeyPreparer(ctx, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "RegenerateKey", nil, "Failure preparing request") + return + } + + result, err = client.RegenerateKeySender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "RegenerateKey", nil, "Failure sending request") + return + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client Client) RegenerateKeyPreparer(ctx context.Context, parameters RegenerateKeyParameters, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client Client) RegenerateKeySender(req *http.Request) (future RegenerateKeyFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client Client) RegenerateKeyResponder(resp *http.Response) (result Keys, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Restart operation to restart a resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) Restart(ctx context.Context, resourceGroupName string, resourceName string) (result RestartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Restart") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RestartPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "Restart", nil, "Failure preparing request") + return + } + + result, err = client.RestartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "Restart", nil, "Failure sending request") + return + } + + return +} + +// RestartPreparer prepares the Restart request. +func (client Client) RestartPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RestartSender sends the Restart request. The method will close the +// http.Response Body if it receives an error. +func (client Client) RestartSender(req *http.Request) (future RestartFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RestartResponder handles the response to the Restart request. The method always +// closes the http.Response Body. +func (client Client) RestartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update operation to update an exiting resource. +// Parameters: +// parameters - parameters for the update operation +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) Update(ctx context.Context, parameters ResourceType, resourceGroupName string, resourceName string) (result UpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.Client", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client Client) UpdatePreparer(ctx context.Context, parameters ResourceType, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client Client) UpdateSender(req *http.Request) (future UpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client Client) UpdateResponder(resp *http.Response) (result ResourceType, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/signalrapi/interfaces.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/signalrapi/interfaces.go new file mode 100644 index 000000000000..81b4fd730f6b --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/signalrapi/interfaces.go @@ -0,0 +1,76 @@ +package signalrapi + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/signalr/mgmt/2021-06-01-preview/signalr" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result signalr.OperationListPage, err error) + ListComplete(ctx context.Context) (result signalr.OperationListIterator, err error) +} + +var _ OperationsClientAPI = (*signalr.OperationsClient)(nil) + +// ClientAPI contains the set of methods on the Client type. +type ClientAPI interface { + CheckNameAvailability(ctx context.Context, location string, parameters signalr.NameAvailabilityParameters) (result signalr.NameAvailability, err error) + CreateOrUpdate(ctx context.Context, parameters signalr.ResourceType, resourceGroupName string, resourceName string) (result signalr.CreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.DeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.ResourceType, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result signalr.ResourceListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result signalr.ResourceListIterator, err error) + ListBySubscription(ctx context.Context) (result signalr.ResourceListPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result signalr.ResourceListIterator, err error) + ListKeys(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.Keys, err error) + RegenerateKey(ctx context.Context, parameters signalr.RegenerateKeyParameters, resourceGroupName string, resourceName string) (result signalr.RegenerateKeyFuture, err error) + Restart(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.RestartFuture, err error) + Update(ctx context.Context, parameters signalr.ResourceType, resourceGroupName string, resourceName string) (result signalr.UpdateFuture, err error) +} + +var _ ClientAPI = (*signalr.Client)(nil) + +// UsagesClientAPI contains the set of methods on the UsagesClient type. +type UsagesClientAPI interface { + List(ctx context.Context, location string) (result signalr.UsageListPage, err error) + ListComplete(ctx context.Context, location string) (result signalr.UsageListIterator, err error) +} + +var _ UsagesClientAPI = (*signalr.UsagesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + Delete(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result signalr.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result signalr.PrivateEndpointConnection, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.PrivateEndpointConnectionListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.PrivateEndpointConnectionListIterator, err error) + Update(ctx context.Context, privateEndpointConnectionName string, parameters signalr.PrivateEndpointConnection, resourceGroupName string, resourceName string) (result signalr.PrivateEndpointConnection, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*signalr.PrivateEndpointConnectionsClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + List(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.PrivateLinkResourceListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.PrivateLinkResourceListIterator, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*signalr.PrivateLinkResourcesClient)(nil) + +// SharedPrivateLinkResourcesClientAPI contains the set of methods on the SharedPrivateLinkResourcesClient type. +type SharedPrivateLinkResourcesClientAPI interface { + CreateOrUpdate(ctx context.Context, sharedPrivateLinkResourceName string, parameters signalr.SharedPrivateLinkResource, resourceGroupName string, resourceName string) (result signalr.SharedPrivateLinkResourcesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (result signalr.SharedPrivateLinkResourcesDeleteFuture, err error) + Get(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (result signalr.SharedPrivateLinkResource, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.SharedPrivateLinkResourceListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result signalr.SharedPrivateLinkResourceListIterator, err error) +} + +var _ SharedPrivateLinkResourcesClientAPI = (*signalr.SharedPrivateLinkResourcesClient)(nil) diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/usages.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/usages.go new file mode 100644 index 000000000000..4470dc75c8ac --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/usages.go @@ -0,0 +1,147 @@ +package signalr + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UsagesClient is the REST API for Azure SignalR Service +type UsagesClient struct { + BaseClient +} + +// NewUsagesClient creates an instance of the UsagesClient client. +func NewUsagesClient(subscriptionID string) UsagesClient { + return NewUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsagesClientWithBaseURI creates an instance of the UsagesClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesClient { + return UsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list resource usage quotas by location. +// Parameters: +// location - the location like "eastus" +func (client UsagesClient) List(ctx context.Context, location string) (result UsageListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsagesClient.List") + defer func() { + sc := -1 + if result.ul.Response.Response != nil { + sc = result.ul.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.UsagesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ul.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.UsagesClient", "List", resp, "Failure sending request") + return + } + + result.ul, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.UsagesClient", "List", resp, "Failure responding to request") + return + } + if result.ul.hasNextLink() && result.ul.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client UsagesClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client UsagesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UsagesClient) ListResponder(resp *http.Response) (result UsageList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client UsagesClient) listNextResults(ctx context.Context, lastResults UsageList) (result UsageList, err error) { + req, err := lastResults.usageListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "signalr.UsagesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "signalr.UsagesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.UsagesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client UsagesClient) ListComplete(ctx context.Context, location string) (result UsageListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsagesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, location) + return +} diff --git a/services/preview/signalr/mgmt/2021-06-01-preview/signalr/version.go b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/version.go new file mode 100644 index 000000000000..996c58bc23ed --- /dev/null +++ b/services/preview/signalr/mgmt/2021-06-01-preview/signalr/version.go @@ -0,0 +1,19 @@ +package signalr + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " signalr/2021-06-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/CHANGELOG.md b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/_meta.json b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/_meta.json new file mode 100644 index 000000000000..5fcfd56617ce --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "b548283ea6f4b3d797e85432fcc6e3ff2a2ac224", + "readme": "/_/azure-rest-api-specs/specification/webpubsub/resource-manager/readme.md", + "tag": "package-2021-06-01-preview", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2021-06-01-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/webpubsub/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/client.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/client.go new file mode 100644 index 000000000000..48a1ac7ed67c --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/client.go @@ -0,0 +1,41 @@ +// Package webpubsub implements the Azure ARM Webpubsub service API version 2021-06-01-preview. +// +// REST API for Azure WebPubSub Service +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Webpubsub + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Webpubsub. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/enums.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/enums.go new file mode 100644 index 000000000000..79c69ed717dc --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/enums.go @@ -0,0 +1,195 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights 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. + +// ACLAction enumerates the values for acl action. +type ACLAction string + +const ( + // ACLActionAllow ... + ACLActionAllow ACLAction = "Allow" + // ACLActionDeny ... + ACLActionDeny ACLAction = "Deny" +) + +// PossibleACLActionValues returns an array of possible values for the ACLAction const type. +func PossibleACLActionValues() []ACLAction { + return []ACLAction{ACLActionAllow, ACLActionDeny} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// KeyType enumerates the values for key type. +type KeyType string + +const ( + // KeyTypePrimary ... + KeyTypePrimary KeyType = "Primary" + // KeyTypeSecondary ... + KeyTypeSecondary KeyType = "Secondary" +) + +// PossibleKeyTypeValues returns an array of possible values for the KeyType const type. +func PossibleKeyTypeValues() []KeyType { + return []KeyType{KeyTypePrimary, KeyTypeSecondary} +} + +// ManagedIdentityType enumerates the values for managed identity type. +type ManagedIdentityType string + +const ( + // ManagedIdentityTypeNone ... + ManagedIdentityTypeNone ManagedIdentityType = "None" + // ManagedIdentityTypeSystemAssigned ... + ManagedIdentityTypeSystemAssigned ManagedIdentityType = "SystemAssigned" + // ManagedIdentityTypeUserAssigned ... + ManagedIdentityTypeUserAssigned ManagedIdentityType = "UserAssigned" +) + +// PossibleManagedIdentityTypeValues returns an array of possible values for the ManagedIdentityType const type. +func PossibleManagedIdentityTypeValues() []ManagedIdentityType { + return []ManagedIdentityType{ManagedIdentityTypeNone, ManagedIdentityTypeSystemAssigned, ManagedIdentityTypeUserAssigned} +} + +// PrivateLinkServiceConnectionStatus enumerates the values for private link service connection status. +type PrivateLinkServiceConnectionStatus string + +const ( + // PrivateLinkServiceConnectionStatusApproved ... + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + // PrivateLinkServiceConnectionStatusDisconnected ... + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + // PrivateLinkServiceConnectionStatusPending ... + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + // PrivateLinkServiceConnectionStatusRejected ... + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{PrivateLinkServiceConnectionStatusApproved, PrivateLinkServiceConnectionStatusDisconnected, PrivateLinkServiceConnectionStatusPending, PrivateLinkServiceConnectionStatusRejected} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating ... + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting ... + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateMoving ... + ProvisioningStateMoving ProvisioningState = "Moving" + // ProvisioningStateRunning ... + ProvisioningStateRunning ProvisioningState = "Running" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUnknown ... + ProvisioningStateUnknown ProvisioningState = "Unknown" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCanceled, ProvisioningStateCreating, ProvisioningStateDeleting, ProvisioningStateFailed, ProvisioningStateMoving, ProvisioningStateRunning, ProvisioningStateSucceeded, ProvisioningStateUnknown, ProvisioningStateUpdating} +} + +// RequestType enumerates the values for request type. +type RequestType string + +const ( + // RequestTypeClientConnection ... + RequestTypeClientConnection RequestType = "ClientConnection" + // RequestTypeRESTAPI ... + RequestTypeRESTAPI RequestType = "RESTAPI" + // RequestTypeServerConnection ... + RequestTypeServerConnection RequestType = "ServerConnection" + // RequestTypeTrace ... + RequestTypeTrace RequestType = "Trace" +) + +// PossibleRequestTypeValues returns an array of possible values for the RequestType const type. +func PossibleRequestTypeValues() []RequestType { + return []RequestType{RequestTypeClientConnection, RequestTypeRESTAPI, RequestTypeServerConnection, RequestTypeTrace} +} + +// SharedPrivateLinkResourceStatus enumerates the values for shared private link resource status. +type SharedPrivateLinkResourceStatus string + +const ( + // SharedPrivateLinkResourceStatusApproved ... + SharedPrivateLinkResourceStatusApproved SharedPrivateLinkResourceStatus = "Approved" + // SharedPrivateLinkResourceStatusDisconnected ... + SharedPrivateLinkResourceStatusDisconnected SharedPrivateLinkResourceStatus = "Disconnected" + // SharedPrivateLinkResourceStatusPending ... + SharedPrivateLinkResourceStatusPending SharedPrivateLinkResourceStatus = "Pending" + // SharedPrivateLinkResourceStatusRejected ... + SharedPrivateLinkResourceStatusRejected SharedPrivateLinkResourceStatus = "Rejected" + // SharedPrivateLinkResourceStatusTimeout ... + SharedPrivateLinkResourceStatusTimeout SharedPrivateLinkResourceStatus = "Timeout" +) + +// PossibleSharedPrivateLinkResourceStatusValues returns an array of possible values for the SharedPrivateLinkResourceStatus const type. +func PossibleSharedPrivateLinkResourceStatusValues() []SharedPrivateLinkResourceStatus { + return []SharedPrivateLinkResourceStatus{SharedPrivateLinkResourceStatusApproved, SharedPrivateLinkResourceStatusDisconnected, SharedPrivateLinkResourceStatusPending, SharedPrivateLinkResourceStatusRejected, SharedPrivateLinkResourceStatusTimeout} +} + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // SkuTierBasic ... + SkuTierBasic SkuTier = "Basic" + // SkuTierFree ... + SkuTierFree SkuTier = "Free" + // SkuTierPremium ... + SkuTierPremium SkuTier = "Premium" + // SkuTierStandard ... + SkuTierStandard SkuTier = "Standard" +) + +// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. +func PossibleSkuTierValues() []SkuTier { + return []SkuTier{SkuTierBasic, SkuTierFree, SkuTierPremium, SkuTierStandard} +} + +// UpstreamAuthType enumerates the values for upstream auth type. +type UpstreamAuthType string + +const ( + // UpstreamAuthTypeManagedIdentity ... + UpstreamAuthTypeManagedIdentity UpstreamAuthType = "ManagedIdentity" + // UpstreamAuthTypeNone ... + UpstreamAuthTypeNone UpstreamAuthType = "None" +) + +// PossibleUpstreamAuthTypeValues returns an array of possible values for the UpstreamAuthType const type. +func PossibleUpstreamAuthTypeValues() []UpstreamAuthType { + return []UpstreamAuthType{UpstreamAuthTypeManagedIdentity, UpstreamAuthTypeNone} +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/models.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/models.go new file mode 100644 index 000000000000..48809fc0b6b6 --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/models.go @@ -0,0 +1,2283 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub" + +// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (ResourceType, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CreateOrUpdateFuture.Result. +func (future *CreateOrUpdateFuture) result(client Client) (rt ResourceType, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + rt.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("webpubsub.CreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rt.Response.Response, err = future.GetResult(sender); err == nil && rt.Response.Response.StatusCode != http.StatusNoContent { + rt, err = client.CreateOrUpdateResponder(rt.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.CreateOrUpdateFuture", "Result", rt.Response.Response, "Failure responding to request") + } + } + return +} + +// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DeleteFuture.Result. +func (future *DeleteFuture) result(client Client) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.DeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("webpubsub.DeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DiagnosticConfiguration diagnostic configuration of a Microsoft.SignalRService resource. Used together +// with Azure monitor DiagnosticSettings. +type DiagnosticConfiguration struct { + // EnableConnectivityLogs - Indicate whether or not enable Connectivity logs. + // Available values: Enabled, Disabled. + // Case insensitive. + EnableConnectivityLogs *string `json:"enableConnectivityLogs,omitempty"` + // EnableMessagingLogs - Indicate whether or not enable Messaging logs. + // Available values: Enabled, Disabled. + // Case insensitive. + EnableMessagingLogs *string `json:"enableMessagingLogs,omitempty"` + // EnableLiveTrace - Indicate whether or not enable Live Trace. + // Available values: Enabled, Disabled. + // Case insensitive. + // Live Trace allows you to know what's happening inside Azure SignalR service, it will give you live traces in real time, it will be helpful when you developing your own Azure SignalR based web application or self-troubleshooting some issues. + EnableLiveTrace *string `json:"enableLiveTrace,omitempty"` +} + +// Dimension specifications of the Dimension of metrics. +type Dimension struct { + // Name - The public facing name of the dimension. + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the dimension. + DisplayName *string `json:"displayName,omitempty"` + // InternalName - Name of the dimension as it appears in MDM. + InternalName *string `json:"internalName,omitempty"` + // ToBeExportedForShoebox - A Boolean flag indicating whether this dimension should be included for the shoebox export scenario. + ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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 { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// EventHandlerSettings the settings for event handler in webpubsub service +type EventHandlerSettings struct { + // Items - Get or set the EventHandler items. The key is the hub name and the value is the corresponding EventHandlerTemplate. + Items map[string][]EventHandlerTemplate `json:"items"` +} + +// MarshalJSON is the custom marshaler for EventHandlerSettings. +func (ehs EventHandlerSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ehs.Items != nil { + objectMap["items"] = ehs.Items + } + return json.Marshal(objectMap) +} + +// EventHandlerTemplate eventHandler template item settings. +type EventHandlerTemplate struct { + // URLTemplate - Gets or sets the EventHandler URL template. You can use a predefined parameter {hub} and {event} inside the template, the value of the EventHandler URL is dynamically calculated when the client request comes in. + // For example, UrlTemplate can be `http://example.com/api/{hub}/{event}`. The host part can't contains parameters. + URLTemplate *string `json:"urlTemplate,omitempty"` + // UserEventPattern - Gets or sets the matching pattern for event names. + // There are 3 kind of patterns supported: + // 1. "*", it to matches any event name + // 2. Combine multiple events with ",", for example "event1,event2", it matches event "event1" and "event2" + // 3. The single event name, for example, "event1", it matches "event1" + UserEventPattern *string `json:"userEventPattern,omitempty"` + // SystemEventPattern - Gets ot sets the system event pattern. + // There are 2 kind of patterns supported: + // 1. The single event name, for example, "connect", it matches "connect" + // 2. Combine multiple events with ",", for example "connect,disconnected", it matches event "connect" and "disconnected" + SystemEventPattern *string `json:"systemEventPattern,omitempty"` + // Auth - Gets or sets the auth settings for an event handler. If not set, no auth is used. + Auth *UpstreamAuthSettings `json:"auth,omitempty"` +} + +// Keys a class represents the access keys of the resource. +type Keys struct { + autorest.Response `json:"-"` + // PrimaryKey - The primary access key. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - The secondary access key. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // PrimaryConnectionString - Connection string constructed via the primaryKey + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + // SecondaryConnectionString - Connection string constructed via the secondaryKey + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` +} + +// LogSpecification specifications of the Logs for Azure Monitoring. +type LogSpecification struct { + // Name - Name of the log. + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the log. + DisplayName *string `json:"displayName,omitempty"` +} + +// ManagedIdentity a class represent managed identities used for request and response +type ManagedIdentity struct { + // Type - Represent the identity type: systemAssigned, userAssigned, None. Possible values include: 'ManagedIdentityTypeNone', 'ManagedIdentityTypeSystemAssigned', 'ManagedIdentityTypeUserAssigned' + Type ManagedIdentityType `json:"type,omitempty"` + // UserAssignedIdentities - Get or set the user assigned identities + UserAssignedIdentities map[string]*UserAssignedIdentityProperty `json:"userAssignedIdentities"` + // PrincipalID - READ-ONLY; Get the principal id for the system assigned identity. + // Only be used in response. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; Get the tenant id for the system assigned identity. + // Only be used in response + TenantID *string `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedIdentity. +func (mi ManagedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mi.Type != "" { + objectMap["type"] = mi.Type + } + if mi.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = mi.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// ManagedIdentitySettings managed identity settings for upstream. +type ManagedIdentitySettings struct { + // Resource - The Resource indicating the App ID URI of the target resource. + // It also appears in the aud (audience) claim of the issued token. + Resource *string `json:"resource,omitempty"` +} + +// MetricSpecification specifications of the Metrics for Azure Monitoring. +type MetricSpecification struct { + // Name - Name of the metric. + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // DisplayDescription - Localized friendly description of the metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + // Unit - The unit that makes sense for the metric. + Unit *string `json:"unit,omitempty"` + // AggregationType - Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count. + AggregationType *string `json:"aggregationType,omitempty"` + // FillGapWithZero - Optional. If set to true, then zero will be returned for time duration where no metric is emitted/published. + // Ex. a metric that returns the number of times a particular error code was emitted. The error code may not appear + // often, instead of the RP publishing 0, Shoebox can auto fill in 0s for time periods where nothing was emitted. + FillGapWithZero *string `json:"fillGapWithZero,omitempty"` + // Category - The name of the metric category that the metric belongs to. A metric can only belong to a single category. + Category *string `json:"category,omitempty"` + // Dimensions - The dimensions of the metrics. + Dimensions *[]Dimension `json:"dimensions,omitempty"` +} + +// NameAvailability result of the request to check name availability. It contains a flag and possible +// reason of failure. +type NameAvailability struct { + autorest.Response `json:"-"` + // NameAvailable - Indicates whether the name is available or not. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - The reason of the availability. Required if name is not available. + Reason *string `json:"reason,omitempty"` + // Message - The message of the operation. + Message *string `json:"message,omitempty"` +} + +// NameAvailabilityParameters data POST-ed to the nameAvailability action +type NameAvailabilityParameters struct { + // Type - The resource type. Can be "Microsoft.SignalRService/SignalR" or "Microsoft.SignalRService/webPubSub" + Type *string `json:"type,omitempty"` + // Name - The resource name to validate. e.g."my-resource-name" + Name *string `json:"name,omitempty"` +} + +// NetworkACL network ACL +type NetworkACL struct { + // Allow - Allowed request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Allow *[]RequestType `json:"allow,omitempty"` + // Deny - Denied request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Deny *[]RequestType `json:"deny,omitempty"` +} + +// NetworkACLs network ACLs for the resource +type NetworkACLs struct { + // DefaultAction - Default action when no other rule matches. Possible values include: 'ACLActionAllow', 'ACLActionDeny' + DefaultAction ACLAction `json:"defaultAction,omitempty"` + // PublicNetwork - ACL for requests from public network + PublicNetwork *NetworkACL `json:"publicNetwork,omitempty"` + // PrivateEndpoints - ACLs for requests from private endpoints + PrivateEndpoints *[]PrivateEndpointACL `json:"privateEndpoints,omitempty"` +} + +// Operation REST API operation supported by resource provider. +type Operation struct { + // Name - Name of the operation with format: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // IsDataAction - If the operation is a data action. (for data plane rbac) + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - The object that describes the operation. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - Optional. The intended executor of the operation; governs the display of the operation in the RBAC UX and the audit logs UX. + Origin *string `json:"origin,omitempty"` + // Properties - Extra properties for the operation. + Properties *OperationProperties `json:"properties,omitempty"` +} + +// OperationDisplay the object that describes a operation. +type OperationDisplay struct { + // Provider - Friendly name of the resource provider + Provider *string `json:"provider,omitempty"` + // Resource - Resource type on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - The localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - The localized friendly description for the operation + Description *string `json:"description,omitempty"` +} + +// OperationList result of the request to list REST API operations. It contains a list of operations. +type OperationList struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - The URL the client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListIterator) Response() OperationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{ + fn: getNextPage, + ol: cur, + } +} + +// OperationProperties extra Operation properties. +type OperationProperties struct { + // ServiceSpecification - The service specifications. + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// PrivateEndpoint private endpoint +type PrivateEndpoint struct { + // ID - Full qualified Id of the private endpoint + ID *string `json:"id,omitempty"` +} + +// PrivateEndpointACL ACL for a private endpoint +type PrivateEndpointACL struct { + // Name - Name of the private endpoint connection + Name *string `json:"name,omitempty"` + // Allow - Allowed request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Allow *[]RequestType `json:"allow,omitempty"` + // Deny - Denied request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Deny *[]RequestType `json:"deny,omitempty"` +} + +// PrivateEndpointConnection a private endpoint connection to an azure resource +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // PrivateEndpointConnectionProperties - Properties of the private endpoint connection + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + pec.SystemData = &systemData + } + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionList a list of private endpoint connections +type PrivateEndpointConnectionList struct { + autorest.Response `json:"-"` + // Value - The list of the private endpoint connections + Value *[]PrivateEndpointConnection `json:"value,omitempty"` + // NextLink - Request URL that can be used to query next page of private endpoint connections. Returned when the total number of requested private endpoint connections exceed maximum page size. + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateEndpointConnectionListIterator provides access to a complete listing of PrivateEndpointConnection +// values. +type PrivateEndpointConnectionListIterator struct { + i int + page PrivateEndpointConnectionListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateEndpointConnectionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateEndpointConnectionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateEndpointConnectionListIterator) Response() PrivateEndpointConnectionList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateEndpointConnectionListIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListIterator type. +func NewPrivateEndpointConnectionListIterator(page PrivateEndpointConnectionListPage) PrivateEndpointConnectionListIterator { + return PrivateEndpointConnectionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pecl PrivateEndpointConnectionList) IsEmpty() bool { + return pecl.Value == nil || len(*pecl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pecl PrivateEndpointConnectionList) hasNextLink() bool { + return pecl.NextLink != nil && len(*pecl.NextLink) != 0 +} + +// privateEndpointConnectionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pecl PrivateEndpointConnectionList) privateEndpointConnectionListPreparer(ctx context.Context) (*http.Request, error) { + if !pecl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pecl.NextLink))) +} + +// PrivateEndpointConnectionListPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListPage struct { + fn func(context.Context, PrivateEndpointConnectionList) (PrivateEndpointConnectionList, error) + pecl PrivateEndpointConnectionList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateEndpointConnectionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.pecl) + if err != nil { + return err + } + page.pecl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateEndpointConnectionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListPage) NotDone() bool { + return !page.pecl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListPage) Response() PrivateEndpointConnectionList { + return page.pecl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListPage) Values() []PrivateEndpointConnection { + if page.pecl.IsEmpty() { + return nil + } + return *page.pecl.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListPage type. +func NewPrivateEndpointConnectionListPage(cur PrivateEndpointConnectionList, getNextPage func(context.Context, PrivateEndpointConnectionList) (PrivateEndpointConnectionList, error)) PrivateEndpointConnectionListPage { + return PrivateEndpointConnectionListPage{ + fn: getNextPage, + pecl: cur, + } +} + +// PrivateEndpointConnectionProperties private endpoint connection properties +type PrivateEndpointConnectionProperties struct { + // ProvisioningState - READ-ONLY; Provisioning state of the private endpoint connection. Possible values include: 'ProvisioningStateUnknown', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateRunning', 'ProvisioningStateCreating', 'ProvisioningStateUpdating', 'ProvisioningStateDeleting', 'ProvisioningStateMoving' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // PrivateEndpoint - Private endpoint associated with the private endpoint connection + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection state + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pecp.PrivateEndpoint + } + if pecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("webpubsub.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkResource private link resource +type PrivateLinkResource struct { + // PrivateLinkResourceProperties - Properties of a private link resource + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceList contains a list of PrivateLinkResource and a possible link to query more results +type PrivateLinkResourceList struct { + autorest.Response `json:"-"` + // Value - List of PrivateLinkResource + Value *[]PrivateLinkResource `json:"value,omitempty"` + // NextLink - The URL the client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateLinkResourceListIterator provides access to a complete listing of PrivateLinkResource values. +type PrivateLinkResourceListIterator struct { + i int + page PrivateLinkResourceListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkResourceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkResourceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkResourceListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkResourceListIterator) Response() PrivateLinkResourceList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkResourceListIterator) Value() PrivateLinkResource { + if !iter.page.NotDone() { + return PrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkResourceListIterator type. +func NewPrivateLinkResourceListIterator(page PrivateLinkResourceListPage) PrivateLinkResourceListIterator { + return PrivateLinkResourceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plrl PrivateLinkResourceList) IsEmpty() bool { + return plrl.Value == nil || len(*plrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plrl PrivateLinkResourceList) hasNextLink() bool { + return plrl.NextLink != nil && len(*plrl.NextLink) != 0 +} + +// privateLinkResourceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plrl PrivateLinkResourceList) privateLinkResourceListPreparer(ctx context.Context) (*http.Request, error) { + if !plrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plrl.NextLink))) +} + +// PrivateLinkResourceListPage contains a page of PrivateLinkResource values. +type PrivateLinkResourceListPage struct { + fn func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error) + plrl PrivateLinkResourceList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkResourceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plrl) + if err != nil { + return err + } + page.plrl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkResourceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkResourceListPage) NotDone() bool { + return !page.plrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkResourceListPage) Response() PrivateLinkResourceList { + return page.plrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkResourceListPage) Values() []PrivateLinkResource { + if page.plrl.IsEmpty() { + return nil + } + return *page.plrl.Value +} + +// Creates a new instance of the PrivateLinkResourceListPage type. +func NewPrivateLinkResourceListPage(cur PrivateLinkResourceList, getNextPage func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error)) PrivateLinkResourceListPage { + return PrivateLinkResourceListPage{ + fn: getNextPage, + plrl: cur, + } +} + +// PrivateLinkResourceProperties private link resource properties +type PrivateLinkResourceProperties struct { + // GroupID - Group Id of the private link resource + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - Required members of the private link resource + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - Required private DNS zone names + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` + // ShareablePrivateLinkResourceTypes - The list of resources that are onboarded to private link service + ShareablePrivateLinkResourceTypes *[]ShareablePrivateLinkResourceType `json:"shareablePrivateLinkResourceTypes,omitempty"` +} + +// PrivateLinkServiceConnectionState connection state of the private endpoint connection +type PrivateLinkServiceConnectionState struct { + // Status - Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. Possible values include: 'PrivateLinkServiceConnectionStatusPending', 'PrivateLinkServiceConnectionStatusApproved', 'PrivateLinkServiceConnectionStatusRejected', 'PrivateLinkServiceConnectionStatusDisconnected' + Status PrivateLinkServiceConnectionStatus `json:"status,omitempty"` + // Description - The reason for approval/rejection of the connection. + Description *string `json:"description,omitempty"` + // ActionsRequired - A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// Properties a class that describes the properties of the resource +type Properties struct { + // ProvisioningState - READ-ONLY; Provisioning state of the resource. Possible values include: 'ProvisioningStateUnknown', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateRunning', 'ProvisioningStateCreating', 'ProvisioningStateUpdating', 'ProvisioningStateDeleting', 'ProvisioningStateMoving' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ExternalIP - READ-ONLY; The publicly accessible IP of the resource. + ExternalIP *string `json:"externalIP,omitempty"` + // HostName - READ-ONLY; FQDN of the service instance. + HostName *string `json:"hostName,omitempty"` + // PublicPort - READ-ONLY; The publicly accessible port of the resource which is designed for browser/client side usage. + PublicPort *int32 `json:"publicPort,omitempty"` + // ServerPort - READ-ONLY; The publicly accessible port of the resource which is designed for customer server side usage. + ServerPort *int32 `json:"serverPort,omitempty"` + // Version - READ-ONLY; Version of the resource. Probably you need the same or higher version of client SDKs. + Version *string `json:"version,omitempty"` + // PrivateEndpointConnections - READ-ONLY; Private endpoint connections to the resource. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // SharedPrivateLinkResources - READ-ONLY; The list of shared private link resources. + SharedPrivateLinkResources *[]SharedPrivateLinkResource `json:"sharedPrivateLinkResources,omitempty"` + // TLS - TLS settings. + TLS *TLSSettings `json:"tls,omitempty"` + // DiagnosticConfiguration - Diagnostic configuration of a Microsoft.SignalRService resource. Used together with Azure monitor DiagnosticSettings. + DiagnosticConfiguration *DiagnosticConfiguration `json:"diagnosticConfiguration,omitempty"` + // EventHandler - The settings for event handler in webpubsub service. + EventHandler *EventHandlerSettings `json:"eventHandler,omitempty"` + // NetworkACLs - Network ACLs + NetworkACLs *NetworkACLs `json:"networkACLs,omitempty"` + // PublicNetworkAccess - Enable or disable public network access. Default to "Enabled". + // When it's Enabled, network ACLs still apply. + // When it's Disabled, public network access is always disabled no matter what you set in network ACLs. + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + // DisableLocalAuth - DisableLocalAuth + // Enable or disable local auth with AccessKey + // When set as true, connection with AccessKey=xxx won't work. + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + // DisableAadAuth - DisableLocalAuth + // Enable or disable aad auth + // When set as true, connection with AuthType=aad won't work. + DisableAadAuth *bool `json:"disableAadAuth,omitempty"` +} + +// MarshalJSON is the custom marshaler for Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.TLS != nil { + objectMap["tls"] = p.TLS + } + if p.DiagnosticConfiguration != nil { + objectMap["diagnosticConfiguration"] = p.DiagnosticConfiguration + } + if p.EventHandler != nil { + objectMap["eventHandler"] = p.EventHandler + } + if p.NetworkACLs != nil { + objectMap["networkACLs"] = p.NetworkACLs + } + if p.PublicNetworkAccess != nil { + objectMap["publicNetworkAccess"] = p.PublicNetworkAccess + } + if p.DisableLocalAuth != nil { + objectMap["disableLocalAuth"] = p.DisableLocalAuth + } + if p.DisableAadAuth != nil { + objectMap["disableAadAuth"] = p.DisableAadAuth + } + return json.Marshal(objectMap) +} + +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RegenerateKeyFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type RegenerateKeyFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (Keys, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *RegenerateKeyFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for RegenerateKeyFuture.Result. +func (future *RegenerateKeyFuture) result(client Client) (kVar Keys, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.RegenerateKeyFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + kVar.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("webpubsub.RegenerateKeyFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if kVar.Response.Response, err = future.GetResult(sender); err == nil && kVar.Response.Response.StatusCode != http.StatusNoContent { + kVar, err = client.RegenerateKeyResponder(kVar.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.RegenerateKeyFuture", "Result", kVar.Response.Response, "Failure responding to request") + } + } + return +} + +// RegenerateKeyParameters parameters describes the request to regenerate access keys +type RegenerateKeyParameters struct { + // KeyType - The keyType to regenerate. Must be either 'primary' or 'secondary'(case-insensitive). Possible values include: 'KeyTypePrimary', 'KeyTypeSecondary' + KeyType KeyType `json:"keyType,omitempty"` +} + +// Resource the core properties of ARM resources. +type Resource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceList object that includes an array of resources and a possible link for next set. +type ResourceList struct { + autorest.Response `json:"-"` + // Value - List of the resources + Value *[]ResourceType `json:"value,omitempty"` + // NextLink - The URL the client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// ResourceListIterator provides access to a complete listing of ResourceType values. +type ResourceListIterator struct { + i int + page ResourceListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ResourceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ResourceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ResourceListIterator) Response() ResourceList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ResourceListIterator) Value() ResourceType { + if !iter.page.NotDone() { + return ResourceType{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ResourceListIterator type. +func NewResourceListIterator(page ResourceListPage) ResourceListIterator { + return ResourceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rl ResourceList) IsEmpty() bool { + return rl.Value == nil || len(*rl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rl ResourceList) hasNextLink() bool { + return rl.NextLink != nil && len(*rl.NextLink) != 0 +} + +// resourceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rl ResourceList) resourceListPreparer(ctx context.Context) (*http.Request, error) { + if !rl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rl.NextLink))) +} + +// ResourceListPage contains a page of ResourceType values. +type ResourceListPage struct { + fn func(context.Context, ResourceList) (ResourceList, error) + rl ResourceList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ResourceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rl) + if err != nil { + return err + } + page.rl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ResourceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceListPage) NotDone() bool { + return !page.rl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceListPage) Response() ResourceList { + return page.rl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceListPage) Values() []ResourceType { + if page.rl.IsEmpty() { + return nil + } + return *page.rl.Value +} + +// Creates a new instance of the ResourceListPage type. +func NewResourceListPage(cur ResourceList, getNextPage func(context.Context, ResourceList) (ResourceList, error)) ResourceListPage { + return ResourceListPage{ + fn: getNextPage, + rl: cur, + } +} + +// ResourceSku the billing information of the resource. +type ResourceSku struct { + // Name - The name of the SKU. Required. + // + // Allowed values: Standard_S1, Free_F1 + Name *string `json:"name,omitempty"` + // Tier - Optional tier of this particular SKU. 'Standard' or 'Free'. + // + // `Basic` is deprecated, use `Standard` instead. Possible values include: 'SkuTierFree', 'SkuTierBasic', 'SkuTierStandard', 'SkuTierPremium' + Tier SkuTier `json:"tier,omitempty"` + // Size - READ-ONLY; Not used. Retained for future use. + Size *string `json:"size,omitempty"` + // Family - READ-ONLY; Not used. Retained for future use. + Family *string `json:"family,omitempty"` + // Capacity - Optional, integer. The unit count of the resource. 1 by default. + // + // If present, following values are allowed: + // Free: 1 + // Standard: 1,2,5,10,20,50,100 + Capacity *int32 `json:"capacity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceSku. +func (rs ResourceSku) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rs.Name != nil { + objectMap["name"] = rs.Name + } + if rs.Tier != "" { + objectMap["tier"] = rs.Tier + } + if rs.Capacity != nil { + objectMap["capacity"] = rs.Capacity + } + return json.Marshal(objectMap) +} + +// ResourceType a class represent a resource. +type ResourceType struct { + autorest.Response `json:"-"` + // Sku - The billing information of the resource.(e.g. Free, Standard) + Sku *ResourceSku `json:"sku,omitempty"` + // Properties - Settings used to provision or configure the resource + *Properties `json:"properties,omitempty"` + // Identity - The managed identity response + Identity *ManagedIdentity `json:"identity,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // Location - The GEO location of the resource. e.g. West US | East US | North Central US | South Central US. + Location *string `json:"location,omitempty"` + // Tags - Tags of the service which is a list of key value pairs that describe the resource. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceType. +func (rt ResourceType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rt.Sku != nil { + objectMap["sku"] = rt.Sku + } + if rt.Properties != nil { + objectMap["properties"] = rt.Properties + } + if rt.Identity != nil { + objectMap["identity"] = rt.Identity + } + if rt.Location != nil { + objectMap["location"] = rt.Location + } + if rt.Tags != nil { + objectMap["tags"] = rt.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ResourceType struct. +func (rt *ResourceType) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku ResourceSku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + rt.Sku = &sku + } + case "properties": + if v != nil { + var properties Properties + err = json.Unmarshal(*v, &properties) + if err != nil { + return err + } + rt.Properties = &properties + } + case "identity": + if v != nil { + var identity ManagedIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + rt.Identity = &identity + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + rt.SystemData = &systemData + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rt.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rt.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rt.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rt.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rt.Type = &typeVar + } + } + } + + return nil +} + +// RestartFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type RestartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *RestartFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for RestartFuture.Result. +func (future *RestartFuture) result(client Client) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.RestartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("webpubsub.RestartFuture") + return + } + ar.Response = future.Response() + return +} + +// ServiceSpecification an object that describes a specification. +type ServiceSpecification struct { + // MetricSpecifications - Specifications of the Metrics for Azure Monitoring. + MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` + // LogSpecifications - Specifications of the Logs for Azure Monitoring. + LogSpecifications *[]LogSpecification `json:"logSpecifications,omitempty"` +} + +// ShareablePrivateLinkResourceProperties describes the properties of a resource type that has been +// onboarded to private link service +type ShareablePrivateLinkResourceProperties struct { + // Description - The description of the resource type that has been onboarded to private link service + Description *string `json:"description,omitempty"` + // GroupID - The resource provider group id for the resource that has been onboarded to private link service + GroupID *string `json:"groupId,omitempty"` + // Type - The resource provider type for the resource that has been onboarded to private link service + Type *string `json:"type,omitempty"` +} + +// ShareablePrivateLinkResourceType describes a resource type that has been onboarded to private link +// service +type ShareablePrivateLinkResourceType struct { + // Name - The name of the resource type that has been onboarded to private link service + Name *string `json:"name,omitempty"` + // Properties - Describes the properties of a resource type that has been onboarded to private link service + Properties *ShareablePrivateLinkResourceProperties `json:"properties,omitempty"` +} + +// SharedPrivateLinkResource describes a Shared Private Link Resource +type SharedPrivateLinkResource struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // SharedPrivateLinkResourceProperties - Describes the properties of a Shared Private Link Resource + *SharedPrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SharedPrivateLinkResource. +func (splr SharedPrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if splr.SharedPrivateLinkResourceProperties != nil { + objectMap["properties"] = splr.SharedPrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SharedPrivateLinkResource struct. +func (splr *SharedPrivateLinkResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + splr.SystemData = &systemData + } + case "properties": + if v != nil { + var sharedPrivateLinkResourceProperties SharedPrivateLinkResourceProperties + err = json.Unmarshal(*v, &sharedPrivateLinkResourceProperties) + if err != nil { + return err + } + splr.SharedPrivateLinkResourceProperties = &sharedPrivateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + splr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + splr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + splr.Type = &typeVar + } + } + } + + return nil +} + +// SharedPrivateLinkResourceList a list of shared private link resources +type SharedPrivateLinkResourceList struct { + autorest.Response `json:"-"` + // Value - The list of the shared private link resources + Value *[]SharedPrivateLinkResource `json:"value,omitempty"` + // NextLink - Request URL that can be used to query next page of private endpoint connections. Returned when the total number of requested private endpoint connections exceed maximum page size. + NextLink *string `json:"nextLink,omitempty"` +} + +// SharedPrivateLinkResourceListIterator provides access to a complete listing of SharedPrivateLinkResource +// values. +type SharedPrivateLinkResourceListIterator struct { + i int + page SharedPrivateLinkResourceListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SharedPrivateLinkResourceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourceListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SharedPrivateLinkResourceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SharedPrivateLinkResourceListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SharedPrivateLinkResourceListIterator) Response() SharedPrivateLinkResourceList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SharedPrivateLinkResourceListIterator) Value() SharedPrivateLinkResource { + if !iter.page.NotDone() { + return SharedPrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SharedPrivateLinkResourceListIterator type. +func NewSharedPrivateLinkResourceListIterator(page SharedPrivateLinkResourceListPage) SharedPrivateLinkResourceListIterator { + return SharedPrivateLinkResourceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (splrl SharedPrivateLinkResourceList) IsEmpty() bool { + return splrl.Value == nil || len(*splrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (splrl SharedPrivateLinkResourceList) hasNextLink() bool { + return splrl.NextLink != nil && len(*splrl.NextLink) != 0 +} + +// sharedPrivateLinkResourceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (splrl SharedPrivateLinkResourceList) sharedPrivateLinkResourceListPreparer(ctx context.Context) (*http.Request, error) { + if !splrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(splrl.NextLink))) +} + +// SharedPrivateLinkResourceListPage contains a page of SharedPrivateLinkResource values. +type SharedPrivateLinkResourceListPage struct { + fn func(context.Context, SharedPrivateLinkResourceList) (SharedPrivateLinkResourceList, error) + splrl SharedPrivateLinkResourceList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SharedPrivateLinkResourceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourceListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.splrl) + if err != nil { + return err + } + page.splrl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SharedPrivateLinkResourceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SharedPrivateLinkResourceListPage) NotDone() bool { + return !page.splrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SharedPrivateLinkResourceListPage) Response() SharedPrivateLinkResourceList { + return page.splrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SharedPrivateLinkResourceListPage) Values() []SharedPrivateLinkResource { + if page.splrl.IsEmpty() { + return nil + } + return *page.splrl.Value +} + +// Creates a new instance of the SharedPrivateLinkResourceListPage type. +func NewSharedPrivateLinkResourceListPage(cur SharedPrivateLinkResourceList, getNextPage func(context.Context, SharedPrivateLinkResourceList) (SharedPrivateLinkResourceList, error)) SharedPrivateLinkResourceListPage { + return SharedPrivateLinkResourceListPage{ + fn: getNextPage, + splrl: cur, + } +} + +// SharedPrivateLinkResourceProperties describes the properties of an existing Shared Private Link Resource +type SharedPrivateLinkResourceProperties struct { + // GroupID - The group id from the provider of resource the shared private link resource is for + GroupID *string `json:"groupId,omitempty"` + // PrivateLinkResourceID - The resource id of the resource the shared private link resource is for + PrivateLinkResourceID *string `json:"privateLinkResourceId,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the shared private link resource. Possible values include: 'ProvisioningStateUnknown', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateRunning', 'ProvisioningStateCreating', 'ProvisioningStateUpdating', 'ProvisioningStateDeleting', 'ProvisioningStateMoving' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // RequestMessage - The request message for requesting approval of the shared private link resource + RequestMessage *string `json:"requestMessage,omitempty"` + // Status - READ-ONLY; Status of the shared private link resource. Possible values include: 'SharedPrivateLinkResourceStatusPending', 'SharedPrivateLinkResourceStatusApproved', 'SharedPrivateLinkResourceStatusRejected', 'SharedPrivateLinkResourceStatusDisconnected', 'SharedPrivateLinkResourceStatusTimeout' + Status SharedPrivateLinkResourceStatus `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for SharedPrivateLinkResourceProperties. +func (splrp SharedPrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if splrp.GroupID != nil { + objectMap["groupId"] = splrp.GroupID + } + if splrp.PrivateLinkResourceID != nil { + objectMap["privateLinkResourceId"] = splrp.PrivateLinkResourceID + } + if splrp.RequestMessage != nil { + objectMap["requestMessage"] = splrp.RequestMessage + } + return json.Marshal(objectMap) +} + +// SharedPrivateLinkResourcesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SharedPrivateLinkResourcesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SharedPrivateLinkResourcesClient) (SharedPrivateLinkResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SharedPrivateLinkResourcesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SharedPrivateLinkResourcesCreateOrUpdateFuture.Result. +func (future *SharedPrivateLinkResourcesCreateOrUpdateFuture) result(client SharedPrivateLinkResourcesClient) (splr SharedPrivateLinkResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + splr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("webpubsub.SharedPrivateLinkResourcesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if splr.Response.Response, err = future.GetResult(sender); err == nil && splr.Response.Response.StatusCode != http.StatusNoContent { + splr, err = client.CreateOrUpdateResponder(splr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesCreateOrUpdateFuture", "Result", splr.Response.Response, "Failure responding to request") + } + } + return +} + +// SharedPrivateLinkResourcesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SharedPrivateLinkResourcesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SharedPrivateLinkResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SharedPrivateLinkResourcesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SharedPrivateLinkResourcesDeleteFuture.Result. +func (future *SharedPrivateLinkResourcesDeleteFuture) result(client SharedPrivateLinkResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("webpubsub.SharedPrivateLinkResourcesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SignalRServiceUsage object that describes a specific usage of the resources. +type SignalRServiceUsage struct { + // ID - Fully qualified ARM resource id + ID *string `json:"id,omitempty"` + // CurrentValue - Current value for the usage quota. + CurrentValue *int64 `json:"currentValue,omitempty"` + // Limit - The maximum permitted value for the usage quota. If there is no limit, this value will be -1. + Limit *int64 `json:"limit,omitempty"` + // Name - Localizable String object containing the name and a localized value. + Name *SignalRServiceUsageName `json:"name,omitempty"` + // Unit - Representing the units of the usage quota. Possible values are: Count, Bytes, Seconds, Percent, CountPerSecond, BytesPerSecond. + Unit *string `json:"unit,omitempty"` +} + +// SignalRServiceUsageList object that includes an array of the resource usages and a possible link for +// next set. +type SignalRServiceUsageList struct { + autorest.Response `json:"-"` + // Value - List of the resource usages + Value *[]SignalRServiceUsage `json:"value,omitempty"` + // NextLink - The URL the client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// SignalRServiceUsageListIterator provides access to a complete listing of SignalRServiceUsage values. +type SignalRServiceUsageListIterator struct { + i int + page SignalRServiceUsageListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SignalRServiceUsageListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignalRServiceUsageListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SignalRServiceUsageListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SignalRServiceUsageListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SignalRServiceUsageListIterator) Response() SignalRServiceUsageList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SignalRServiceUsageListIterator) Value() SignalRServiceUsage { + if !iter.page.NotDone() { + return SignalRServiceUsage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SignalRServiceUsageListIterator type. +func NewSignalRServiceUsageListIterator(page SignalRServiceUsageListPage) SignalRServiceUsageListIterator { + return SignalRServiceUsageListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (srsul SignalRServiceUsageList) IsEmpty() bool { + return srsul.Value == nil || len(*srsul.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (srsul SignalRServiceUsageList) hasNextLink() bool { + return srsul.NextLink != nil && len(*srsul.NextLink) != 0 +} + +// signalRServiceUsageListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (srsul SignalRServiceUsageList) signalRServiceUsageListPreparer(ctx context.Context) (*http.Request, error) { + if !srsul.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(srsul.NextLink))) +} + +// SignalRServiceUsageListPage contains a page of SignalRServiceUsage values. +type SignalRServiceUsageListPage struct { + fn func(context.Context, SignalRServiceUsageList) (SignalRServiceUsageList, error) + srsul SignalRServiceUsageList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SignalRServiceUsageListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SignalRServiceUsageListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.srsul) + if err != nil { + return err + } + page.srsul = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SignalRServiceUsageListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SignalRServiceUsageListPage) NotDone() bool { + return !page.srsul.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SignalRServiceUsageListPage) Response() SignalRServiceUsageList { + return page.srsul +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SignalRServiceUsageListPage) Values() []SignalRServiceUsage { + if page.srsul.IsEmpty() { + return nil + } + return *page.srsul.Value +} + +// Creates a new instance of the SignalRServiceUsageListPage type. +func NewSignalRServiceUsageListPage(cur SignalRServiceUsageList, getNextPage func(context.Context, SignalRServiceUsageList) (SignalRServiceUsageList, error)) SignalRServiceUsageListPage { + return SignalRServiceUsageListPage{ + fn: getNextPage, + srsul: cur, + } +} + +// SignalRServiceUsageName localizable String object containing the name and a localized value. +type SignalRServiceUsageName struct { + // Value - The identifier of the usage. + Value *string `json:"value,omitempty"` + // LocalizedValue - Localized name of the usage. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TLSSettings TLS settings for the resource +type TLSSettings struct { + // ClientCertEnabled - Request client certificate during TLS handshake if enabled + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource. +type TrackedResource struct { + // Location - The GEO location of the resource. e.g. West US | East US | North Central US | South Central US. + Location *string `json:"location,omitempty"` + // Tags - Tags of the service which is a list of key value pairs that describe the resource. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type UpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (ResourceType, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *UpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for UpdateFuture.Result. +func (future *UpdateFuture) result(client Client) (rt ResourceType, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.UpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + rt.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("webpubsub.UpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rt.Response.Response, err = future.GetResult(sender); err == nil && rt.Response.Response.StatusCode != http.StatusNoContent { + rt, err = client.UpdateResponder(rt.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.UpdateFuture", "Result", rt.Response.Response, "Failure responding to request") + } + } + return +} + +// UpstreamAuthSettings upstream auth settings. +type UpstreamAuthSettings struct { + // Type - Gets or sets the type of auth. None or ManagedIdentity is supported now. Possible values include: 'UpstreamAuthTypeNone', 'UpstreamAuthTypeManagedIdentity' + Type UpstreamAuthType `json:"type,omitempty"` + // ManagedIdentity - Gets or sets the managed identity settings. It's required if the auth type is set to ManagedIdentity. + ManagedIdentity *ManagedIdentitySettings `json:"managedIdentity,omitempty"` +} + +// UserAssignedIdentityProperty properties of user assigned identity. +type UserAssignedIdentityProperty struct { + // PrincipalID - READ-ONLY; Get the principal id for the user assigned identity + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - READ-ONLY; Get the client id for the user assigned identity + ClientID *string `json:"clientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserAssignedIdentityProperty. +func (uaip UserAssignedIdentityProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/operations.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/operations.go new file mode 100644 index 000000000000..5fd2e53fd052 --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/operations.go @@ -0,0 +1,140 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the REST API for Azure WebPubSub Service +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations of the Microsoft.SignalRService provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.SignalRService/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "webpubsub.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "webpubsub.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/privateendpointconnections.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/privateendpointconnections.go new file mode 100644 index 000000000000..c5847db70112 --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/privateendpointconnections.go @@ -0,0 +1,393 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient is the REST API for Azure WebPubSub Service +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete the specified private endpoint connection +// Parameters: +// privateEndpointConnectionName - the name of the private endpoint connection +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, privateEndpointConnectionName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the specified private endpoint connection +// Parameters: +// privateEndpointConnectionName - the name of the private endpoint connection +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, privateEndpointConnectionName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list private endpoint connections +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") + defer func() { + sc := -1 + if result.pecl.Response.Response != nil { + sc = result.pecl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.pecl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "List", resp, "Failure sending request") + return + } + + result.pecl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "List", resp, "Failure responding to request") + return + } + if result.pecl.hasNextLink() && result.pecl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateEndpointConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result PrivateEndpointConnectionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsClient) listNextResults(ctx context.Context, lastResults PrivateEndpointConnectionList) (result PrivateEndpointConnectionList, err error) { + req, err := lastResults.privateEndpointConnectionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, resourceName) + return +} + +// Update update the state of specified private endpoint connection +// Parameters: +// privateEndpointConnectionName - the name of the private endpoint connection +// parameters - the resource of private endpoint and its properties +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateEndpointConnectionsClient) Update(ctx context.Context, privateEndpointConnectionName string, parameters PrivateEndpointConnection, resourceGroupName string, resourceName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, privateEndpointConnectionName, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateEndpointConnectionsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateEndpointConnectionsClient) UpdatePreparer(ctx context.Context, privateEndpointConnectionName string, parameters PrivateEndpointConnection, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) UpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/privatelinkresources.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/privatelinkresources.go new file mode 100644 index 000000000000..877d5c846b81 --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/privatelinkresources.go @@ -0,0 +1,151 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the REST API for Azure WebPubSub Service +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the private link resources that need to be created for a resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.plrl.Response.Response != nil { + sc = result.plrl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateLinkResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.PrivateLinkResourcesClient", "List", resp, "Failure sending request") + return + } + + result.plrl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateLinkResourcesClient", "List", resp, "Failure responding to request") + return + } + if result.plrl.hasNextLink() && result.plrl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListResponder(resp *http.Response) (result PrivateLinkResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkResourcesClient) listNextResults(ctx context.Context, lastResults PrivateLinkResourceList) (result PrivateLinkResourceList, err error) { + req, err := lastResults.privateLinkResourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "webpubsub.PrivateLinkResourcesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "webpubsub.PrivateLinkResourcesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.PrivateLinkResourcesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkResourcesClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/sharedprivatelinkresources.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/sharedprivatelinkresources.go new file mode 100644 index 000000000000..f9eca7f8abf3 --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/sharedprivatelinkresources.go @@ -0,0 +1,405 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SharedPrivateLinkResourcesClient is the REST API for Azure WebPubSub Service +type SharedPrivateLinkResourcesClient struct { + BaseClient +} + +// NewSharedPrivateLinkResourcesClient creates an instance of the SharedPrivateLinkResourcesClient client. +func NewSharedPrivateLinkResourcesClient(subscriptionID string) SharedPrivateLinkResourcesClient { + return NewSharedPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSharedPrivateLinkResourcesClientWithBaseURI creates an instance of the SharedPrivateLinkResourcesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewSharedPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) SharedPrivateLinkResourcesClient { + return SharedPrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a shared private link resource +// Parameters: +// sharedPrivateLinkResourceName - the name of the shared private link resource +// parameters - the shared private link resource +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdate(ctx context.Context, sharedPrivateLinkResourceName string, parameters SharedPrivateLinkResource, resourceGroupName string, resourceName string) (result SharedPrivateLinkResourcesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SharedPrivateLinkResourceProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.SharedPrivateLinkResourceProperties.GroupID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.SharedPrivateLinkResourceProperties.PrivateLinkResourceID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("webpubsub.SharedPrivateLinkResourcesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, sharedPrivateLinkResourceName, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdatePreparer(ctx context.Context, sharedPrivateLinkResourceName string, parameters SharedPrivateLinkResource, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "sharedPrivateLinkResourceName": autorest.Encode("path", sharedPrivateLinkResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdateSender(req *http.Request) (future SharedPrivateLinkResourcesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) CreateOrUpdateResponder(resp *http.Response) (result SharedPrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete the specified shared private link resource +// Parameters: +// sharedPrivateLinkResourceName - the name of the shared private link resource +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client SharedPrivateLinkResourcesClient) Delete(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (result SharedPrivateLinkResourcesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, sharedPrivateLinkResourceName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SharedPrivateLinkResourcesClient) DeletePreparer(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "sharedPrivateLinkResourceName": autorest.Encode("path", sharedPrivateLinkResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) DeleteSender(req *http.Request) (future SharedPrivateLinkResourcesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the specified shared private link resource +// Parameters: +// sharedPrivateLinkResourceName - the name of the shared private link resource +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client SharedPrivateLinkResourcesClient) Get(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (result SharedPrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, sharedPrivateLinkResourceName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SharedPrivateLinkResourcesClient) GetPreparer(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "sharedPrivateLinkResourceName": autorest.Encode("path", sharedPrivateLinkResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) GetResponder(resp *http.Response) (result SharedPrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list shared private link resources +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client SharedPrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result SharedPrivateLinkResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.splrl.Response.Response != nil { + sc = result.splrl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.splrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "List", resp, "Failure sending request") + return + } + + result.splrl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "List", resp, "Failure responding to request") + return + } + if result.splrl.hasNextLink() && result.splrl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client SharedPrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/sharedPrivateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SharedPrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SharedPrivateLinkResourcesClient) ListResponder(resp *http.Response) (result SharedPrivateLinkResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SharedPrivateLinkResourcesClient) listNextResults(ctx context.Context, lastResults SharedPrivateLinkResourceList) (result SharedPrivateLinkResourceList, err error) { + req, err := lastResults.sharedPrivateLinkResourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.SharedPrivateLinkResourcesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SharedPrivateLinkResourcesClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result SharedPrivateLinkResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedPrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, resourceName) + return +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/usages.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/usages.go new file mode 100644 index 000000000000..7d254cb5fbab --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/usages.go @@ -0,0 +1,147 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UsagesClient is the REST API for Azure WebPubSub Service +type UsagesClient struct { + BaseClient +} + +// NewUsagesClient creates an instance of the UsagesClient client. +func NewUsagesClient(subscriptionID string) UsagesClient { + return NewUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsagesClientWithBaseURI creates an instance of the UsagesClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesClient { + return UsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list resource usage quotas by location. +// Parameters: +// location - the location like "eastus" +func (client UsagesClient) List(ctx context.Context, location string) (result SignalRServiceUsageListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsagesClient.List") + defer func() { + sc := -1 + if result.srsul.Response.Response != nil { + sc = result.srsul.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.UsagesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.srsul.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.UsagesClient", "List", resp, "Failure sending request") + return + } + + result.srsul, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.UsagesClient", "List", resp, "Failure responding to request") + return + } + if result.srsul.hasNextLink() && result.srsul.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client UsagesClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client UsagesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UsagesClient) ListResponder(resp *http.Response) (result SignalRServiceUsageList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client UsagesClient) listNextResults(ctx context.Context, lastResults SignalRServiceUsageList) (result SignalRServiceUsageList, err error) { + req, err := lastResults.signalRServiceUsageListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "webpubsub.UsagesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "webpubsub.UsagesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.UsagesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client UsagesClient) ListComplete(ctx context.Context, location string) (result SignalRServiceUsageListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsagesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, location) + return +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/version.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/version.go new file mode 100644 index 000000000000..9dd43b2f3be3 --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/version.go @@ -0,0 +1,19 @@ +package webpubsub + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " webpubsub/2021-06-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/webpubsub.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/webpubsub.go new file mode 100644 index 000000000000..cc9bb729e779 --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/webpubsub.go @@ -0,0 +1,912 @@ +package webpubsub + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// Client is the REST API for Azure WebPubSub Service +type Client struct { + BaseClient +} + +// NewClient creates an instance of the Client client. +func NewClient(subscriptionID string) Client { + return NewClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClientWithBaseURI creates an instance of the Client client using a custom endpoint. Use this when interacting +// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { + return Client{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability checks that the resource name is valid and is not already in use. +// Parameters: +// location - the region +// parameters - parameters supplied to the operation. +func (client Client) CheckNameAvailability(ctx context.Context, location string, parameters NameAvailabilityParameters) (result NameAvailability, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("webpubsub.Client", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, location, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.Client", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client Client) CheckNameAvailabilityPreparer(ctx context.Context, location string, parameters NameAvailabilityParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client Client) CheckNameAvailabilityResponder(resp *http.Response) (result NameAvailability, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate create or update a resource. +// Parameters: +// parameters - parameters for the create or update operation +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) CreateOrUpdate(ctx context.Context, parameters ResourceType, resourceGroupName string, resourceName string) (result CreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("webpubsub.Client", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client Client) CreateOrUpdatePreparer(ctx context.Context, parameters ResourceType, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CreateOrUpdateSender(req *http.Request) (future CreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client Client) CreateOrUpdateResponder(resp *http.Response) (result ResourceType, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete operation to delete a resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result DeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client Client) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client Client) DeleteSender(req *http.Request) (future DeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the resource and its properties. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ResourceType, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.Client", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client Client) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client Client) GetResponder(resp *http.Response) (result ResourceType, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup handles requests to list all resources in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup") + defer func() { + sc := -1 + if result.rl.Response.Response != nil { + sc = result.rl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.rl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.Client", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.rl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.rl.hasNextLink() && result.rl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client Client) ListByResourceGroupResponder(resp *http.Response) (result ResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client Client) listByResourceGroupNextResults(ctx context.Context, lastResults ResourceList) (result ResourceList, err error) { + req, err := lastResults.resourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "webpubsub.Client", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "webpubsub.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription handles requests to list all resources in a subscription. +func (client Client) ListBySubscription(ctx context.Context) (result ResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListBySubscription") + defer func() { + sc := -1 + if result.rl.Response.Response != nil { + sc = result.rl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.rl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.Client", "ListBySubscription", resp, "Failure sending request") + return + } + + result.rl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.rl.hasNextLink() && result.rl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client Client) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/webPubSub", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client Client) ListBySubscriptionResponder(resp *http.Response) (result ResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client Client) listBySubscriptionNextResults(ctx context.Context, lastResults ResourceList) (result ResourceList, err error) { + req, err := lastResults.resourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "webpubsub.Client", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "webpubsub.Client", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListBySubscriptionComplete(ctx context.Context) (result ResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// ListKeys get the access keys of the resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) ListKeys(ctx context.Context, resourceGroupName string, resourceName string) (result Keys, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListKeysPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "webpubsub.Client", "ListKeys", resp, "Failure sending request") + return + } + + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "ListKeys", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client Client) ListKeysPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/listKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client Client) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client Client) ListKeysResponder(resp *http.Response) (result Keys, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateKey regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated at the +// same time. +// Parameters: +// parameters - parameter that describes the Regenerate Key Operation. +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) RegenerateKey(ctx context.Context, parameters RegenerateKeyParameters, resourceGroupName string, resourceName string) (result RegenerateKeyFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.RegenerateKey") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RegenerateKeyPreparer(ctx, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "RegenerateKey", nil, "Failure preparing request") + return + } + + result, err = client.RegenerateKeySender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "RegenerateKey", nil, "Failure sending request") + return + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client Client) RegenerateKeyPreparer(ctx context.Context, parameters RegenerateKeyParameters, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/regenerateKey", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client Client) RegenerateKeySender(req *http.Request) (future RegenerateKeyFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client Client) RegenerateKeyResponder(resp *http.Response) (result Keys, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Restart operation to restart a resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) Restart(ctx context.Context, resourceGroupName string, resourceName string) (result RestartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Restart") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RestartPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "Restart", nil, "Failure preparing request") + return + } + + result, err = client.RestartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "Restart", nil, "Failure sending request") + return + } + + return +} + +// RestartPreparer prepares the Restart request. +func (client Client) RestartPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/restart", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RestartSender sends the Restart request. The method will close the +// http.Response Body if it receives an error. +func (client Client) RestartSender(req *http.Request) (future RestartFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RestartResponder handles the response to the Restart request. The method always +// closes the http.Response Body. +func (client Client) RestartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update operation to update an exiting resource. +// Parameters: +// parameters - parameters for the update operation +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the resource. +func (client Client) Update(ctx context.Context, parameters ResourceType, resourceGroupName string, resourceName string) (result UpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, parameters, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "webpubsub.Client", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client Client) UpdatePreparer(ctx context.Context, parameters ResourceType, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client Client) UpdateSender(req *http.Request) (future UpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client Client) UpdateResponder(resp *http.Response) (result ResourceType, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/webpubsubapi/interfaces.go b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/webpubsubapi/interfaces.go new file mode 100644 index 000000000000..8cf44faeaa58 --- /dev/null +++ b/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub/webpubsubapi/interfaces.go @@ -0,0 +1,76 @@ +package webpubsubapi + +// Copyright (c) Microsoft Corporation. All rights 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/webpubsub/mgmt/2021-06-01-preview/webpubsub" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result webpubsub.OperationListPage, err error) + ListComplete(ctx context.Context) (result webpubsub.OperationListIterator, err error) +} + +var _ OperationsClientAPI = (*webpubsub.OperationsClient)(nil) + +// ClientAPI contains the set of methods on the Client type. +type ClientAPI interface { + CheckNameAvailability(ctx context.Context, location string, parameters webpubsub.NameAvailabilityParameters) (result webpubsub.NameAvailability, err error) + CreateOrUpdate(ctx context.Context, parameters webpubsub.ResourceType, resourceGroupName string, resourceName string) (result webpubsub.CreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.DeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.ResourceType, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result webpubsub.ResourceListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result webpubsub.ResourceListIterator, err error) + ListBySubscription(ctx context.Context) (result webpubsub.ResourceListPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result webpubsub.ResourceListIterator, err error) + ListKeys(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.Keys, err error) + RegenerateKey(ctx context.Context, parameters webpubsub.RegenerateKeyParameters, resourceGroupName string, resourceName string) (result webpubsub.RegenerateKeyFuture, err error) + Restart(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.RestartFuture, err error) + Update(ctx context.Context, parameters webpubsub.ResourceType, resourceGroupName string, resourceName string) (result webpubsub.UpdateFuture, err error) +} + +var _ ClientAPI = (*webpubsub.Client)(nil) + +// UsagesClientAPI contains the set of methods on the UsagesClient type. +type UsagesClientAPI interface { + List(ctx context.Context, location string) (result webpubsub.SignalRServiceUsageListPage, err error) + ListComplete(ctx context.Context, location string) (result webpubsub.SignalRServiceUsageListIterator, err error) +} + +var _ UsagesClientAPI = (*webpubsub.UsagesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + Delete(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result webpubsub.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result webpubsub.PrivateEndpointConnection, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.PrivateEndpointConnectionListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.PrivateEndpointConnectionListIterator, err error) + Update(ctx context.Context, privateEndpointConnectionName string, parameters webpubsub.PrivateEndpointConnection, resourceGroupName string, resourceName string) (result webpubsub.PrivateEndpointConnection, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*webpubsub.PrivateEndpointConnectionsClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + List(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.PrivateLinkResourceListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.PrivateLinkResourceListIterator, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*webpubsub.PrivateLinkResourcesClient)(nil) + +// SharedPrivateLinkResourcesClientAPI contains the set of methods on the SharedPrivateLinkResourcesClient type. +type SharedPrivateLinkResourcesClientAPI interface { + CreateOrUpdate(ctx context.Context, sharedPrivateLinkResourceName string, parameters webpubsub.SharedPrivateLinkResource, resourceGroupName string, resourceName string) (result webpubsub.SharedPrivateLinkResourcesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (result webpubsub.SharedPrivateLinkResourcesDeleteFuture, err error) + Get(ctx context.Context, sharedPrivateLinkResourceName string, resourceGroupName string, resourceName string) (result webpubsub.SharedPrivateLinkResource, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.SharedPrivateLinkResourceListPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result webpubsub.SharedPrivateLinkResourceListIterator, err error) +} + +var _ SharedPrivateLinkResourcesClientAPI = (*webpubsub.SharedPrivateLinkResourcesClient)(nil) diff --git a/version/version.go b/version/version.go index 3e4ff42109fd..5e38e4455506 100644 --- a/version/version.go +++ b/version/version.go @@ -4,4 +4,4 @@ package version // Licensed under the MIT License. See License.txt in the project root for license information. // Number contains the semantic version of this SDK. -const Number = "v55.4.0" +const Number = "v55.5.0"