diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/CHANGELOG.md b/services/postgresql/mgmt/2017-12-01/postgresql/CHANGELOG.md index d37474b3dd93..4787b2e4e259 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/CHANGELOG.md +++ b/services/postgresql/mgmt/2017-12-01/postgresql/CHANGELOG.md @@ -1,14 +1,70 @@ -# Change History +# Unreleased ## Additive Changes ### New Funcs -1. AzureEntityResource.MarshalJSON() ([]byte, error) -1. ErrorAdditionalInfo.MarshalJSON() ([]byte, error) -1. ErrorResponse.MarshalJSON() ([]byte, error) -1. OperationDisplay.MarshalJSON() ([]byte, error) -1. ProxyResource.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. ServerPrivateEndpointConnection.MarshalJSON() ([]byte, error) -1. VirtualNetworkRuleListResult.MarshalJSON() ([]byte, error) +1. *RecoverableServerResource.UnmarshalJSON([]byte) error +1. *ServerParametersListUpdateConfigurationsFuture.UnmarshalJSON([]byte) error +1. *ServerSecurityAlertPolicyListResultIterator.Next() error +1. *ServerSecurityAlertPolicyListResultIterator.NextWithContext(context.Context) error +1. *ServerSecurityAlertPolicyListResultPage.Next() error +1. *ServerSecurityAlertPolicyListResultPage.NextWithContext(context.Context) error +1. NewRecoverableServersClient(string) RecoverableServersClient +1. NewRecoverableServersClientWithBaseURI(string, string) RecoverableServersClient +1. NewServerBasedPerformanceTierClient(string) ServerBasedPerformanceTierClient +1. NewServerBasedPerformanceTierClientWithBaseURI(string, string) ServerBasedPerformanceTierClient +1. NewServerParametersClient(string) ServerParametersClient +1. NewServerParametersClientWithBaseURI(string, string) ServerParametersClient +1. NewServerSecurityAlertPolicyListResultIterator(ServerSecurityAlertPolicyListResultPage) ServerSecurityAlertPolicyListResultIterator +1. NewServerSecurityAlertPolicyListResultPage(ServerSecurityAlertPolicyListResult, func(context.Context, ServerSecurityAlertPolicyListResult) (ServerSecurityAlertPolicyListResult, error)) ServerSecurityAlertPolicyListResultPage +1. RecoverableServerProperties.MarshalJSON() ([]byte, error) +1. RecoverableServerResource.MarshalJSON() ([]byte, error) +1. RecoverableServersClient.Get(context.Context, string, string) (RecoverableServerResource, error) +1. RecoverableServersClient.GetPreparer(context.Context, string, string) (*http.Request, error) +1. RecoverableServersClient.GetResponder(*http.Response) (RecoverableServerResource, error) +1. RecoverableServersClient.GetSender(*http.Request) (*http.Response, error) +1. ServerBasedPerformanceTierClient.List(context.Context, string, string) (PerformanceTierListResult, error) +1. ServerBasedPerformanceTierClient.ListPreparer(context.Context, string, string) (*http.Request, error) +1. ServerBasedPerformanceTierClient.ListResponder(*http.Response) (PerformanceTierListResult, error) +1. ServerBasedPerformanceTierClient.ListSender(*http.Request) (*http.Response, error) +1. ServerParametersClient.ListUpdateConfigurations(context.Context, string, string, ConfigurationListResult) (ServerParametersListUpdateConfigurationsFuture, error) +1. ServerParametersClient.ListUpdateConfigurationsPreparer(context.Context, string, string, ConfigurationListResult) (*http.Request, error) +1. ServerParametersClient.ListUpdateConfigurationsResponder(*http.Response) (ConfigurationListResult, error) +1. ServerParametersClient.ListUpdateConfigurationsSender(*http.Request) (ServerParametersListUpdateConfigurationsFuture, error) +1. ServerSecurityAlertPoliciesClient.ListByServer(context.Context, string, string) (ServerSecurityAlertPolicyListResultPage, error) +1. ServerSecurityAlertPoliciesClient.ListByServerComplete(context.Context, string, string) (ServerSecurityAlertPolicyListResultIterator, error) +1. ServerSecurityAlertPoliciesClient.ListByServerPreparer(context.Context, string, string) (*http.Request, error) +1. ServerSecurityAlertPoliciesClient.ListByServerResponder(*http.Response) (ServerSecurityAlertPolicyListResult, error) +1. ServerSecurityAlertPoliciesClient.ListByServerSender(*http.Request) (*http.Response, error) +1. ServerSecurityAlertPolicyListResult.IsEmpty() bool +1. ServerSecurityAlertPolicyListResult.MarshalJSON() ([]byte, error) +1. ServerSecurityAlertPolicyListResultIterator.NotDone() bool +1. ServerSecurityAlertPolicyListResultIterator.Response() ServerSecurityAlertPolicyListResult +1. ServerSecurityAlertPolicyListResultIterator.Value() ServerSecurityAlertPolicy +1. ServerSecurityAlertPolicyListResultPage.NotDone() bool +1. ServerSecurityAlertPolicyListResultPage.Response() ServerSecurityAlertPolicyListResult +1. ServerSecurityAlertPolicyListResultPage.Values() []ServerSecurityAlertPolicy + +### Struct Changes + +#### New Structs + +1. RecoverableServerProperties +1. RecoverableServerResource +1. RecoverableServersClient +1. ServerBasedPerformanceTierClient +1. ServerParametersClient +1. ServerParametersListUpdateConfigurationsFuture +1. ServerSecurityAlertPolicyListResult +1. ServerSecurityAlertPolicyListResultIterator +1. ServerSecurityAlertPolicyListResultPage + +#### New Struct Fields + +1. PerformanceTierProperties.MaxBackupRetentionDays +1. PerformanceTierProperties.MaxLargeStorageMB +1. PerformanceTierProperties.MaxStorageMB +1. PerformanceTierProperties.MinBackupRetentionDays +1. PerformanceTierProperties.MinLargeStorageMB +1. PerformanceTierProperties.MinStorageMB diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/_meta.json b/services/postgresql/mgmt/2017-12-01/postgresql/_meta.json index 0d0f4dfcca08..0212442d74c3 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/_meta.json +++ b/services/postgresql/mgmt/2017-12-01/postgresql/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "c7616be749e60dc269e2bb50800f06dbca065098", "readme": "/_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", "tag": "package-2017-12-01", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/configurations.go b/services/postgresql/mgmt/2017-12-01/postgresql/configurations.go index feaaf83facaf..baf2b466f420 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/configurations.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/configurations.go @@ -55,8 +55,7 @@ func (client ConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceG 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ConfigurationsClient", "CreateOrUpdate", err.Error()) } @@ -147,8 +146,7 @@ func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName st 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ConfigurationsClient", "Get", err.Error()) } @@ -234,8 +232,7 @@ func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ConfigurationsClient", "ListByServer", err.Error()) } diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/databases.go b/services/postgresql/mgmt/2017-12-01/postgresql/databases.go index 2b881d38f129..4d33aafebad9 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/databases.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/databases.go @@ -55,8 +55,7 @@ func (client DatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupN 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.DatabasesClient", "CreateOrUpdate", err.Error()) } @@ -147,8 +146,7 @@ func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName stri 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.DatabasesClient", "Delete", err.Error()) } @@ -236,8 +234,7 @@ func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.DatabasesClient", "Get", err.Error()) } @@ -323,8 +320,7 @@ func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupNam 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.DatabasesClient", "ListByServer", err.Error()) } diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/firewallrules.go b/services/postgresql/mgmt/2017-12-01/postgresql/firewallrules.go index 74c9523a0e7c..7d16733a33f8 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/firewallrules.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/firewallrules.go @@ -55,8 +55,7 @@ func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGr 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, @@ -154,8 +153,7 @@ func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.FirewallRulesClient", "Delete", err.Error()) } @@ -243,8 +241,7 @@ func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName str 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.FirewallRulesClient", "Get", err.Error()) } @@ -330,8 +327,7 @@ func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGrou 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.FirewallRulesClient", "ListByServer", err.Error()) } diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/logfiles.go b/services/postgresql/mgmt/2017-12-01/postgresql/logfiles.go index a2d6752efb7a..cac447365b12 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/logfiles.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/logfiles.go @@ -53,8 +53,7 @@ func (client LogFilesClient) ListByServer(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.LogFilesClient", "ListByServer", err.Error()) } diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/models.go b/services/postgresql/mgmt/2017-12-01/postgresql/models.go index 5029523ae3b6..928385942319 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/models.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/models.go @@ -747,6 +747,18 @@ type PerformanceTierListResult struct { type PerformanceTierProperties struct { // ID - ID of the performance tier. ID *string `json:"id,omitempty"` + // MaxBackupRetentionDays - Maximum Backup retention in days for the performance tier edition + MaxBackupRetentionDays *int32 `json:"maxBackupRetentionDays,omitempty"` + // MinBackupRetentionDays - Minimum Backup retention in days for the performance tier edition + MinBackupRetentionDays *int32 `json:"minBackupRetentionDays,omitempty"` + // MaxStorageMB - Max storage allowed for a server. + MaxStorageMB *int32 `json:"maxStorageMB,omitempty"` + // MinLargeStorageMB - Max storage allowed for a server. + MinLargeStorageMB *int32 `json:"minLargeStorageMB,omitempty"` + // MaxLargeStorageMB - Max storage allowed for a server. + MaxLargeStorageMB *int32 `json:"maxLargeStorageMB,omitempty"` + // MinStorageMB - Max storage allowed for a server. + MinStorageMB *int32 `json:"minStorageMB,omitempty"` // ServiceLevelObjectives - Service level objectives associated with the performance tier ServiceLevelObjectives *[]PerformanceTierServiceLevelObjectives `json:"serviceLevelObjectives,omitempty"` } @@ -794,6 +806,101 @@ func (pr ProxyResource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// RecoverableServerProperties the recoverable server's properties. +type RecoverableServerProperties struct { + // LastAvailableBackupDateTime - READ-ONLY; The last available backup date time. + LastAvailableBackupDateTime *string `json:"lastAvailableBackupDateTime,omitempty"` + // ServiceLevelObjective - READ-ONLY; The service level objective + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // Edition - READ-ONLY; Edition of the performance tier. + Edition *string `json:"edition,omitempty"` + // VCore - READ-ONLY; vCore associated with the service level objective + VCore *int32 `json:"vCore,omitempty"` + // HardwareGeneration - READ-ONLY; Hardware generation associated with the service level objective + HardwareGeneration *string `json:"hardwareGeneration,omitempty"` + // Version - READ-ONLY; The PostgreSQL version + Version *string `json:"version,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableServerProperties. +func (rsp RecoverableServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableServerResource a recoverable server resource. +type RecoverableServerResource struct { + autorest.Response `json:"-"` + // RecoverableServerProperties - Resource properties. + *RecoverableServerProperties `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 RecoverableServerResource. +func (rsr RecoverableServerResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsr.RecoverableServerProperties != nil { + objectMap["properties"] = rsr.RecoverableServerProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecoverableServerResource struct. +func (rsr *RecoverableServerResource) 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 recoverableServerProperties RecoverableServerProperties + err = json.Unmarshal(*v, &recoverableServerProperties) + if err != nil { + return err + } + rsr.RecoverableServerProperties = &recoverableServerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rsr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rsr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rsr.Type = &typeVar + } + } + } + + return nil +} + // 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} @@ -1247,6 +1354,49 @@ type ServerListResult struct { Value *[]Server `json:"value,omitempty"` } +// ServerParametersListUpdateConfigurationsFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerParametersListUpdateConfigurationsFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerParametersClient) (ConfigurationListResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerParametersListUpdateConfigurationsFuture) 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 ServerParametersListUpdateConfigurationsFuture.Result. +func (future *ServerParametersListUpdateConfigurationsFuture) result(client ServerParametersClient) (clr ConfigurationListResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersListUpdateConfigurationsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + clr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresql.ServerParametersListUpdateConfigurationsFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if clr.Response.Response, err = future.GetResult(sender); err == nil && clr.Response.Response.StatusCode != http.StatusNoContent { + clr, err = client.ListUpdateConfigurationsResponder(clr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersListUpdateConfigurationsFuture", "Result", clr.Response.Response, "Failure responding to request") + } + } + return +} + // ServerPrivateEndpointConnection a private endpoint connection under a server type ServerPrivateEndpointConnection struct { // ID - READ-ONLY; Resource ID of the Private Endpoint Connection. @@ -2049,6 +2199,172 @@ func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { return nil } +// ServerSecurityAlertPolicyListResult a list of the server's security alert policies. +type ServerSecurityAlertPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerSecurityAlertPolicyListResult. +func (ssaplr ServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ServerSecurityAlertPolicy values. +type ServerSecurityAlertPolicyListResultIterator struct { + i int + page ServerSecurityAlertPolicyListResultPage +} + +// 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 *ServerSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPolicyListResultIterator.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 *ServerSecurityAlertPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerSecurityAlertPolicyListResultIterator) 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 ServerSecurityAlertPolicyListResultIterator) Response() ServerSecurityAlertPolicyListResult { + 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 ServerSecurityAlertPolicyListResultIterator) Value() ServerSecurityAlertPolicy { + if !iter.page.NotDone() { + return ServerSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerSecurityAlertPolicyListResultIterator type. +func NewServerSecurityAlertPolicyListResultIterator(page ServerSecurityAlertPolicyListResultPage) ServerSecurityAlertPolicyListResultIterator { + return ServerSecurityAlertPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ssaplr ServerSecurityAlertPolicyListResult) IsEmpty() bool { + return ssaplr.Value == nil || len(*ssaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ssaplr ServerSecurityAlertPolicyListResult) hasNextLink() bool { + return ssaplr.NextLink != nil && len(*ssaplr.NextLink) != 0 +} + +// serverSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ssaplr ServerSecurityAlertPolicyListResult) serverSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ssaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ssaplr.NextLink))) +} + +// ServerSecurityAlertPolicyListResultPage contains a page of ServerSecurityAlertPolicy values. +type ServerSecurityAlertPolicyListResultPage struct { + fn func(context.Context, ServerSecurityAlertPolicyListResult) (ServerSecurityAlertPolicyListResult, error) + ssaplr ServerSecurityAlertPolicyListResult +} + +// 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 *ServerSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPolicyListResultPage.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.ssaplr) + if err != nil { + return err + } + page.ssaplr = 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 *ServerSecurityAlertPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.ssaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerSecurityAlertPolicyListResultPage) Response() ServerSecurityAlertPolicyListResult { + return page.ssaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerSecurityAlertPolicyListResultPage) Values() []ServerSecurityAlertPolicy { + if page.ssaplr.IsEmpty() { + return nil + } + return *page.ssaplr.Value +} + +// Creates a new instance of the ServerSecurityAlertPolicyListResultPage type. +func NewServerSecurityAlertPolicyListResultPage(cur ServerSecurityAlertPolicyListResult, getNextPage func(context.Context, ServerSecurityAlertPolicyListResult) (ServerSecurityAlertPolicyListResult, error)) ServerSecurityAlertPolicyListResultPage { + return ServerSecurityAlertPolicyListResultPage{ + fn: getNextPage, + ssaplr: cur, + } +} + // ServersRestartFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type ServersRestartFuture struct { diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/postgresqlapi/interfaces.go b/services/postgresql/mgmt/2017-12-01/postgresql/postgresqlapi/interfaces.go index 36e5f246fd8b..d1e7e1dc3f48 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/postgresqlapi/interfaces.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/postgresqlapi/interfaces.go @@ -71,6 +71,13 @@ type ConfigurationsClientAPI interface { var _ ConfigurationsClientAPI = (*postgresql.ConfigurationsClient)(nil) +// ServerParametersClientAPI contains the set of methods on the ServerParametersClient type. +type ServerParametersClientAPI interface { + ListUpdateConfigurations(ctx context.Context, resourceGroupName string, serverName string, value postgresql.ConfigurationListResult) (result postgresql.ServerParametersListUpdateConfigurationsFuture, err error) +} + +var _ ServerParametersClientAPI = (*postgresql.ServerParametersClient)(nil) + // LogFilesClientAPI contains the set of methods on the LogFilesClient type. type LogFilesClientAPI interface { ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.LogFileListResult, err error) @@ -88,6 +95,20 @@ type ServerAdministratorsClientAPI interface { var _ ServerAdministratorsClientAPI = (*postgresql.ServerAdministratorsClient)(nil) +// RecoverableServersClientAPI contains the set of methods on the RecoverableServersClient type. +type RecoverableServersClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.RecoverableServerResource, err error) +} + +var _ RecoverableServersClientAPI = (*postgresql.RecoverableServersClient)(nil) + +// ServerBasedPerformanceTierClientAPI contains the set of methods on the ServerBasedPerformanceTierClient type. +type ServerBasedPerformanceTierClientAPI interface { + List(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.PerformanceTierListResult, err error) +} + +var _ ServerBasedPerformanceTierClientAPI = (*postgresql.ServerBasedPerformanceTierClient)(nil) + // LocationBasedPerformanceTierClientAPI contains the set of methods on the LocationBasedPerformanceTierClient type. type LocationBasedPerformanceTierClientAPI interface { List(ctx context.Context, locationName string) (result postgresql.PerformanceTierListResult, err error) @@ -113,6 +134,8 @@ var _ OperationsClientAPI = (*postgresql.OperationsClient)(nil) type ServerSecurityAlertPoliciesClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters postgresql.ServerSecurityAlertPolicy) (result postgresql.ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) Get(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.ServerSecurityAlertPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.ServerSecurityAlertPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.ServerSecurityAlertPolicyListResultIterator, err error) } var _ ServerSecurityAlertPoliciesClientAPI = (*postgresql.ServerSecurityAlertPoliciesClient)(nil) diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/recoverableservers.go b/services/postgresql/mgmt/2017-12-01/postgresql/recoverableservers.go new file mode 100644 index 000000000000..a73a4546376c --- /dev/null +++ b/services/postgresql/mgmt/2017-12-01/postgresql/recoverableservers.go @@ -0,0 +1,120 @@ +package postgresql + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// RecoverableServersClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type RecoverableServersClient struct { + BaseClient +} + +// NewRecoverableServersClient creates an instance of the RecoverableServersClient client. +func NewRecoverableServersClient(subscriptionID string) RecoverableServersClient { + return NewRecoverableServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecoverableServersClientWithBaseURI creates an instance of the RecoverableServersClient 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 NewRecoverableServersClientWithBaseURI(baseURI string, subscriptionID string) RecoverableServersClient { + return RecoverableServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recoverable PostgreSQL Server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client RecoverableServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result RecoverableServerResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableServersClient.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("postgresql.RecoverableServersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.RecoverableServersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresql.RecoverableServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.RecoverableServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoverableServersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBForPostgreSQL/servers/{serverName}/recoverableServers", 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 RecoverableServersClient) 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 RecoverableServersClient) GetResponder(resp *http.Response) (result RecoverableServerResource, 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/postgresql/mgmt/2017-12-01/postgresql/replicas.go b/services/postgresql/mgmt/2017-12-01/postgresql/replicas.go index ba1c5c858c1a..8a8f896bb1c6 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/replicas.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/replicas.go @@ -53,8 +53,7 @@ func (client ReplicasClient) ListByServer(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ReplicasClient", "ListByServer", err.Error()) } @@ -96,7 +95,7 @@ func (client ReplicasClient) ListByServerPreparer(ctx context.Context, resourceG preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Replicas", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/replicas", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/serveradministrators.go b/services/postgresql/mgmt/2017-12-01/postgresql/serveradministrators.go index 1ab895e57c18..40ce4a7a1bad 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/serveradministrators.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/serveradministrators.go @@ -56,8 +56,7 @@ func (client ServerAdministratorsClient) CreateOrUpdate(ctx context.Context, res 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: properties, Constraints: []validation.Constraint{{Target: "properties.ServerAdministratorProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "properties.ServerAdministratorProperties.AdministratorType", Name: validation.Null, Rule: true, Chain: nil}, @@ -100,7 +99,7 @@ func (client ServerAdministratorsClient) CreateOrUpdatePreparer(ctx context.Cont autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Administrators/activeDirectory", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/administrators/activeDirectory", pathParameters), autorest.WithJSON(properties), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) @@ -153,8 +152,7 @@ func (client ServerAdministratorsClient) Delete(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServerAdministratorsClient", "Delete", err.Error()) } @@ -189,7 +187,7 @@ func (client ServerAdministratorsClient) DeletePreparer(ctx context.Context, res preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Administrators/activeDirectory", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/administrators/activeDirectory", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -240,8 +238,7 @@ func (client ServerAdministratorsClient) Get(ctx context.Context, resourceGroupN 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServerAdministratorsClient", "Get", err.Error()) } @@ -283,7 +280,7 @@ func (client ServerAdministratorsClient) GetPreparer(ctx context.Context, resour preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Administrators/activeDirectory", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/administrators/activeDirectory", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -326,8 +323,7 @@ func (client ServerAdministratorsClient) List(ctx context.Context, resourceGroup 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServerAdministratorsClient", "List", err.Error()) } diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/serverbasedperformancetier.go b/services/postgresql/mgmt/2017-12-01/postgresql/serverbasedperformancetier.go new file mode 100644 index 000000000000..7fcf1485cb7f --- /dev/null +++ b/services/postgresql/mgmt/2017-12-01/postgresql/serverbasedperformancetier.go @@ -0,0 +1,120 @@ +package postgresql + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ServerBasedPerformanceTierClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type ServerBasedPerformanceTierClient struct { + BaseClient +} + +// NewServerBasedPerformanceTierClient creates an instance of the ServerBasedPerformanceTierClient client. +func NewServerBasedPerformanceTierClient(subscriptionID string) ServerBasedPerformanceTierClient { + return NewServerBasedPerformanceTierClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerBasedPerformanceTierClientWithBaseURI creates an instance of the ServerBasedPerformanceTierClient 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 NewServerBasedPerformanceTierClientWithBaseURI(baseURI string, subscriptionID string) ServerBasedPerformanceTierClient { + return ServerBasedPerformanceTierClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list all the performance tiers for a PostgreSQL server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServerBasedPerformanceTierClient) List(ctx context.Context, resourceGroupName string, serverName string) (result PerformanceTierListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBasedPerformanceTierClient.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("postgresql.ServerBasedPerformanceTierClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerBasedPerformanceTierClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresql.ServerBasedPerformanceTierClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerBasedPerformanceTierClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServerBasedPerformanceTierClient) ListPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBForPostgreSQL/servers/{serverName}/performanceTiers", 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 ServerBasedPerformanceTierClient) 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 ServerBasedPerformanceTierClient) ListResponder(resp *http.Response) (result PerformanceTierListResult, 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/postgresql/mgmt/2017-12-01/postgresql/serverparameters.go b/services/postgresql/mgmt/2017-12-01/postgresql/serverparameters.go new file mode 100644 index 000000000000..d21b7ff6997a --- /dev/null +++ b/services/postgresql/mgmt/2017-12-01/postgresql/serverparameters.go @@ -0,0 +1,125 @@ +package postgresql + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ServerParametersClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type ServerParametersClient struct { + BaseClient +} + +// NewServerParametersClient creates an instance of the ServerParametersClient client. +func NewServerParametersClient(subscriptionID string) ServerParametersClient { + return NewServerParametersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerParametersClientWithBaseURI creates an instance of the ServerParametersClient 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 NewServerParametersClientWithBaseURI(baseURI string, subscriptionID string) ServerParametersClient { + return ServerParametersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListUpdateConfigurations update a list of configurations in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// value - the parameters for updating a list of server configuration. +func (client ServerParametersClient) ListUpdateConfigurations(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult) (result ServerParametersListUpdateConfigurationsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerParametersClient.ListUpdateConfigurations") + 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: 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("postgresql.ServerParametersClient", "ListUpdateConfigurations", err.Error()) + } + + req, err := client.ListUpdateConfigurationsPreparer(ctx, resourceGroupName, serverName, value) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersClient", "ListUpdateConfigurations", nil, "Failure preparing request") + return + } + + result, err = client.ListUpdateConfigurationsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersClient", "ListUpdateConfigurations", nil, "Failure sending request") + return + } + + return +} + +// ListUpdateConfigurationsPreparer prepares the ListUpdateConfigurations request. +func (client ServerParametersClient) ListUpdateConfigurationsPreparer(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBForPostgreSQL/servers/{serverName}/updateConfigurations", pathParameters), + autorest.WithJSON(value), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUpdateConfigurationsSender sends the ListUpdateConfigurations request. The method will close the +// http.Response Body if it receives an error. +func (client ServerParametersClient) ListUpdateConfigurationsSender(req *http.Request) (future ServerParametersListUpdateConfigurationsFuture, 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 +} + +// ListUpdateConfigurationsResponder handles the response to the ListUpdateConfigurations request. The method always +// closes the http.Response Body. +func (client ServerParametersClient) ListUpdateConfigurationsResponder(resp *http.Response) (result ConfigurationListResult, 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/postgresql/mgmt/2017-12-01/postgresql/servers.go b/services/postgresql/mgmt/2017-12-01/postgresql/servers.go index bc0a3487876c..2dcc01e1ed7b 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/servers.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/servers.go @@ -54,8 +54,7 @@ func (client ServersClient) Create(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {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}, @@ -151,8 +150,7 @@ func (client ServersClient) Delete(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "Delete", err.Error()) } @@ -238,8 +236,7 @@ func (client ServersClient) Get(ctx context.Context, resourceGroupName string, s 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "Get", err.Error()) } @@ -400,8 +397,7 @@ func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "ListByResourceGroup", err.Error()) } @@ -485,8 +481,7 @@ func (client ServersClient) Restart(ctx context.Context, resourceGroupName strin 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "Restart", err.Error()) } @@ -574,8 +569,7 @@ func (client ServersClient) Update(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "Update", err.Error()) } diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/serversecurityalertpolicies.go b/services/postgresql/mgmt/2017-12-01/postgresql/serversecurityalertpolicies.go index ecee5a3f232c..277082f2e2fe 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/serversecurityalertpolicies.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/serversecurityalertpolicies.go @@ -53,8 +53,7 @@ func (client ServerSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Conte 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", err.Error()) @@ -144,8 +143,7 @@ func (client ServerSecurityAlertPoliciesClient) Get(ctx context.Context, resourc 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.ServerSecurityAlertPoliciesClient", "Get", err.Error()) @@ -212,3 +210,130 @@ func (client ServerSecurityAlertPoliciesClient) GetResponder(resp *http.Response result.Response = autorest.Response{Response: resp} return } + +// ListByServer get the server's threat detection policies. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServerSecurityAlertPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.ssaplr.Response.Response != nil { + sc = result.ssaplr.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("postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.ssaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.ssaplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.ssaplr.hasNextLink() && result.ssaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerSecurityAlertPoliciesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBforPostgreSQL/servers/{serverName}/securityAlertPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) ListByServerResponder(resp *http.Response) (result ServerSecurityAlertPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerSecurityAlertPoliciesClient) listByServerNextResults(ctx context.Context, lastResults ServerSecurityAlertPolicyListResult) (result ServerSecurityAlertPolicyListResult, err error) { + req, err := lastResults.serverSecurityAlertPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerSecurityAlertPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/postgresql/mgmt/2017-12-01/postgresql/virtualnetworkrules.go b/services/postgresql/mgmt/2017-12-01/postgresql/virtualnetworkrules.go index 243cc9c356f1..46dd48784d6f 100644 --- a/services/postgresql/mgmt/2017-12-01/postgresql/virtualnetworkrules.go +++ b/services/postgresql/mgmt/2017-12-01/postgresql/virtualnetworkrules.go @@ -54,8 +54,7 @@ func (client VirtualNetworkRulesClient) CreateOrUpdate(ctx context.Context, reso 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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: parameters, @@ -149,8 +148,7 @@ func (client VirtualNetworkRulesClient) Delete(ctx context.Context, resourceGrou 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.VirtualNetworkRulesClient", "Delete", err.Error()) @@ -238,8 +236,7 @@ func (client VirtualNetworkRulesClient) Get(ctx context.Context, resourceGroupNa 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.VirtualNetworkRulesClient", "Get", err.Error()) @@ -325,8 +322,7 @@ func (client VirtualNetworkRulesClient) ListByServer(ctx context.Context, resour 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.VirtualNetworkRulesClient", "ListByServer", err.Error()) diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/CHANGELOG.md b/services/postgresql/mgmt/2020-01-01/postgresql/CHANGELOG.md index bd9e28e8fadd..4787b2e4e259 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/CHANGELOG.md +++ b/services/postgresql/mgmt/2020-01-01/postgresql/CHANGELOG.md @@ -1,19 +1,70 @@ -# Change History +# Unreleased ## Additive Changes ### New Funcs -1. AzureEntityResource.MarshalJSON() ([]byte, error) -1. ErrorAdditionalInfo.MarshalJSON() ([]byte, error) -1. ErrorResponse.MarshalJSON() ([]byte, error) -1. OperationDisplay.MarshalJSON() ([]byte, error) -1. PrivateEndpointConnectionListResult.MarshalJSON() ([]byte, error) -1. PrivateLinkResource.MarshalJSON() ([]byte, error) -1. PrivateLinkResourceListResult.MarshalJSON() ([]byte, error) -1. PrivateLinkResourceProperties.MarshalJSON() ([]byte, error) -1. ProxyResource.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. ServerKeyListResult.MarshalJSON() ([]byte, error) -1. ServerPrivateEndpointConnection.MarshalJSON() ([]byte, error) -1. VirtualNetworkRuleListResult.MarshalJSON() ([]byte, error) +1. *RecoverableServerResource.UnmarshalJSON([]byte) error +1. *ServerParametersListUpdateConfigurationsFuture.UnmarshalJSON([]byte) error +1. *ServerSecurityAlertPolicyListResultIterator.Next() error +1. *ServerSecurityAlertPolicyListResultIterator.NextWithContext(context.Context) error +1. *ServerSecurityAlertPolicyListResultPage.Next() error +1. *ServerSecurityAlertPolicyListResultPage.NextWithContext(context.Context) error +1. NewRecoverableServersClient(string) RecoverableServersClient +1. NewRecoverableServersClientWithBaseURI(string, string) RecoverableServersClient +1. NewServerBasedPerformanceTierClient(string) ServerBasedPerformanceTierClient +1. NewServerBasedPerformanceTierClientWithBaseURI(string, string) ServerBasedPerformanceTierClient +1. NewServerParametersClient(string) ServerParametersClient +1. NewServerParametersClientWithBaseURI(string, string) ServerParametersClient +1. NewServerSecurityAlertPolicyListResultIterator(ServerSecurityAlertPolicyListResultPage) ServerSecurityAlertPolicyListResultIterator +1. NewServerSecurityAlertPolicyListResultPage(ServerSecurityAlertPolicyListResult, func(context.Context, ServerSecurityAlertPolicyListResult) (ServerSecurityAlertPolicyListResult, error)) ServerSecurityAlertPolicyListResultPage +1. RecoverableServerProperties.MarshalJSON() ([]byte, error) +1. RecoverableServerResource.MarshalJSON() ([]byte, error) +1. RecoverableServersClient.Get(context.Context, string, string) (RecoverableServerResource, error) +1. RecoverableServersClient.GetPreparer(context.Context, string, string) (*http.Request, error) +1. RecoverableServersClient.GetResponder(*http.Response) (RecoverableServerResource, error) +1. RecoverableServersClient.GetSender(*http.Request) (*http.Response, error) +1. ServerBasedPerformanceTierClient.List(context.Context, string, string) (PerformanceTierListResult, error) +1. ServerBasedPerformanceTierClient.ListPreparer(context.Context, string, string) (*http.Request, error) +1. ServerBasedPerformanceTierClient.ListResponder(*http.Response) (PerformanceTierListResult, error) +1. ServerBasedPerformanceTierClient.ListSender(*http.Request) (*http.Response, error) +1. ServerParametersClient.ListUpdateConfigurations(context.Context, string, string, ConfigurationListResult) (ServerParametersListUpdateConfigurationsFuture, error) +1. ServerParametersClient.ListUpdateConfigurationsPreparer(context.Context, string, string, ConfigurationListResult) (*http.Request, error) +1. ServerParametersClient.ListUpdateConfigurationsResponder(*http.Response) (ConfigurationListResult, error) +1. ServerParametersClient.ListUpdateConfigurationsSender(*http.Request) (ServerParametersListUpdateConfigurationsFuture, error) +1. ServerSecurityAlertPoliciesClient.ListByServer(context.Context, string, string) (ServerSecurityAlertPolicyListResultPage, error) +1. ServerSecurityAlertPoliciesClient.ListByServerComplete(context.Context, string, string) (ServerSecurityAlertPolicyListResultIterator, error) +1. ServerSecurityAlertPoliciesClient.ListByServerPreparer(context.Context, string, string) (*http.Request, error) +1. ServerSecurityAlertPoliciesClient.ListByServerResponder(*http.Response) (ServerSecurityAlertPolicyListResult, error) +1. ServerSecurityAlertPoliciesClient.ListByServerSender(*http.Request) (*http.Response, error) +1. ServerSecurityAlertPolicyListResult.IsEmpty() bool +1. ServerSecurityAlertPolicyListResult.MarshalJSON() ([]byte, error) +1. ServerSecurityAlertPolicyListResultIterator.NotDone() bool +1. ServerSecurityAlertPolicyListResultIterator.Response() ServerSecurityAlertPolicyListResult +1. ServerSecurityAlertPolicyListResultIterator.Value() ServerSecurityAlertPolicy +1. ServerSecurityAlertPolicyListResultPage.NotDone() bool +1. ServerSecurityAlertPolicyListResultPage.Response() ServerSecurityAlertPolicyListResult +1. ServerSecurityAlertPolicyListResultPage.Values() []ServerSecurityAlertPolicy + +### Struct Changes + +#### New Structs + +1. RecoverableServerProperties +1. RecoverableServerResource +1. RecoverableServersClient +1. ServerBasedPerformanceTierClient +1. ServerParametersClient +1. ServerParametersListUpdateConfigurationsFuture +1. ServerSecurityAlertPolicyListResult +1. ServerSecurityAlertPolicyListResultIterator +1. ServerSecurityAlertPolicyListResultPage + +#### New Struct Fields + +1. PerformanceTierProperties.MaxBackupRetentionDays +1. PerformanceTierProperties.MaxLargeStorageMB +1. PerformanceTierProperties.MaxStorageMB +1. PerformanceTierProperties.MinBackupRetentionDays +1. PerformanceTierProperties.MinLargeStorageMB +1. PerformanceTierProperties.MinStorageMB diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/_meta.json b/services/postgresql/mgmt/2020-01-01/postgresql/_meta.json index 1aacd052fc27..62ddccd06b6e 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/_meta.json +++ b/services/postgresql/mgmt/2020-01-01/postgresql/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "c7616be749e60dc269e2bb50800f06dbca065098", "readme": "/_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", "tag": "package-2020-01-01", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/configurations.go b/services/postgresql/mgmt/2020-01-01/postgresql/configurations.go index feaaf83facaf..baf2b466f420 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/configurations.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/configurations.go @@ -55,8 +55,7 @@ func (client ConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceG 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ConfigurationsClient", "CreateOrUpdate", err.Error()) } @@ -147,8 +146,7 @@ func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName st 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ConfigurationsClient", "Get", err.Error()) } @@ -234,8 +232,7 @@ func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ConfigurationsClient", "ListByServer", err.Error()) } diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/databases.go b/services/postgresql/mgmt/2020-01-01/postgresql/databases.go index 2b881d38f129..4d33aafebad9 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/databases.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/databases.go @@ -55,8 +55,7 @@ func (client DatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupN 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.DatabasesClient", "CreateOrUpdate", err.Error()) } @@ -147,8 +146,7 @@ func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName stri 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.DatabasesClient", "Delete", err.Error()) } @@ -236,8 +234,7 @@ func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.DatabasesClient", "Get", err.Error()) } @@ -323,8 +320,7 @@ func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupNam 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.DatabasesClient", "ListByServer", err.Error()) } diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/firewallrules.go b/services/postgresql/mgmt/2020-01-01/postgresql/firewallrules.go index 74c9523a0e7c..7d16733a33f8 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/firewallrules.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/firewallrules.go @@ -55,8 +55,7 @@ func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGr 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, @@ -154,8 +153,7 @@ func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.FirewallRulesClient", "Delete", err.Error()) } @@ -243,8 +241,7 @@ func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName str 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.FirewallRulesClient", "Get", err.Error()) } @@ -330,8 +327,7 @@ func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGrou 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.FirewallRulesClient", "ListByServer", err.Error()) } diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/logfiles.go b/services/postgresql/mgmt/2020-01-01/postgresql/logfiles.go index a2d6752efb7a..cac447365b12 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/logfiles.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/logfiles.go @@ -53,8 +53,7 @@ func (client LogFilesClient) ListByServer(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.LogFilesClient", "ListByServer", err.Error()) } diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/models.go b/services/postgresql/mgmt/2020-01-01/postgresql/models.go index 019da26aa3bf..a1369bec68eb 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/models.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/models.go @@ -747,6 +747,18 @@ type PerformanceTierListResult struct { type PerformanceTierProperties struct { // ID - ID of the performance tier. ID *string `json:"id,omitempty"` + // MaxBackupRetentionDays - Maximum Backup retention in days for the performance tier edition + MaxBackupRetentionDays *int32 `json:"maxBackupRetentionDays,omitempty"` + // MinBackupRetentionDays - Minimum Backup retention in days for the performance tier edition + MinBackupRetentionDays *int32 `json:"minBackupRetentionDays,omitempty"` + // MaxStorageMB - Max storage allowed for a server. + MaxStorageMB *int32 `json:"maxStorageMB,omitempty"` + // MinLargeStorageMB - Max storage allowed for a server. + MinLargeStorageMB *int32 `json:"minLargeStorageMB,omitempty"` + // MaxLargeStorageMB - Max storage allowed for a server. + MaxLargeStorageMB *int32 `json:"maxLargeStorageMB,omitempty"` + // MinStorageMB - Max storage allowed for a server. + MinStorageMB *int32 `json:"minStorageMB,omitempty"` // ServiceLevelObjectives - Service level objectives associated with the performance tier ServiceLevelObjectives *[]PerformanceTierServiceLevelObjectives `json:"serviceLevelObjectives,omitempty"` } @@ -1399,6 +1411,101 @@ func (pr ProxyResource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// RecoverableServerProperties the recoverable server's properties. +type RecoverableServerProperties struct { + // LastAvailableBackupDateTime - READ-ONLY; The last available backup date time. + LastAvailableBackupDateTime *string `json:"lastAvailableBackupDateTime,omitempty"` + // ServiceLevelObjective - READ-ONLY; The service level objective + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // Edition - READ-ONLY; Edition of the performance tier. + Edition *string `json:"edition,omitempty"` + // VCore - READ-ONLY; vCore associated with the service level objective + VCore *int32 `json:"vCore,omitempty"` + // HardwareGeneration - READ-ONLY; Hardware generation associated with the service level objective + HardwareGeneration *string `json:"hardwareGeneration,omitempty"` + // Version - READ-ONLY; The PostgreSQL version + Version *string `json:"version,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableServerProperties. +func (rsp RecoverableServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableServerResource a recoverable server resource. +type RecoverableServerResource struct { + autorest.Response `json:"-"` + // RecoverableServerProperties - Resource properties. + *RecoverableServerProperties `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 RecoverableServerResource. +func (rsr RecoverableServerResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsr.RecoverableServerProperties != nil { + objectMap["properties"] = rsr.RecoverableServerProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecoverableServerResource struct. +func (rsr *RecoverableServerResource) 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 recoverableServerProperties RecoverableServerProperties + err = json.Unmarshal(*v, &recoverableServerProperties) + if err != nil { + return err + } + rsr.RecoverableServerProperties = &recoverableServerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rsr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rsr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rsr.Type = &typeVar + } + } + } + + return nil +} + // 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} @@ -2203,6 +2310,49 @@ type ServerListResult struct { Value *[]Server `json:"value,omitempty"` } +// ServerParametersListUpdateConfigurationsFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerParametersListUpdateConfigurationsFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerParametersClient) (ConfigurationListResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerParametersListUpdateConfigurationsFuture) 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 ServerParametersListUpdateConfigurationsFuture.Result. +func (future *ServerParametersListUpdateConfigurationsFuture) result(client ServerParametersClient) (clr ConfigurationListResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersListUpdateConfigurationsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + clr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresql.ServerParametersListUpdateConfigurationsFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if clr.Response.Response, err = future.GetResult(sender); err == nil && clr.Response.Response.StatusCode != http.StatusNoContent { + clr, err = client.ListUpdateConfigurationsResponder(clr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersListUpdateConfigurationsFuture", "Result", clr.Response.Response, "Failure responding to request") + } + } + return +} + // ServerPrivateEndpointConnection a private endpoint connection under a server type ServerPrivateEndpointConnection struct { // ID - READ-ONLY; Resource ID of the Private Endpoint Connection. @@ -3005,6 +3155,172 @@ func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { return nil } +// ServerSecurityAlertPolicyListResult a list of the server's security alert policies. +type ServerSecurityAlertPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerSecurityAlertPolicyListResult. +func (ssaplr ServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ServerSecurityAlertPolicy values. +type ServerSecurityAlertPolicyListResultIterator struct { + i int + page ServerSecurityAlertPolicyListResultPage +} + +// 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 *ServerSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPolicyListResultIterator.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 *ServerSecurityAlertPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerSecurityAlertPolicyListResultIterator) 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 ServerSecurityAlertPolicyListResultIterator) Response() ServerSecurityAlertPolicyListResult { + 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 ServerSecurityAlertPolicyListResultIterator) Value() ServerSecurityAlertPolicy { + if !iter.page.NotDone() { + return ServerSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerSecurityAlertPolicyListResultIterator type. +func NewServerSecurityAlertPolicyListResultIterator(page ServerSecurityAlertPolicyListResultPage) ServerSecurityAlertPolicyListResultIterator { + return ServerSecurityAlertPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ssaplr ServerSecurityAlertPolicyListResult) IsEmpty() bool { + return ssaplr.Value == nil || len(*ssaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ssaplr ServerSecurityAlertPolicyListResult) hasNextLink() bool { + return ssaplr.NextLink != nil && len(*ssaplr.NextLink) != 0 +} + +// serverSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ssaplr ServerSecurityAlertPolicyListResult) serverSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ssaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ssaplr.NextLink))) +} + +// ServerSecurityAlertPolicyListResultPage contains a page of ServerSecurityAlertPolicy values. +type ServerSecurityAlertPolicyListResultPage struct { + fn func(context.Context, ServerSecurityAlertPolicyListResult) (ServerSecurityAlertPolicyListResult, error) + ssaplr ServerSecurityAlertPolicyListResult +} + +// 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 *ServerSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPolicyListResultPage.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.ssaplr) + if err != nil { + return err + } + page.ssaplr = 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 *ServerSecurityAlertPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.ssaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerSecurityAlertPolicyListResultPage) Response() ServerSecurityAlertPolicyListResult { + return page.ssaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerSecurityAlertPolicyListResultPage) Values() []ServerSecurityAlertPolicy { + if page.ssaplr.IsEmpty() { + return nil + } + return *page.ssaplr.Value +} + +// Creates a new instance of the ServerSecurityAlertPolicyListResultPage type. +func NewServerSecurityAlertPolicyListResultPage(cur ServerSecurityAlertPolicyListResult, getNextPage func(context.Context, ServerSecurityAlertPolicyListResult) (ServerSecurityAlertPolicyListResult, error)) ServerSecurityAlertPolicyListResultPage { + return ServerSecurityAlertPolicyListResultPage{ + fn: getNextPage, + ssaplr: cur, + } +} + // ServersRestartFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type ServersRestartFuture struct { diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/postgresqlapi/interfaces.go b/services/postgresql/mgmt/2020-01-01/postgresql/postgresqlapi/interfaces.go index 792a0586a553..39ed98502bfd 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/postgresqlapi/interfaces.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/postgresqlapi/interfaces.go @@ -71,6 +71,13 @@ type ConfigurationsClientAPI interface { var _ ConfigurationsClientAPI = (*postgresql.ConfigurationsClient)(nil) +// ServerParametersClientAPI contains the set of methods on the ServerParametersClient type. +type ServerParametersClientAPI interface { + ListUpdateConfigurations(ctx context.Context, resourceGroupName string, serverName string, value postgresql.ConfigurationListResult) (result postgresql.ServerParametersListUpdateConfigurationsFuture, err error) +} + +var _ ServerParametersClientAPI = (*postgresql.ServerParametersClient)(nil) + // LogFilesClientAPI contains the set of methods on the LogFilesClient type. type LogFilesClientAPI interface { ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.LogFileListResult, err error) @@ -88,6 +95,20 @@ type ServerAdministratorsClientAPI interface { var _ ServerAdministratorsClientAPI = (*postgresql.ServerAdministratorsClient)(nil) +// RecoverableServersClientAPI contains the set of methods on the RecoverableServersClient type. +type RecoverableServersClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.RecoverableServerResource, err error) +} + +var _ RecoverableServersClientAPI = (*postgresql.RecoverableServersClient)(nil) + +// ServerBasedPerformanceTierClientAPI contains the set of methods on the ServerBasedPerformanceTierClient type. +type ServerBasedPerformanceTierClientAPI interface { + List(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.PerformanceTierListResult, err error) +} + +var _ ServerBasedPerformanceTierClientAPI = (*postgresql.ServerBasedPerformanceTierClient)(nil) + // LocationBasedPerformanceTierClientAPI contains the set of methods on the LocationBasedPerformanceTierClient type. type LocationBasedPerformanceTierClientAPI interface { List(ctx context.Context, locationName string) (result postgresql.PerformanceTierListResult, err error) @@ -113,6 +134,8 @@ var _ OperationsClientAPI = (*postgresql.OperationsClient)(nil) type ServerSecurityAlertPoliciesClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters postgresql.ServerSecurityAlertPolicy) (result postgresql.ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) Get(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.ServerSecurityAlertPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.ServerSecurityAlertPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.ServerSecurityAlertPolicyListResultIterator, err error) } var _ ServerSecurityAlertPoliciesClientAPI = (*postgresql.ServerSecurityAlertPoliciesClient)(nil) diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/privateendpointconnections.go b/services/postgresql/mgmt/2020-01-01/postgresql/privateendpointconnections.go index 632d8c2eb4dc..a4564ecc597d 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/privateendpointconnections.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/privateendpointconnections.go @@ -52,8 +52,7 @@ func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Contex 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: false, @@ -150,8 +149,7 @@ func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resou 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.PrivateEndpointConnectionsClient", "Delete", err.Error()) @@ -239,8 +237,7 @@ func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resource 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.PrivateEndpointConnectionsClient", "Get", err.Error()) @@ -326,8 +323,7 @@ func (client PrivateEndpointConnectionsClient) ListByServer(ctx context.Context, 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.PrivateEndpointConnectionsClient", "ListByServer", err.Error()) @@ -457,8 +453,7 @@ func (client PrivateEndpointConnectionsClient) UpdateTags(ctx context.Context, r 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.PrivateEndpointConnectionsClient", "UpdateTags", err.Error()) } diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/privatelinkresources.go b/services/postgresql/mgmt/2020-01-01/postgresql/privatelinkresources.go index 88e967257cd0..821ea3e43a0f 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/privatelinkresources.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/privatelinkresources.go @@ -53,8 +53,7 @@ func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupN 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.PrivateLinkResourcesClient", "Get", err.Error()) @@ -140,8 +139,7 @@ func (client PrivateLinkResourcesClient) ListByServer(ctx context.Context, resou 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.PrivateLinkResourcesClient", "ListByServer", err.Error()) diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/recoverableservers.go b/services/postgresql/mgmt/2020-01-01/postgresql/recoverableservers.go new file mode 100644 index 000000000000..a73a4546376c --- /dev/null +++ b/services/postgresql/mgmt/2020-01-01/postgresql/recoverableservers.go @@ -0,0 +1,120 @@ +package postgresql + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// RecoverableServersClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type RecoverableServersClient struct { + BaseClient +} + +// NewRecoverableServersClient creates an instance of the RecoverableServersClient client. +func NewRecoverableServersClient(subscriptionID string) RecoverableServersClient { + return NewRecoverableServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecoverableServersClientWithBaseURI creates an instance of the RecoverableServersClient 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 NewRecoverableServersClientWithBaseURI(baseURI string, subscriptionID string) RecoverableServersClient { + return RecoverableServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recoverable PostgreSQL Server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client RecoverableServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result RecoverableServerResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableServersClient.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("postgresql.RecoverableServersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.RecoverableServersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresql.RecoverableServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.RecoverableServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoverableServersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBForPostgreSQL/servers/{serverName}/recoverableServers", 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 RecoverableServersClient) 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 RecoverableServersClient) GetResponder(resp *http.Response) (result RecoverableServerResource, 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/postgresql/mgmt/2020-01-01/postgresql/replicas.go b/services/postgresql/mgmt/2020-01-01/postgresql/replicas.go index ba1c5c858c1a..8a8f896bb1c6 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/replicas.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/replicas.go @@ -53,8 +53,7 @@ func (client ReplicasClient) ListByServer(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ReplicasClient", "ListByServer", err.Error()) } @@ -96,7 +95,7 @@ func (client ReplicasClient) ListByServerPreparer(ctx context.Context, resourceG preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Replicas", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/replicas", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/serveradministrators.go b/services/postgresql/mgmt/2020-01-01/postgresql/serveradministrators.go index 1ab895e57c18..40ce4a7a1bad 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/serveradministrators.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/serveradministrators.go @@ -56,8 +56,7 @@ func (client ServerAdministratorsClient) CreateOrUpdate(ctx context.Context, res 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: properties, Constraints: []validation.Constraint{{Target: "properties.ServerAdministratorProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "properties.ServerAdministratorProperties.AdministratorType", Name: validation.Null, Rule: true, Chain: nil}, @@ -100,7 +99,7 @@ func (client ServerAdministratorsClient) CreateOrUpdatePreparer(ctx context.Cont autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Administrators/activeDirectory", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/administrators/activeDirectory", pathParameters), autorest.WithJSON(properties), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) @@ -153,8 +152,7 @@ func (client ServerAdministratorsClient) Delete(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServerAdministratorsClient", "Delete", err.Error()) } @@ -189,7 +187,7 @@ func (client ServerAdministratorsClient) DeletePreparer(ctx context.Context, res preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Administrators/activeDirectory", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/administrators/activeDirectory", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -240,8 +238,7 @@ func (client ServerAdministratorsClient) Get(ctx context.Context, resourceGroupN 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServerAdministratorsClient", "Get", err.Error()) } @@ -283,7 +280,7 @@ func (client ServerAdministratorsClient) GetPreparer(ctx context.Context, resour preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Administrators/activeDirectory", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/administrators/activeDirectory", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -326,8 +323,7 @@ func (client ServerAdministratorsClient) List(ctx context.Context, resourceGroup 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServerAdministratorsClient", "List", err.Error()) } diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/serverbasedperformancetier.go b/services/postgresql/mgmt/2020-01-01/postgresql/serverbasedperformancetier.go new file mode 100644 index 000000000000..7fcf1485cb7f --- /dev/null +++ b/services/postgresql/mgmt/2020-01-01/postgresql/serverbasedperformancetier.go @@ -0,0 +1,120 @@ +package postgresql + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ServerBasedPerformanceTierClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type ServerBasedPerformanceTierClient struct { + BaseClient +} + +// NewServerBasedPerformanceTierClient creates an instance of the ServerBasedPerformanceTierClient client. +func NewServerBasedPerformanceTierClient(subscriptionID string) ServerBasedPerformanceTierClient { + return NewServerBasedPerformanceTierClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerBasedPerformanceTierClientWithBaseURI creates an instance of the ServerBasedPerformanceTierClient 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 NewServerBasedPerformanceTierClientWithBaseURI(baseURI string, subscriptionID string) ServerBasedPerformanceTierClient { + return ServerBasedPerformanceTierClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list all the performance tiers for a PostgreSQL server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServerBasedPerformanceTierClient) List(ctx context.Context, resourceGroupName string, serverName string) (result PerformanceTierListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBasedPerformanceTierClient.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("postgresql.ServerBasedPerformanceTierClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerBasedPerformanceTierClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresql.ServerBasedPerformanceTierClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerBasedPerformanceTierClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServerBasedPerformanceTierClient) ListPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBForPostgreSQL/servers/{serverName}/performanceTiers", 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 ServerBasedPerformanceTierClient) 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 ServerBasedPerformanceTierClient) ListResponder(resp *http.Response) (result PerformanceTierListResult, 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/postgresql/mgmt/2020-01-01/postgresql/serverkeys.go b/services/postgresql/mgmt/2020-01-01/postgresql/serverkeys.go index 5d63a01aa61f..3f917e7a1688 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/serverkeys.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/serverkeys.go @@ -58,8 +58,7 @@ func (client ServerKeysClient) CreateOrUpdate(ctx context.Context, serverName st 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServerKeysClient", "CreateOrUpdate", err.Error()) } @@ -151,8 +150,7 @@ func (client ServerKeysClient) Delete(ctx context.Context, serverName string, ke 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServerKeysClient", "Delete", err.Error()) } @@ -238,8 +236,7 @@ func (client ServerKeysClient) Get(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.ServerKeysClient", "Get", err.Error()) @@ -327,8 +324,7 @@ func (client ServerKeysClient) List(ctx context.Context, resourceGroupName strin 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServerKeysClient", "List", err.Error()) } diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/serverparameters.go b/services/postgresql/mgmt/2020-01-01/postgresql/serverparameters.go new file mode 100644 index 000000000000..d21b7ff6997a --- /dev/null +++ b/services/postgresql/mgmt/2020-01-01/postgresql/serverparameters.go @@ -0,0 +1,125 @@ +package postgresql + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ServerParametersClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type ServerParametersClient struct { + BaseClient +} + +// NewServerParametersClient creates an instance of the ServerParametersClient client. +func NewServerParametersClient(subscriptionID string) ServerParametersClient { + return NewServerParametersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerParametersClientWithBaseURI creates an instance of the ServerParametersClient 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 NewServerParametersClientWithBaseURI(baseURI string, subscriptionID string) ServerParametersClient { + return ServerParametersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListUpdateConfigurations update a list of configurations in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// value - the parameters for updating a list of server configuration. +func (client ServerParametersClient) ListUpdateConfigurations(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult) (result ServerParametersListUpdateConfigurationsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerParametersClient.ListUpdateConfigurations") + 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: 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("postgresql.ServerParametersClient", "ListUpdateConfigurations", err.Error()) + } + + req, err := client.ListUpdateConfigurationsPreparer(ctx, resourceGroupName, serverName, value) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersClient", "ListUpdateConfigurations", nil, "Failure preparing request") + return + } + + result, err = client.ListUpdateConfigurationsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersClient", "ListUpdateConfigurations", nil, "Failure sending request") + return + } + + return +} + +// ListUpdateConfigurationsPreparer prepares the ListUpdateConfigurations request. +func (client ServerParametersClient) ListUpdateConfigurationsPreparer(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBForPostgreSQL/servers/{serverName}/updateConfigurations", pathParameters), + autorest.WithJSON(value), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUpdateConfigurationsSender sends the ListUpdateConfigurations request. The method will close the +// http.Response Body if it receives an error. +func (client ServerParametersClient) ListUpdateConfigurationsSender(req *http.Request) (future ServerParametersListUpdateConfigurationsFuture, 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 +} + +// ListUpdateConfigurationsResponder handles the response to the ListUpdateConfigurations request. The method always +// closes the http.Response Body. +func (client ServerParametersClient) ListUpdateConfigurationsResponder(resp *http.Response) (result ConfigurationListResult, 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/postgresql/mgmt/2020-01-01/postgresql/servers.go b/services/postgresql/mgmt/2020-01-01/postgresql/servers.go index bc0a3487876c..2dcc01e1ed7b 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/servers.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/servers.go @@ -54,8 +54,7 @@ func (client ServersClient) Create(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {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}, @@ -151,8 +150,7 @@ func (client ServersClient) Delete(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "Delete", err.Error()) } @@ -238,8 +236,7 @@ func (client ServersClient) Get(ctx context.Context, resourceGroupName string, s 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "Get", err.Error()) } @@ -400,8 +397,7 @@ func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "ListByResourceGroup", err.Error()) } @@ -485,8 +481,7 @@ func (client ServersClient) Restart(ctx context.Context, resourceGroupName strin 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "Restart", err.Error()) } @@ -574,8 +569,7 @@ func (client ServersClient) Update(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresql.ServersClient", "Update", err.Error()) } diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/serversecurityalertpolicies.go b/services/postgresql/mgmt/2020-01-01/postgresql/serversecurityalertpolicies.go index ecee5a3f232c..277082f2e2fe 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/serversecurityalertpolicies.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/serversecurityalertpolicies.go @@ -53,8 +53,7 @@ func (client ServerSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Conte 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", err.Error()) @@ -144,8 +143,7 @@ func (client ServerSecurityAlertPoliciesClient) Get(ctx context.Context, resourc 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.ServerSecurityAlertPoliciesClient", "Get", err.Error()) @@ -212,3 +210,130 @@ func (client ServerSecurityAlertPoliciesClient) GetResponder(resp *http.Response result.Response = autorest.Response{Response: resp} return } + +// ListByServer get the server's threat detection policies. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServerSecurityAlertPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.ssaplr.Response.Response != nil { + sc = result.ssaplr.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("postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.ssaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.ssaplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.ssaplr.hasNextLink() && result.ssaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerSecurityAlertPoliciesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBforPostgreSQL/servers/{serverName}/securityAlertPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) ListByServerResponder(resp *http.Response) (result ServerSecurityAlertPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerSecurityAlertPoliciesClient) listByServerNextResults(ctx context.Context, lastResults ServerSecurityAlertPolicyListResult) (result ServerSecurityAlertPolicyListResult, err error) { + req, err := lastResults.serverSecurityAlertPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerSecurityAlertPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/postgresql/mgmt/2020-01-01/postgresql/virtualnetworkrules.go b/services/postgresql/mgmt/2020-01-01/postgresql/virtualnetworkrules.go index 243cc9c356f1..46dd48784d6f 100644 --- a/services/postgresql/mgmt/2020-01-01/postgresql/virtualnetworkrules.go +++ b/services/postgresql/mgmt/2020-01-01/postgresql/virtualnetworkrules.go @@ -54,8 +54,7 @@ func (client VirtualNetworkRulesClient) CreateOrUpdate(ctx context.Context, reso 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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: parameters, @@ -149,8 +148,7 @@ func (client VirtualNetworkRulesClient) Delete(ctx context.Context, resourceGrou 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.VirtualNetworkRulesClient", "Delete", err.Error()) @@ -238,8 +236,7 @@ func (client VirtualNetworkRulesClient) Get(ctx context.Context, resourceGroupNa 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.VirtualNetworkRulesClient", "Get", err.Error()) @@ -325,8 +322,7 @@ func (client VirtualNetworkRulesClient) ListByServer(ctx context.Context, resour 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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("postgresql.VirtualNetworkRulesClient", "ListByServer", err.Error()) diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/CHANGELOG.md b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/_meta.json b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/_meta.json new file mode 100644 index 000000000000..d5f292c1a698 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "c7616be749e60dc269e2bb50800f06dbca065098", + "readme": "/_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", + "tag": "package-flexibleserver-2021-06", + "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-flexibleserver-2021-06 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/checknameavailability.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/checknameavailability.go new file mode 100644 index 000000000000..f8187aaf040e --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/checknameavailability.go @@ -0,0 +1,118 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// CheckNameAvailabilityClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type CheckNameAvailabilityClient struct { + BaseClient +} + +// NewCheckNameAvailabilityClient creates an instance of the CheckNameAvailabilityClient client. +func NewCheckNameAvailabilityClient(subscriptionID string) CheckNameAvailabilityClient { + return NewCheckNameAvailabilityClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCheckNameAvailabilityClientWithBaseURI creates an instance of the CheckNameAvailabilityClient 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 NewCheckNameAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckNameAvailabilityClient { + return CheckNameAvailabilityClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute check the availability of name for resource +// Parameters: +// nameAvailabilityRequest - the required parameters for checking if resource name is available. +func (client CheckNameAvailabilityClient) Execute(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest) (result NameAvailability, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CheckNameAvailabilityClient.Execute") + 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: nameAvailabilityRequest, + Constraints: []validation.Constraint{{Target: "nameAvailabilityRequest.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", err.Error()) + } + + req, err := client.ExecutePreparer(ctx, nameAvailabilityRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client CheckNameAvailabilityClient) ExecutePreparer(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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}/providers/Microsoft.DBForPostgreSql/checkNameAvailability", pathParameters), + autorest.WithJSON(nameAvailabilityRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client CheckNameAvailabilityClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client CheckNameAvailabilityClient) ExecuteResponder(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 +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/client.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/client.go new file mode 100644 index 000000000000..a3b40a7fc77a --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/client.go @@ -0,0 +1,43 @@ +// Package postgresqlflexibleservers implements the Azure ARM Postgresqlflexibleservers service API version 2021-06-01. +// +// The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL +// resources including servers, databases, firewall rules, VNET rules, security alert policies, log files and +// configurations with new business model. +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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 Postgresqlflexibleservers + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Postgresqlflexibleservers. +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/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/configurations.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/configurations.go new file mode 100644 index 000000000000..5b2fa4b70660 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/configurations.go @@ -0,0 +1,434 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ConfigurationsClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type ConfigurationsClient struct { + BaseClient +} + +// NewConfigurationsClient creates an instance of the ConfigurationsClient client. +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return NewConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationsClientWithBaseURI creates an instance of the ConfigurationsClient 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 NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return ConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets information about a configuration of server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.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("postgresqlflexibleservers.ConfigurationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/configurations/{configurationName}", 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 ConfigurationsClient) 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 ConfigurationsClient) GetResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the configurations in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.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("postgresqlflexibleservers.ConfigurationsClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.clr.hasNextLink() && result.clr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ConfigurationsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/configurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) ListByServerResponder(resp *http.Response) (result ConfigurationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ConfigurationsClient) listByServerNextResults(ctx context.Context, lastResults ConfigurationListResult) (result ConfigurationListResult, err error) { + req, err := lastResults.configurationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConfigurationsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Put updates a configuration of a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +// parameters - the required parameters for updating a server configuration. +func (client ConfigurationsClient) Put(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsPutFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Put") + 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: 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("postgresqlflexibleservers.ConfigurationsClient", "Put", err.Error()) + } + + req, err := client.PutPreparer(ctx, resourceGroupName, serverName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Put", nil, "Failure preparing request") + return + } + + result, err = client.PutSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Put", nil, "Failure sending request") + return + } + + return +} + +// PutPreparer prepares the Put request. +func (client ConfigurationsClient) PutPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.DBForPostgreSql/flexibleServers/{serverName}/configurations/{configurationName}", pathParameters), + autorest.WithJSON(parameters), + 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 ConfigurationsClient) PutSender(req *http.Request) (future ConfigurationsPutFuture, 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 +} + +// PutResponder handles the response to the Put request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) PutResponder(resp *http.Response) (result Configuration, 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 a configuration of a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +// parameters - the required parameters for updating a server configuration. +func (client ConfigurationsClient) Update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.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: 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("postgresqlflexibleservers.ConfigurationsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.DBForPostgreSql/flexibleServers/{serverName}/configurations/{configurationName}", 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 ConfigurationsClient) UpdateSender(req *http.Request) (future ConfigurationsUpdateFuture, 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 ConfigurationsClient) UpdateResponder(resp *http.Response) (result Configuration, 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/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/databases.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/databases.go new file mode 100644 index 000000000000..6e9a51c8dc71 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/databases.go @@ -0,0 +1,429 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// DatabasesClient is the the Microsoft Azure management API provides create, read, update, and delete functionality +// for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, +// log files and configurations with new business model. +type DatabasesClient struct { + BaseClient +} + +// NewDatabasesClient creates an instance of the DatabasesClient client. +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient 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 NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the required parameters for creating or updating a database. +func (client DatabasesClient) Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (result DatabasesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Create") + 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: 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("postgresqlflexibleservers.DatabasesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DatabasesClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.DBForPostgreSql/flexibleServers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithJSON(parameters), + 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 DatabasesClient) CreateSender(req *http.Request) (future DatabasesCreateFuture, 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 +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateResponder(resp *http.Response) (result Database, 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 a database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.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: 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("postgresqlflexibleservers.DatabasesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/databases/{databaseName}", 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 DatabasesClient) DeleteSender(req *http.Request) (future DatabasesDeleteFuture, 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 DatabasesClient) 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 gets information about a database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.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("postgresqlflexibleservers.DatabasesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/databases/{databaseName}", 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 DatabasesClient) 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 DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the databases in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.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("postgresqlflexibleservers.DatabasesClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client DatabasesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listByServerNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/enums.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/enums.go new file mode 100644 index 000000000000..765705b15031 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/enums.go @@ -0,0 +1,236 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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. + +// ConfigurationDataType enumerates the values for configuration data type. +type ConfigurationDataType string + +const ( + // Boolean ... + Boolean ConfigurationDataType = "Boolean" + // Enumeration ... + Enumeration ConfigurationDataType = "Enumeration" + // Integer ... + Integer ConfigurationDataType = "Integer" + // Numeric ... + Numeric ConfigurationDataType = "Numeric" +) + +// PossibleConfigurationDataTypeValues returns an array of possible values for the ConfigurationDataType const type. +func PossibleConfigurationDataTypeValues() []ConfigurationDataType { + return []ConfigurationDataType{Boolean, Enumeration, Integer, Numeric} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// CreateMode enumerates the values for create mode. +type CreateMode string + +const ( + // Create ... + Create CreateMode = "Create" + // Default ... + Default CreateMode = "Default" + // PointInTimeRestore ... + PointInTimeRestore CreateMode = "PointInTimeRestore" + // Update ... + Update CreateMode = "Update" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{Create, Default, PointInTimeRestore, Update} +} + +// CreateModeForUpdate enumerates the values for create mode for update. +type CreateModeForUpdate string + +const ( + // CreateModeForUpdateDefault ... + CreateModeForUpdateDefault CreateModeForUpdate = "Default" + // CreateModeForUpdateUpdate ... + CreateModeForUpdateUpdate CreateModeForUpdate = "Update" +) + +// PossibleCreateModeForUpdateValues returns an array of possible values for the CreateModeForUpdate const type. +func PossibleCreateModeForUpdateValues() []CreateModeForUpdate { + return []CreateModeForUpdate{CreateModeForUpdateDefault, CreateModeForUpdateUpdate} +} + +// GeoRedundantBackupEnum enumerates the values for geo redundant backup enum. +type GeoRedundantBackupEnum string + +const ( + // Disabled ... + Disabled GeoRedundantBackupEnum = "Disabled" + // Enabled ... + Enabled GeoRedundantBackupEnum = "Enabled" +) + +// PossibleGeoRedundantBackupEnumValues returns an array of possible values for the GeoRedundantBackupEnum const type. +func PossibleGeoRedundantBackupEnumValues() []GeoRedundantBackupEnum { + return []GeoRedundantBackupEnum{Disabled, Enabled} +} + +// HighAvailabilityMode enumerates the values for high availability mode. +type HighAvailabilityMode string + +const ( + // HighAvailabilityModeDisabled ... + HighAvailabilityModeDisabled HighAvailabilityMode = "Disabled" + // HighAvailabilityModeZoneRedundant ... + HighAvailabilityModeZoneRedundant HighAvailabilityMode = "ZoneRedundant" +) + +// PossibleHighAvailabilityModeValues returns an array of possible values for the HighAvailabilityMode const type. +func PossibleHighAvailabilityModeValues() []HighAvailabilityMode { + return []HighAvailabilityMode{HighAvailabilityModeDisabled, HighAvailabilityModeZoneRedundant} +} + +// OperationOrigin enumerates the values for operation origin. +type OperationOrigin string + +const ( + // OperationOriginNotSpecified ... + OperationOriginNotSpecified OperationOrigin = "NotSpecified" + // OperationOriginSystem ... + OperationOriginSystem OperationOrigin = "system" + // OperationOriginUser ... + OperationOriginUser OperationOrigin = "user" +) + +// PossibleOperationOriginValues returns an array of possible values for the OperationOrigin const type. +func PossibleOperationOriginValues() []OperationOrigin { + return []OperationOrigin{OperationOriginNotSpecified, OperationOriginSystem, OperationOriginUser} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // SystemAssigned ... + SystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{SystemAssigned} +} + +// ServerHAState enumerates the values for server ha state. +type ServerHAState string + +const ( + // CreatingStandby ... + CreatingStandby ServerHAState = "CreatingStandby" + // FailingOver ... + FailingOver ServerHAState = "FailingOver" + // Healthy ... + Healthy ServerHAState = "Healthy" + // NotEnabled ... + NotEnabled ServerHAState = "NotEnabled" + // RemovingStandby ... + RemovingStandby ServerHAState = "RemovingStandby" + // ReplicatingData ... + ReplicatingData ServerHAState = "ReplicatingData" +) + +// PossibleServerHAStateValues returns an array of possible values for the ServerHAState const type. +func PossibleServerHAStateValues() []ServerHAState { + return []ServerHAState{CreatingStandby, FailingOver, Healthy, NotEnabled, RemovingStandby, ReplicatingData} +} + +// ServerPublicNetworkAccessState enumerates the values for server public network access state. +type ServerPublicNetworkAccessState string + +const ( + // ServerPublicNetworkAccessStateDisabled ... + ServerPublicNetworkAccessStateDisabled ServerPublicNetworkAccessState = "Disabled" + // ServerPublicNetworkAccessStateEnabled ... + ServerPublicNetworkAccessStateEnabled ServerPublicNetworkAccessState = "Enabled" +) + +// PossibleServerPublicNetworkAccessStateValues returns an array of possible values for the ServerPublicNetworkAccessState const type. +func PossibleServerPublicNetworkAccessStateValues() []ServerPublicNetworkAccessState { + return []ServerPublicNetworkAccessState{ServerPublicNetworkAccessStateDisabled, ServerPublicNetworkAccessStateEnabled} +} + +// ServerState enumerates the values for server state. +type ServerState string + +const ( + // ServerStateDisabled ... + ServerStateDisabled ServerState = "Disabled" + // ServerStateDropping ... + ServerStateDropping ServerState = "Dropping" + // ServerStateReady ... + ServerStateReady ServerState = "Ready" + // ServerStateStarting ... + ServerStateStarting ServerState = "Starting" + // ServerStateStopped ... + ServerStateStopped ServerState = "Stopped" + // ServerStateStopping ... + ServerStateStopping ServerState = "Stopping" + // ServerStateUpdating ... + ServerStateUpdating ServerState = "Updating" +) + +// PossibleServerStateValues returns an array of possible values for the ServerState const type. +func PossibleServerStateValues() []ServerState { + return []ServerState{ServerStateDisabled, ServerStateDropping, ServerStateReady, ServerStateStarting, ServerStateStopped, ServerStateStopping, ServerStateUpdating} +} + +// ServerVersion enumerates the values for server version. +type ServerVersion string + +const ( + // OneOne ... + OneOne ServerVersion = "11" + // OneThree ... + OneThree ServerVersion = "13" + // OneTwo ... + OneTwo ServerVersion = "12" +) + +// PossibleServerVersionValues returns an array of possible values for the ServerVersion const type. +func PossibleServerVersionValues() []ServerVersion { + return []ServerVersion{OneOne, OneThree, OneTwo} +} + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // Burstable ... + Burstable SkuTier = "Burstable" + // GeneralPurpose ... + GeneralPurpose SkuTier = "GeneralPurpose" + // MemoryOptimized ... + MemoryOptimized SkuTier = "MemoryOptimized" +) + +// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. +func PossibleSkuTierValues() []SkuTier { + return []SkuTier{Burstable, GeneralPurpose, MemoryOptimized} +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/firewallrules.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/firewallrules.go new file mode 100644 index 000000000000..0e631a40aa53 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/firewallrules.go @@ -0,0 +1,436 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// FirewallRulesClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type FirewallRulesClient struct { + BaseClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the FirewallRulesClient 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 NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new firewall rule or updates an existing firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +// parameters - the required parameters for creating or updating a firewall rule. +func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (result FirewallRulesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.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: 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: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Pattern, Rule: `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`, Chain: nil}}}, + {Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Pattern, Rule: `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, firewallRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (future FirewallRulesCreateOrUpdateFuture, 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 FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, 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 a PostgreSQL server firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRulesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.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: 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("postgresqlflexibleservers.FirewallRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) DeleteSender(req *http.Request) (future FirewallRulesDeleteFuture, 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 FirewallRulesClient) 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 list all the firewall rules in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.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("postgresqlflexibleservers.FirewallRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) 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 FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the firewall rules in a given PostgreSQL server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.frlr.Response.Response != nil { + sc = result.frlr.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("postgresqlflexibleservers.FirewallRulesClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.frlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.frlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.frlr.hasNextLink() && result.frlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FirewallRulesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client FirewallRulesClient) listByServerNextResults(ctx context.Context, lastResults FirewallRuleListResult) (result FirewallRuleListResult, err error) { + req, err := lastResults.firewallRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client FirewallRulesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/getprivatednszonesuffix.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/getprivatednszonesuffix.go new file mode 100644 index 000000000000..0c0fe2ef390c --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/getprivatednszonesuffix.go @@ -0,0 +1,101 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// GetPrivateDNSZoneSuffixClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type GetPrivateDNSZoneSuffixClient struct { + BaseClient +} + +// NewGetPrivateDNSZoneSuffixClient creates an instance of the GetPrivateDNSZoneSuffixClient client. +func NewGetPrivateDNSZoneSuffixClient(subscriptionID string) GetPrivateDNSZoneSuffixClient { + return NewGetPrivateDNSZoneSuffixClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGetPrivateDNSZoneSuffixClientWithBaseURI creates an instance of the GetPrivateDNSZoneSuffixClient 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 NewGetPrivateDNSZoneSuffixClientWithBaseURI(baseURI string, subscriptionID string) GetPrivateDNSZoneSuffixClient { + return GetPrivateDNSZoneSuffixClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute get private DNS zone suffix in the cloud +func (client GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context) (result String, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GetPrivateDNSZoneSuffixClient.Execute") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ExecutePreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client GetPrivateDNSZoneSuffixClient) ExecutePreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DBForPostgreSql/getPrivateDnsZoneSuffix"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client GetPrivateDNSZoneSuffixClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client GetPrivateDNSZoneSuffixClient) ExecuteResponder(resp *http.Response) (result String, 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/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/locationbasedcapabilities.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/locationbasedcapabilities.go new file mode 100644 index 000000000000..65d7191dcb73 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/locationbasedcapabilities.go @@ -0,0 +1,157 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// LocationBasedCapabilitiesClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type LocationBasedCapabilitiesClient struct { + BaseClient +} + +// NewLocationBasedCapabilitiesClient creates an instance of the LocationBasedCapabilitiesClient client. +func NewLocationBasedCapabilitiesClient(subscriptionID string) LocationBasedCapabilitiesClient { + return NewLocationBasedCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLocationBasedCapabilitiesClientWithBaseURI creates an instance of the LocationBasedCapabilitiesClient 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 NewLocationBasedCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) LocationBasedCapabilitiesClient { + return LocationBasedCapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute get capabilities at specified location in a given subscription. +// Parameters: +// locationName - the name of the location. +func (client LocationBasedCapabilitiesClient) Execute(ctx context.Context, locationName string) (result CapabilitiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationBasedCapabilitiesClient.Execute") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.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("postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", err.Error()) + } + + result.fn = client.executeNextResults + req, err := client.ExecutePreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", resp, "Failure sending request") + return + } + + result.clr, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", resp, "Failure responding to request") + return + } + if result.clr.hasNextLink() && result.clr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client LocationBasedCapabilitiesClient) ExecutePreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/locations/{locationName}/capabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client LocationBasedCapabilitiesClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client LocationBasedCapabilitiesClient) ExecuteResponder(resp *http.Response) (result CapabilitiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// executeNextResults retrieves the next set of results, if any. +func (client LocationBasedCapabilitiesClient) executeNextResults(ctx context.Context, lastResults CapabilitiesListResult) (result CapabilitiesListResult, err error) { + req, err := lastResults.capabilitiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "executeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "executeNextResults", resp, "Failure sending next results request") + } + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "executeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ExecuteComplete enumerates all values, automatically crossing page boundaries as required. +func (client LocationBasedCapabilitiesClient) ExecuteComplete(ctx context.Context, locationName string) (result CapabilitiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationBasedCapabilitiesClient.Execute") + 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.Execute(ctx, locationName) + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/models.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/models.go new file mode 100644 index 000000000000..bfbab9bc7e76 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/models.go @@ -0,0 +1,2533 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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/postgresql/mgmt/2021-06-01/postgresqlflexibleservers" + +// 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) +} + +// Backup backup properties of a server +type Backup struct { + // BackupRetentionDays - Backup retention days for the server. + BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"` + // GeoRedundantBackup - A value indicating whether Geo-Redundant backup is enabled on the server. Possible values include: 'Enabled', 'Disabled' + GeoRedundantBackup GeoRedundantBackupEnum `json:"geoRedundantBackup,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest restore point time (ISO8601 format) for server. + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for Backup. +func (b Backup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if b.BackupRetentionDays != nil { + objectMap["backupRetentionDays"] = b.BackupRetentionDays + } + if b.GeoRedundantBackup != "" { + objectMap["geoRedundantBackup"] = b.GeoRedundantBackup + } + return json.Marshal(objectMap) +} + +// CapabilitiesListResult location capability +type CapabilitiesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; A list of supported capabilities. + Value *[]CapabilityProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for CapabilitiesListResult. +func (clr CapabilitiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CapabilitiesListResultIterator provides access to a complete listing of CapabilityProperties values. +type CapabilitiesListResultIterator struct { + i int + page CapabilitiesListResultPage +} + +// 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 *CapabilitiesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesListResultIterator.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 *CapabilitiesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CapabilitiesListResultIterator) 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 CapabilitiesListResultIterator) Response() CapabilitiesListResult { + 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 CapabilitiesListResultIterator) Value() CapabilityProperties { + if !iter.page.NotDone() { + return CapabilityProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CapabilitiesListResultIterator type. +func NewCapabilitiesListResultIterator(page CapabilitiesListResultPage) CapabilitiesListResultIterator { + return CapabilitiesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CapabilitiesListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (clr CapabilitiesListResult) hasNextLink() bool { + return clr.NextLink != nil && len(*clr.NextLink) != 0 +} + +// capabilitiesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CapabilitiesListResult) capabilitiesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !clr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CapabilitiesListResultPage contains a page of CapabilityProperties values. +type CapabilitiesListResultPage struct { + fn func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error) + clr CapabilitiesListResult +} + +// 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 *CapabilitiesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesListResultPage.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.clr) + if err != nil { + return err + } + page.clr = 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 *CapabilitiesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CapabilitiesListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CapabilitiesListResultPage) Response() CapabilitiesListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CapabilitiesListResultPage) Values() []CapabilityProperties { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the CapabilitiesListResultPage type. +func NewCapabilitiesListResultPage(cur CapabilitiesListResult, getNextPage func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error)) CapabilitiesListResultPage { + return CapabilitiesListResultPage{ + fn: getNextPage, + clr: cur, + } +} + +// CapabilityProperties location capabilities. +type CapabilityProperties struct { + // Zone - READ-ONLY; zone name + Zone *string `json:"zone,omitempty"` + // GeoBackupSupported - READ-ONLY; A value indicating whether a new server in this region can have geo-backups to paired region. + GeoBackupSupported *bool `json:"geoBackupSupported,omitempty"` + // ZoneRedundantHaSupported - READ-ONLY; A value indicating whether a new server in this region can support multi zone HA. + ZoneRedundantHaSupported *bool `json:"zoneRedundantHaSupported,omitempty"` + // ZoneRedundantHaAndGeoBackupSupported - READ-ONLY; A value indicating whether a new server in this region can have geo-backups to paired region. + ZoneRedundantHaAndGeoBackupSupported *bool `json:"zoneRedundantHaAndGeoBackupSupported,omitempty"` + // SupportedFlexibleServerEditions - READ-ONLY + SupportedFlexibleServerEditions *[]FlexibleServerEditionCapability `json:"supportedFlexibleServerEditions,omitempty"` + // SupportedHyperscaleNodeEditions - READ-ONLY + SupportedHyperscaleNodeEditions *[]HyperscaleNodeEditionCapability `json:"supportedHyperscaleNodeEditions,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for CapabilityProperties. +func (cp CapabilityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CloudError an error response from the Batch service. +type CloudError struct { + Error *ErrorResponse `json:"error,omitempty"` +} + +// Configuration represents a Configuration. +type Configuration struct { + autorest.Response `json:"-"` + // ConfigurationProperties - The properties of a configuration. + *ConfigurationProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,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 Configuration. +func (c Configuration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ConfigurationProperties != nil { + objectMap["properties"] = c.ConfigurationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Configuration struct. +func (c *Configuration) 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 configurationProperties ConfigurationProperties + err = json.Unmarshal(*v, &configurationProperties) + if err != nil { + return err + } + c.ConfigurationProperties = &configurationProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + c.SystemData = &systemData + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ConfigurationListResult a list of server configurations. +type ConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - The list of server configurations. + Value *[]Configuration `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConfigurationListResultIterator provides access to a complete listing of Configuration values. +type ConfigurationListResultIterator struct { + i int + page ConfigurationListResultPage +} + +// 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 *ConfigurationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultIterator.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 *ConfigurationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConfigurationListResultIterator) 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 ConfigurationListResultIterator) Response() ConfigurationListResult { + 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 ConfigurationListResultIterator) Value() Configuration { + if !iter.page.NotDone() { + return Configuration{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ConfigurationListResultIterator type. +func NewConfigurationListResultIterator(page ConfigurationListResultPage) ConfigurationListResultIterator { + return ConfigurationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr ConfigurationListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (clr ConfigurationListResult) hasNextLink() bool { + return clr.NextLink != nil && len(*clr.NextLink) != 0 +} + +// configurationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr ConfigurationListResult) configurationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !clr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// ConfigurationListResultPage contains a page of Configuration values. +type ConfigurationListResultPage struct { + fn func(context.Context, ConfigurationListResult) (ConfigurationListResult, error) + clr ConfigurationListResult +} + +// 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 *ConfigurationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultPage.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.clr) + if err != nil { + return err + } + page.clr = 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 *ConfigurationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConfigurationListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConfigurationListResultPage) Response() ConfigurationListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConfigurationListResultPage) Values() []Configuration { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the ConfigurationListResultPage type. +func NewConfigurationListResultPage(cur ConfigurationListResult, getNextPage func(context.Context, ConfigurationListResult) (ConfigurationListResult, error)) ConfigurationListResultPage { + return ConfigurationListResultPage{ + fn: getNextPage, + clr: cur, + } +} + +// ConfigurationProperties the properties of a configuration. +type ConfigurationProperties struct { + // Value - Value of the configuration. + Value *string `json:"value,omitempty"` + // Description - READ-ONLY; Description of the configuration. + Description *string `json:"description,omitempty"` + // DefaultValue - READ-ONLY; Default value of the configuration. + DefaultValue *string `json:"defaultValue,omitempty"` + // DataType - READ-ONLY; Data type of the configuration. Possible values include: 'Boolean', 'Numeric', 'Integer', 'Enumeration' + DataType ConfigurationDataType `json:"dataType,omitempty"` + // AllowedValues - READ-ONLY; Allowed values of the configuration. + AllowedValues *string `json:"allowedValues,omitempty"` + // Source - Source of the configuration. + Source *string `json:"source,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationProperties. +func (cp ConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.Value != nil { + objectMap["value"] = cp.Value + } + if cp.Source != nil { + objectMap["source"] = cp.Source + } + return json.Marshal(objectMap) +} + +// ConfigurationsPutFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConfigurationsPutFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ConfigurationsClient) (Configuration, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ConfigurationsPutFuture) 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 ConfigurationsPutFuture.Result. +func (future *ConfigurationsPutFuture) result(client ConfigurationsClient) (c Configuration, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsPutFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + c.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ConfigurationsPutFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.PutResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsPutFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ConfigurationsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConfigurationsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ConfigurationsClient) (Configuration, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ConfigurationsUpdateFuture) 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 ConfigurationsUpdateFuture.Result. +func (future *ConfigurationsUpdateFuture) result(client ConfigurationsClient) (c Configuration, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + c.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ConfigurationsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.UpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// Database represents a Database. +type Database struct { + autorest.Response `json:"-"` + // DatabaseProperties - The properties of a database. + *DatabaseProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,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 Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Database struct. +func (d *Database) 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 databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + d.DatabaseProperties = &databaseProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + d.SystemData = &systemData + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseListResult a List of databases. +type DatabaseListResult struct { + autorest.Response `json:"-"` + // Value - The list of databases housed in a server + Value *[]Database `json:"value,omitempty"` + // NextLink - The link used to get the next page of databases. + NextLink *string `json:"nextLink,omitempty"` +} + +// DatabaseListResultIterator provides access to a complete listing of Database values. +type DatabaseListResultIterator struct { + i int + page DatabaseListResultPage +} + +// 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 *DatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultIterator.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 *DatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseListResultIterator) 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 DatabaseListResultIterator) Response() DatabaseListResult { + 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 DatabaseListResultIterator) Value() Database { + if !iter.page.NotDone() { + return Database{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseListResultIterator type. +func NewDatabaseListResultIterator(page DatabaseListResultPage) DatabaseListResultIterator { + return DatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DatabaseListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dlr DatabaseListResult) hasNextLink() bool { + return dlr.NextLink != nil && len(*dlr.NextLink) != 0 +} + +// databaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DatabaseListResult) databaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DatabaseListResultPage contains a page of Database values. +type DatabaseListResultPage struct { + fn func(context.Context, DatabaseListResult) (DatabaseListResult, error) + dlr DatabaseListResult +} + +// 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 *DatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultPage.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.dlr) + if err != nil { + return err + } + page.dlr = 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 *DatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseListResultPage) Response() DatabaseListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseListResultPage) Values() []Database { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DatabaseListResultPage type. +func NewDatabaseListResultPage(cur DatabaseListResult, getNextPage func(context.Context, DatabaseListResult) (DatabaseListResult, error)) DatabaseListResultPage { + return DatabaseListResultPage{ + fn: getNextPage, + dlr: cur, + } +} + +// DatabaseProperties the properties of a database. +type DatabaseProperties struct { + // Charset - The charset of the database. + Charset *string `json:"charset,omitempty"` + // Collation - The collation of the database. + Collation *string `json:"collation,omitempty"` +} + +// DatabasesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesCreateFuture) 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 DatabasesCreateFuture.Result. +func (future *DatabasesCreateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.DatabasesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesCreateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesDeleteFuture) 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 DatabasesDeleteFuture.Result. +func (future *DatabasesDeleteFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.DatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DelegatedSubnetUsage delegated subnet usage data. +type DelegatedSubnetUsage struct { + // SubnetName - READ-ONLY; name of the subnet + SubnetName *string `json:"subnetName,omitempty"` + // Usage - READ-ONLY; Number of used delegated subnets + Usage *int64 `json:"usage,omitempty"` +} + +// MarshalJSON is the custom marshaler for DelegatedSubnetUsage. +func (dsu DelegatedSubnetUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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) +} + +// 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 { + // 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 *[]ErrorResponse `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorResponse. +func (er ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// FirewallRule represents a server firewall rule. +type FirewallRule struct { + autorest.Response `json:"-"` + // FirewallRuleProperties - The properties of a firewall rule. + *FirewallRuleProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,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 FirewallRule. +func (fr FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fr.FirewallRuleProperties != nil { + objectMap["properties"] = fr.FirewallRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FirewallRule struct. +func (fr *FirewallRule) 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 firewallRuleProperties FirewallRuleProperties + err = json.Unmarshal(*v, &firewallRuleProperties) + if err != nil { + return err + } + fr.FirewallRuleProperties = &firewallRuleProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + fr.SystemData = &systemData + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fr.Type = &typeVar + } + } + } + + return nil +} + +// FirewallRuleListResult a list of firewall rules. +type FirewallRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of firewall rules in a server. + Value *[]FirewallRule `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// FirewallRuleListResultIterator provides access to a complete listing of FirewallRule values. +type FirewallRuleListResultIterator struct { + i int + page FirewallRuleListResultPage +} + +// 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 *FirewallRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultIterator.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 *FirewallRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter FirewallRuleListResultIterator) 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 FirewallRuleListResultIterator) Response() FirewallRuleListResult { + 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 FirewallRuleListResultIterator) Value() FirewallRule { + if !iter.page.NotDone() { + return FirewallRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the FirewallRuleListResultIterator type. +func NewFirewallRuleListResultIterator(page FirewallRuleListResultPage) FirewallRuleListResultIterator { + return FirewallRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (frlr FirewallRuleListResult) IsEmpty() bool { + return frlr.Value == nil || len(*frlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (frlr FirewallRuleListResult) hasNextLink() bool { + return frlr.NextLink != nil && len(*frlr.NextLink) != 0 +} + +// firewallRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (frlr FirewallRuleListResult) firewallRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !frlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(frlr.NextLink))) +} + +// FirewallRuleListResultPage contains a page of FirewallRule values. +type FirewallRuleListResultPage struct { + fn func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error) + frlr FirewallRuleListResult +} + +// 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 *FirewallRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultPage.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.frlr) + if err != nil { + return err + } + page.frlr = 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 *FirewallRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page FirewallRuleListResultPage) NotDone() bool { + return !page.frlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page FirewallRuleListResultPage) Response() FirewallRuleListResult { + return page.frlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page FirewallRuleListResultPage) Values() []FirewallRule { + if page.frlr.IsEmpty() { + return nil + } + return *page.frlr.Value +} + +// Creates a new instance of the FirewallRuleListResultPage type. +func NewFirewallRuleListResultPage(cur FirewallRuleListResult, getNextPage func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)) FirewallRuleListResultPage { + return FirewallRuleListResultPage{ + fn: getNextPage, + frlr: cur, + } +} + +// FirewallRuleProperties the properties of a server firewall rule. +type FirewallRuleProperties struct { + // StartIPAddress - The start IP address of the server firewall rule. Must be IPv4 format. + StartIPAddress *string `json:"startIpAddress,omitempty"` + // EndIPAddress - The end IP address of the server firewall rule. Must be IPv4 format. + EndIPAddress *string `json:"endIpAddress,omitempty"` +} + +// FirewallRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FirewallRulesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FirewallRulesClient) (FirewallRule, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FirewallRulesCreateOrUpdateFuture) 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 FirewallRulesCreateOrUpdateFuture.Result. +func (future *FirewallRulesCreateOrUpdateFuture) result(client FirewallRulesClient) (fr FirewallRule, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fr.Response.Response, err = future.GetResult(sender); err == nil && fr.Response.Response.StatusCode != http.StatusNoContent { + fr, err = client.CreateOrUpdateResponder(fr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture", "Result", fr.Response.Response, "Failure responding to request") + } + } + return +} + +// FirewallRulesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FirewallRulesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FirewallRulesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FirewallRulesDeleteFuture) 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 FirewallRulesDeleteFuture.Result. +func (future *FirewallRulesDeleteFuture) result(client FirewallRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.FirewallRulesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FlexibleServerEditionCapability flexible server edition capabilities. +type FlexibleServerEditionCapability struct { + // Name - READ-ONLY; Server edition name + Name *string `json:"name,omitempty"` + // SupportedStorageEditions - READ-ONLY; The list of editions supported by this server edition. + SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of server versions supported by this server edition. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for FlexibleServerEditionCapability. +func (fsec FlexibleServerEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// HighAvailability high availability properties of a server +type HighAvailability struct { + // Mode - The HA mode for the server. Possible values include: 'HighAvailabilityModeDisabled', 'HighAvailabilityModeZoneRedundant' + Mode HighAvailabilityMode `json:"mode,omitempty"` + // State - READ-ONLY; A state of a HA server that is visible to user. Possible values include: 'NotEnabled', 'CreatingStandby', 'ReplicatingData', 'FailingOver', 'Healthy', 'RemovingStandby' + State ServerHAState `json:"state,omitempty"` + // StandbyAvailabilityZone - availability zone information of the standby. + StandbyAvailabilityZone *string `json:"standbyAvailabilityZone,omitempty"` +} + +// MarshalJSON is the custom marshaler for HighAvailability. +func (ha HighAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ha.Mode != "" { + objectMap["mode"] = ha.Mode + } + if ha.StandbyAvailabilityZone != nil { + objectMap["standbyAvailabilityZone"] = ha.StandbyAvailabilityZone + } + return json.Marshal(objectMap) +} + +// HyperscaleNodeEditionCapability hyperscale node edition capabilities. +type HyperscaleNodeEditionCapability struct { + // Name - READ-ONLY; Server edition name + Name *string `json:"name,omitempty"` + // SupportedStorageEditions - READ-ONLY; The list of editions supported by this server edition. + SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of server versions supported by this server edition. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // SupportedNodeTypes - READ-ONLY; The list of Node Types supported by this server edition. + SupportedNodeTypes *[]NodeTypeCapability `json:"supportedNodeTypes,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for HyperscaleNodeEditionCapability. +func (hnec HyperscaleNodeEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Identity identity for the resource. +type Identity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'SystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.Type != "" { + objectMap["type"] = i.Type + } + return json.Marshal(objectMap) +} + +// MaintenanceWindow maintenance window properties of a server. +type MaintenanceWindow struct { + // CustomWindow - indicates whether custom window is enabled or disabled + CustomWindow *string `json:"customWindow,omitempty"` + // StartHour - start hour for maintenance window + StartHour *int32 `json:"startHour,omitempty"` + // StartMinute - start minute for maintenance window + StartMinute *int32 `json:"startMinute,omitempty"` + // DayOfWeek - day of week for maintenance window + DayOfWeek *int32 `json:"dayOfWeek,omitempty"` +} + +// NameAvailability represents a resource name availability. +type NameAvailability struct { + autorest.Response `json:"-"` + // Message - Error Message. + Message *string `json:"message,omitempty"` + // NameAvailable - Indicates whether the resource name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Name - name of the PostgreSQL server. + Name *string `json:"name,omitempty"` + // Type - type of the server + Type *string `json:"type,omitempty"` +} + +// NameAvailabilityRequest request from client to check resource name availability. +type NameAvailabilityRequest struct { + // Name - Resource name to verify. + Name *string `json:"name,omitempty"` + // Type - Resource type used for verification. + Type *string `json:"type,omitempty"` +} + +// Network network properties of a server +type Network struct { + // PublicNetworkAccess - READ-ONLY; public network access is enabled or not. Possible values include: 'ServerPublicNetworkAccessStateEnabled', 'ServerPublicNetworkAccessStateDisabled' + PublicNetworkAccess ServerPublicNetworkAccessState `json:"publicNetworkAccess,omitempty"` + // DelegatedSubnetResourceID - delegated subnet arm resource id. + DelegatedSubnetResourceID *string `json:"delegatedSubnetResourceId,omitempty"` + // PrivateDNSZoneArmResourceID - private dns zone arm resource id. + PrivateDNSZoneArmResourceID *string `json:"privateDnsZoneArmResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for Network. +func (n Network) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if n.DelegatedSubnetResourceID != nil { + objectMap["delegatedSubnetResourceId"] = n.DelegatedSubnetResourceID + } + if n.PrivateDNSZoneArmResourceID != nil { + objectMap["privateDnsZoneArmResourceId"] = n.PrivateDNSZoneArmResourceID + } + return json.Marshal(objectMap) +} + +// NodeTypeCapability node type capability +type NodeTypeCapability struct { + // Name - READ-ONLY; note type name + Name *string `json:"name,omitempty"` + // NodeType - READ-ONLY; note type + NodeType *string `json:"nodeType,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for NodeTypeCapability. +func (ntc NodeTypeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Operation REST API operation definition. +type Operation struct { + // Name - READ-ONLY; The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; The localized display information for this particular operation or action. + Display *OperationDisplay `json:"display,omitempty"` + // IsDataAction - Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation. Possible values include: 'OperationOriginNotSpecified', 'OperationOriginUser', 'OperationOriginSystem' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - READ-ONLY; Additional descriptions for the operation. + Properties map[string]interface{} `json:"properties"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.IsDataAction != nil { + objectMap["isDataAction"] = o.IsDataAction + } + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Operation resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Operation description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult a list of resource provider operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - Collection of available operation details + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL 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"` +} + +// Plan plan for the resource. +type Plan struct { + // Name - A user defined name of the 3rd Party Artifact that is being procured. + Name *string `json:"name,omitempty"` + // Publisher - The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string `json:"publisher,omitempty"` + // Product - The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. + Product *string `json:"product,omitempty"` + // PromotionCode - A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The version of the desired product/artifact. + Version *string `json:"version,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) +} + +// ResourceModelWithAllowedPropertySet the resource model definition containing the full set of allowed +// properties for a resource. Except properties bag, there cannot be a top level property outside of this +// set. +type ResourceModelWithAllowedPropertySet 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"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ManagedBy - The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. + ManagedBy *string `json:"managedBy,omitempty"` + // Kind - Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + Identity *ResourceModelWithAllowedPropertySetIdentity `json:"identity,omitempty"` + Sku *ResourceModelWithAllowedPropertySetSku `json:"sku,omitempty"` + Plan *ResourceModelWithAllowedPropertySetPlan `json:"plan,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceModelWithAllowedPropertySet. +func (rmwaps ResourceModelWithAllowedPropertySet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmwaps.Location != nil { + objectMap["location"] = rmwaps.Location + } + if rmwaps.ManagedBy != nil { + objectMap["managedBy"] = rmwaps.ManagedBy + } + if rmwaps.Kind != nil { + objectMap["kind"] = rmwaps.Kind + } + if rmwaps.Tags != nil { + objectMap["tags"] = rmwaps.Tags + } + if rmwaps.Identity != nil { + objectMap["identity"] = rmwaps.Identity + } + if rmwaps.Sku != nil { + objectMap["sku"] = rmwaps.Sku + } + if rmwaps.Plan != nil { + objectMap["plan"] = rmwaps.Plan + } + return json.Marshal(objectMap) +} + +// ResourceModelWithAllowedPropertySetIdentity ... +type ResourceModelWithAllowedPropertySetIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'SystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceModelWithAllowedPropertySetIdentity. +func (rmwaps ResourceModelWithAllowedPropertySetIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmwaps.Type != "" { + objectMap["type"] = rmwaps.Type + } + return json.Marshal(objectMap) +} + +// ResourceModelWithAllowedPropertySetPlan ... +type ResourceModelWithAllowedPropertySetPlan struct { + // Name - A user defined name of the 3rd Party Artifact that is being procured. + Name *string `json:"name,omitempty"` + // Publisher - The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string `json:"publisher,omitempty"` + // Product - The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. + Product *string `json:"product,omitempty"` + // PromotionCode - A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The version of the desired product/artifact. + Version *string `json:"version,omitempty"` +} + +// ResourceModelWithAllowedPropertySetSku ... +type ResourceModelWithAllowedPropertySetSku struct { + // Name - The name of the sku, typically, tier + family + cores, e.g. Standard_D4s_v3. + Name *string `json:"name,omitempty"` + // Tier - The tier of the particular SKU, e.g. Burstable. Possible values include: 'Burstable', 'GeneralPurpose', 'MemoryOptimized' + Tier SkuTier `json:"tier,omitempty"` +} + +// RestartParameter represents server restart parameters. +type RestartParameter struct { + // RestartWithFailover - Indicates whether to restart the server with failover. + RestartWithFailover *bool `json:"restartWithFailover,omitempty"` + // FailoverMode - Failover mode. + FailoverMode *string `json:"failoverMode,omitempty"` +} + +// Server represents a server. +type Server struct { + autorest.Response `json:"-"` + // Identity - The Azure Active Directory identity of the server. + Identity *Identity `json:"identity,omitempty"` + // Sku - The SKU (pricing tier) of the server. + Sku *Sku `json:"sku,omitempty"` + // ServerProperties - Properties of the server. + *ServerProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // 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 Server. +func (s Server) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.Identity != nil { + objectMap["identity"] = s.Identity + } + if s.Sku != nil { + objectMap["sku"] = s.Sku + } + if s.ServerProperties != nil { + objectMap["properties"] = s.ServerProperties + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + if s.Location != nil { + objectMap["location"] = s.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Server struct. +func (s *Server) 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 "identity": + if v != nil { + var identity Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + s.Identity = &identity + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + s.Sku = &sku + } + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + s.ServerProperties = &serverProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + s.SystemData = &systemData + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ServerForUpdate represents a server to be updated. +type ServerForUpdate struct { + // Location - The location the resource resides in. + Location *string `json:"location,omitempty"` + // Sku - The SKU (pricing tier) of the server. + Sku *Sku `json:"sku,omitempty"` + // ServerPropertiesForUpdate - Properties of the server. + *ServerPropertiesForUpdate `json:"properties,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerForUpdate. +func (sfu ServerForUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sfu.Location != nil { + objectMap["location"] = sfu.Location + } + if sfu.Sku != nil { + objectMap["sku"] = sfu.Sku + } + if sfu.ServerPropertiesForUpdate != nil { + objectMap["properties"] = sfu.ServerPropertiesForUpdate + } + if sfu.Tags != nil { + objectMap["tags"] = sfu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerForUpdate struct. +func (sfu *ServerForUpdate) 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 "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sfu.Location = &location + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + sfu.Sku = &sku + } + case "properties": + if v != nil { + var serverPropertiesForUpdate ServerPropertiesForUpdate + err = json.Unmarshal(*v, &serverPropertiesForUpdate) + if err != nil { + return err + } + sfu.ServerPropertiesForUpdate = &serverPropertiesForUpdate + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sfu.Tags = tags + } + } + } + + return nil +} + +// ServerListResult a list of servers. +type ServerListResult struct { + autorest.Response `json:"-"` + // Value - The list of flexible servers + Value *[]Server `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServerListResultIterator provides access to a complete listing of Server values. +type ServerListResultIterator struct { + i int + page ServerListResultPage +} + +// 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 *ServerListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultIterator.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 *ServerListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerListResultIterator) 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 ServerListResultIterator) Response() ServerListResult { + 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 ServerListResultIterator) Value() Server { + if !iter.page.NotDone() { + return Server{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerListResultIterator type. +func NewServerListResultIterator(page ServerListResultPage) ServerListResultIterator { + return ServerListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServerListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServerListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 0 +} + +// serverListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServerListResult) serverListResultPreparer(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))) +} + +// ServerListResultPage contains a page of Server values. +type ServerListResultPage struct { + fn func(context.Context, ServerListResult) (ServerListResult, error) + slr ServerListResult +} + +// 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 *ServerListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultPage.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 *ServerListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerListResultPage) Response() ServerListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerListResultPage) Values() []Server { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the ServerListResultPage type. +func NewServerListResultPage(cur ServerListResult, getNextPage func(context.Context, ServerListResult) (ServerListResult, error)) ServerListResultPage { + return ServerListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// ServerProperties the properties of a server. +type ServerProperties struct { + // AdministratorLogin - The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for server creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Version - PostgreSQL Server version. Possible values include: 'OneThree', 'OneTwo', 'OneOne' + Version ServerVersion `json:"version,omitempty"` + // MinorVersion - READ-ONLY; The minor version of the server. + MinorVersion *string `json:"minorVersion,omitempty"` + // State - READ-ONLY; A state of a server that is visible to user. Possible values include: 'ServerStateReady', 'ServerStateDropping', 'ServerStateDisabled', 'ServerStateStarting', 'ServerStateStopping', 'ServerStateStopped', 'ServerStateUpdating' + State ServerState `json:"state,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of a server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // Storage - Storage properties of a server. + Storage *Storage `json:"storage,omitempty"` + // Backup - Backup properties of a server. + Backup *Backup `json:"backup,omitempty"` + // Network - Network properties of a server. + Network *Network `json:"network,omitempty"` + // HighAvailability - High availability properties of a server. + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + // MaintenanceWindow - Maintenance window properties of a server. + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + // SourceServerResourceID - The source server resource ID to restore from. It's required when 'createMode' is 'PointInTimeRestore'. + SourceServerResourceID *string `json:"sourceServerResourceId,omitempty"` + // PointInTimeUTC - Restore point creation time (ISO8601 format), specifying the time to restore from. It's required when 'createMode' is 'PointInTimeRestore'. + PointInTimeUTC *date.Time `json:"pointInTimeUTC,omitempty"` + // AvailabilityZone - availability zone information of the server. + AvailabilityZone *string `json:"availabilityZone,omitempty"` + // CreateMode - The mode to create a new PostgreSQL server. Possible values include: 'Default', 'Create', 'Update', 'PointInTimeRestore' + CreateMode CreateMode `json:"createMode,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerProperties. +func (sp ServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.AdministratorLogin != nil { + objectMap["administratorLogin"] = sp.AdministratorLogin + } + if sp.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = sp.AdministratorLoginPassword + } + if sp.Version != "" { + objectMap["version"] = sp.Version + } + if sp.Storage != nil { + objectMap["storage"] = sp.Storage + } + if sp.Backup != nil { + objectMap["backup"] = sp.Backup + } + if sp.Network != nil { + objectMap["network"] = sp.Network + } + if sp.HighAvailability != nil { + objectMap["highAvailability"] = sp.HighAvailability + } + if sp.MaintenanceWindow != nil { + objectMap["maintenanceWindow"] = sp.MaintenanceWindow + } + if sp.SourceServerResourceID != nil { + objectMap["sourceServerResourceId"] = sp.SourceServerResourceID + } + if sp.PointInTimeUTC != nil { + objectMap["pointInTimeUTC"] = sp.PointInTimeUTC + } + if sp.AvailabilityZone != nil { + objectMap["availabilityZone"] = sp.AvailabilityZone + } + if sp.CreateMode != "" { + objectMap["createMode"] = sp.CreateMode + } + if sp.Tags != nil { + objectMap["tags"] = sp.Tags + } + return json.Marshal(objectMap) +} + +// ServerPropertiesForUpdate ... +type ServerPropertiesForUpdate struct { + // AdministratorLoginPassword - The password of the administrator login. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Storage - Storage properties of a server. + Storage *Storage `json:"storage,omitempty"` + // Backup - Backup properties of a server. + Backup *Backup `json:"backup,omitempty"` + // HighAvailability - High availability properties of a server. + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + // MaintenanceWindow - Maintenance window properties of a server. + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + // CreateMode - The mode to update a new PostgreSQL server. Possible values include: 'CreateModeForUpdateDefault', 'CreateModeForUpdateUpdate' + CreateMode CreateModeForUpdate `json:"createMode,omitempty"` +} + +// ServersCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersCreateFuture) 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 ServersCreateFuture.Result. +func (future *ServersCreateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.CreateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersCreateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersDeleteFuture) 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 ServersDeleteFuture.Result. +func (future *ServersDeleteFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersRestartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersRestartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersRestartFuture) 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 ServersRestartFuture.Result. +func (future *ServersRestartFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersRestartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersRestartFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersStartFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersStartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersStartFuture) 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 ServersStartFuture.Result. +func (future *ServersStartFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersStartFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersStopFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersStopFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersStopFuture) 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 ServersStopFuture.Result. +func (future *ServersStopFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersStopFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersStopFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersUpdateFuture) 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 ServersUpdateFuture.Result. +func (future *ServersUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.UpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerVersionCapability server version capabilities. +type ServerVersionCapability struct { + // Name - READ-ONLY; server version + Name *string `json:"name,omitempty"` + // SupportedVcores - READ-ONLY + SupportedVcores *[]VcoreCapability `json:"supportedVcores,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVersionCapability. +func (svc ServerVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Sku sku information related properties of a server. +type Sku struct { + // Name - The name of the sku, typically, tier + family + cores, e.g. Standard_D4s_v3. + Name *string `json:"name,omitempty"` + // Tier - The tier of the particular SKU, e.g. Burstable. Possible values include: 'Burstable', 'GeneralPurpose', 'MemoryOptimized' + Tier SkuTier `json:"tier,omitempty"` +} + +// Storage storage properties of a server +type Storage struct { + // StorageSizeGB - Max storage allowed for a server. + StorageSizeGB *int32 `json:"storageSizeGB,omitempty"` +} + +// StorageEditionCapability storage edition capability +type StorageEditionCapability struct { + // Name - READ-ONLY; storage edition name + Name *string `json:"name,omitempty"` + // SupportedStorageMB - READ-ONLY + SupportedStorageMB *[]StorageMBCapability `json:"supportedStorageMB,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageEditionCapability. +func (sec StorageEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// StorageMBCapability storage size in MB capability +type StorageMBCapability struct { + // Name - READ-ONLY; storage MB name + Name *string `json:"name,omitempty"` + // SupportedIops - READ-ONLY; supported IOPS + SupportedIops *int64 `json:"supportedIops,omitempty"` + // StorageSizeMB - READ-ONLY; storage size in MB + StorageSizeMB *int64 `json:"storageSizeMB,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageMBCapability. +func (smc StorageMBCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// String ... +type String struct { + autorest.Response `json:"-"` + Value *string `json:"value,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: 'User', 'Application', 'ManagedIdentity', 'Key' + 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: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// 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) +} + +// VcoreCapability vcores capability +type VcoreCapability struct { + // Name - READ-ONLY; vCore name + Name *string `json:"name,omitempty"` + // VCores - READ-ONLY; supported vCores + VCores *int64 `json:"vCores,omitempty"` + // SupportedIops - READ-ONLY; supported IOPS + SupportedIops *int64 `json:"supportedIops,omitempty"` + // SupportedMemoryPerVcoreMB - READ-ONLY; supported memory per vCore in MB + SupportedMemoryPerVcoreMB *int64 `json:"supportedMemoryPerVcoreMB,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for VcoreCapability. +func (vc VcoreCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualNetworkSubnetUsageParameter virtual network subnet usage parameter +type VirtualNetworkSubnetUsageParameter struct { + // VirtualNetworkArmResourceID - Virtual network resource id. + VirtualNetworkArmResourceID *string `json:"virtualNetworkArmResourceId,omitempty"` +} + +// VirtualNetworkSubnetUsageResult virtual network subnet usage data. +type VirtualNetworkSubnetUsageResult struct { + autorest.Response `json:"-"` + // DelegatedSubnetsUsage - READ-ONLY + DelegatedSubnetsUsage *[]DelegatedSubnetUsage `json:"delegatedSubnetsUsage,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkSubnetUsageResult. +func (vnsur VirtualNetworkSubnetUsageResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/operations.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/operations.go new file mode 100644 index 000000000000..93008c1c249c --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/operations.go @@ -0,0 +1,100 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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 the Microsoft Azure management API provides create, read, update, and delete functionality +// for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, +// log files and configurations with new business model. +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. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DBForPostgreSql/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 +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/postgresqlflexibleserversapi/interfaces.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/postgresqlflexibleserversapi/interfaces.go new file mode 100644 index 000000000000..90724e170676 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/postgresqlflexibleserversapi/interfaces.go @@ -0,0 +1,98 @@ +package postgresqlflexibleserversapi + +// Copyright (c) Microsoft Corporation. All rights 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/postgresql/mgmt/2021-06-01/postgresqlflexibleservers" +) + +// ServersClientAPI contains the set of methods on the ServersClient type. +type ServersClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, parameters postgresqlflexibleservers.Server) (result postgresqlflexibleservers.ServersCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ServersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.Server, err error) + List(ctx context.Context) (result postgresqlflexibleservers.ServerListResultPage, err error) + ListComplete(ctx context.Context) (result postgresqlflexibleservers.ServerListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result postgresqlflexibleservers.ServerListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result postgresqlflexibleservers.ServerListResultIterator, err error) + Restart(ctx context.Context, resourceGroupName string, serverName string, parameters *postgresqlflexibleservers.RestartParameter) (result postgresqlflexibleservers.ServersRestartFuture, err error) + Start(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ServersStartFuture, err error) + Stop(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ServersStopFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, parameters postgresqlflexibleservers.ServerForUpdate) (result postgresqlflexibleservers.ServersUpdateFuture, err error) +} + +var _ ServersClientAPI = (*postgresqlflexibleservers.ServersClient)(nil) + +// FirewallRulesClientAPI contains the set of methods on the FirewallRulesClient type. +type FirewallRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters postgresqlflexibleservers.FirewallRule) (result postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result postgresqlflexibleservers.FirewallRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result postgresqlflexibleservers.FirewallRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.FirewallRuleListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.FirewallRuleListResultIterator, err error) +} + +var _ FirewallRulesClientAPI = (*postgresqlflexibleservers.FirewallRulesClient)(nil) + +// ConfigurationsClientAPI contains the set of methods on the ConfigurationsClient type. +type ConfigurationsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (result postgresqlflexibleservers.Configuration, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ConfigurationListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ConfigurationListResultIterator, err error) + Put(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters postgresqlflexibleservers.Configuration) (result postgresqlflexibleservers.ConfigurationsPutFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters postgresqlflexibleservers.Configuration) (result postgresqlflexibleservers.ConfigurationsUpdateFuture, err error) +} + +var _ ConfigurationsClientAPI = (*postgresqlflexibleservers.ConfigurationsClient)(nil) + +// CheckNameAvailabilityClientAPI contains the set of methods on the CheckNameAvailabilityClient type. +type CheckNameAvailabilityClientAPI interface { + Execute(ctx context.Context, nameAvailabilityRequest postgresqlflexibleservers.NameAvailabilityRequest) (result postgresqlflexibleservers.NameAvailability, err error) +} + +var _ CheckNameAvailabilityClientAPI = (*postgresqlflexibleservers.CheckNameAvailabilityClient)(nil) + +// LocationBasedCapabilitiesClientAPI contains the set of methods on the LocationBasedCapabilitiesClient type. +type LocationBasedCapabilitiesClientAPI interface { + Execute(ctx context.Context, locationName string) (result postgresqlflexibleservers.CapabilitiesListResultPage, err error) + ExecuteComplete(ctx context.Context, locationName string) (result postgresqlflexibleservers.CapabilitiesListResultIterator, err error) +} + +var _ LocationBasedCapabilitiesClientAPI = (*postgresqlflexibleservers.LocationBasedCapabilitiesClient)(nil) + +// VirtualNetworkSubnetUsageClientAPI contains the set of methods on the VirtualNetworkSubnetUsageClient type. +type VirtualNetworkSubnetUsageClientAPI interface { + Execute(ctx context.Context, locationName string, parameters postgresqlflexibleservers.VirtualNetworkSubnetUsageParameter) (result postgresqlflexibleservers.VirtualNetworkSubnetUsageResult, err error) +} + +var _ VirtualNetworkSubnetUsageClientAPI = (*postgresqlflexibleservers.VirtualNetworkSubnetUsageClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result postgresqlflexibleservers.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*postgresqlflexibleservers.OperationsClient)(nil) + +// DatabasesClientAPI contains the set of methods on the DatabasesClient type. +type DatabasesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters postgresqlflexibleservers.Database) (result postgresqlflexibleservers.DatabasesCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result postgresqlflexibleservers.DatabasesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result postgresqlflexibleservers.Database, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.DatabaseListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.DatabaseListResultIterator, err error) +} + +var _ DatabasesClientAPI = (*postgresqlflexibleservers.DatabasesClient)(nil) + +// GetPrivateDNSZoneSuffixClientAPI contains the set of methods on the GetPrivateDNSZoneSuffixClient type. +type GetPrivateDNSZoneSuffixClientAPI interface { + Execute(ctx context.Context) (result postgresqlflexibleservers.String, err error) +} + +var _ GetPrivateDNSZoneSuffixClientAPI = (*postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient)(nil) diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/servers.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/servers.go new file mode 100644 index 000000000000..090e59b2e3ac --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/servers.go @@ -0,0 +1,898 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ServersClient is the the Microsoft Azure management API provides create, read, update, and delete functionality for +// Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, log +// files and configurations with new business model. +type ServersClient struct { + BaseClient +} + +// NewServersClient creates an instance of the ServersClient client. +func NewServersClient(subscriptionID string) ServersClient { + return NewServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServersClientWithBaseURI creates an instance of the ServersClient 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 NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { + return ServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a new server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the required parameters for creating or updating a server. +func (client ServersClient) Create(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (result ServersCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Create") + 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: 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: 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("postgresqlflexibleservers.ServersClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ServersClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + 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.DBForPostgreSql/flexibleServers/{serverName}", pathParameters), + autorest.WithJSON(parameters), + 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 ServersClient) CreateSender(req *http.Request) (future ServersCreateFuture, 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 +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ServersClient) CreateResponder(resp *http.Response) (result Server, 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 a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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: 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("postgresqlflexibleservers.ServersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}", 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 ServersClient) DeleteSender(req *http.Request) (future ServersDeleteFuture, 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 ServersClient) 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 gets information about a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result Server, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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("postgresqlflexibleservers.ServersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}", 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 ServersClient) 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 ServersClient) GetResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all the servers in a given subscription. +func (client ServersClient) List(ctx context.Context) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.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("postgresqlflexibleservers.ServersClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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, "postgresqlflexibleservers.ServersClient", "List", resp, "Failure sending request") + return + } + + result.slr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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 ServersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/flexibleServers", 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 ServersClient) 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 ServersClient) ListResponder(resp *http.Response) (result ServerListResult, 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 ServersClient) listNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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, "postgresqlflexibleservers.ServersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListComplete(ctx context.Context) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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 the servers in a given resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.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("postgresqlflexibleservers.ServersClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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, "postgresqlflexibleservers.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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 ServersClient) 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" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers", 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 ServersClient) 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 ServersClient) ListByResourceGroupResponder(resp *http.Response) (result ServerListResult, 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 ServersClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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, "postgresqlflexibleservers.ServersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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 +} + +// Restart restarts a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the parameters for restarting a server. +func (client ServersClient) Restart(ctx context.Context, resourceGroupName string, serverName string, parameters *RestartParameter) (result ServersRestartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Restart") + 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: 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("postgresqlflexibleservers.ServersClient", "Restart", err.Error()) + } + + req, err := client.RestartPreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Restart", nil, "Failure preparing request") + return + } + + result, err = client.RestartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Restart", nil, "Failure sending request") + return + } + + return +} + +// RestartPreparer prepares the Restart request. +func (client ServersClient) RestartPreparer(ctx context.Context, resourceGroupName string, serverName string, parameters *RestartParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/restart", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + 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 ServersClient) RestartSender(req *http.Request) (future ServersRestartFuture, 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 ServersClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Start starts a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Start(ctx context.Context, resourceGroupName string, serverName string) (result ServersStartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Start") + 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: 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("postgresqlflexibleservers.ServersClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Start", nil, "Failure preparing request") + return + } + + result, err = client.StartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Start", nil, "Failure sending request") + return + } + + return +} + +// StartPreparer prepares the Start request. +func (client ServersClient) StartPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{serverName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) StartSender(req *http.Request) (future ServersStartFuture, 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 +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client ServersClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stops a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Stop(ctx context.Context, resourceGroupName string, serverName string) (result ServersStopFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Stop") + 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: 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("postgresqlflexibleservers.ServersClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Stop", nil, "Failure preparing request") + return + } + + result, err = client.StopSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Stop", nil, "Failure sending request") + return + } + + return +} + +// StopPreparer prepares the Stop request. +func (client ServersClient) StopPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{serverName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) StopSender(req *http.Request) (future ServersStopFuture, 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 +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client ServersClient) StopResponder(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 server. The request body can contain one to many of the properties present in the normal +// server definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the required parameters for updating a server. +func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate) (result ServersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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: 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("postgresqlflexibleservers.ServersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}", 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 ServersClient) UpdateSender(req *http.Request) (future ServersUpdateFuture, 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 ServersClient) UpdateResponder(resp *http.Response) (result Server, 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/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/version.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/version.go new file mode 100644 index 000000000000..e13132f4b75a --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/version.go @@ -0,0 +1,19 @@ +package postgresqlflexibleservers + +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() + " postgresqlflexibleservers/2021-06-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/virtualnetworksubnetusage.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/virtualnetworksubnetusage.go new file mode 100644 index 000000000000..729356b5cf89 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/virtualnetworksubnetusage.go @@ -0,0 +1,118 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// VirtualNetworkSubnetUsageClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type VirtualNetworkSubnetUsageClient struct { + BaseClient +} + +// NewVirtualNetworkSubnetUsageClient creates an instance of the VirtualNetworkSubnetUsageClient client. +func NewVirtualNetworkSubnetUsageClient(subscriptionID string) VirtualNetworkSubnetUsageClient { + return NewVirtualNetworkSubnetUsageClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualNetworkSubnetUsageClientWithBaseURI creates an instance of the VirtualNetworkSubnetUsageClient 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 NewVirtualNetworkSubnetUsageClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkSubnetUsageClient { + return VirtualNetworkSubnetUsageClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute get virtual network subnet usage for a given vNet resource id. +// Parameters: +// locationName - the name of the location. +// parameters - the required parameters for creating or updating a server. +func (client VirtualNetworkSubnetUsageClient) Execute(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter) (result VirtualNetworkSubnetUsageResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkSubnetUsageClient.Execute") + 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("postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", err.Error()) + } + + req, err := client.ExecutePreparer(ctx, locationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client VirtualNetworkSubnetUsageClient) ExecutePreparer(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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}/providers/Microsoft.DBForPostgreSql/locations/{locationName}/checkVirtualNetworkSubnetUsage", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkSubnetUsageClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client VirtualNetworkSubnetUsageClient) ExecuteResponder(resp *http.Response) (result VirtualNetworkSubnetUsageResult, 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/postgresql/mgmt/2017-12-01-preview/postgresql/CHANGELOG.md b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/CHANGELOG.md index d91ad45505a7..4787b2e4e259 100644 --- a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/CHANGELOG.md +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/CHANGELOG.md @@ -1,12 +1,70 @@ -# Change History +# Unreleased ## Additive Changes ### New Funcs -1. AzureEntityResource.MarshalJSON() ([]byte, error) -1. OperationDisplay.MarshalJSON() ([]byte, error) -1. ProxyResource.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. ServerPrivateEndpointConnection.MarshalJSON() ([]byte, error) -1. VirtualNetworkRuleListResult.MarshalJSON() ([]byte, error) +1. *RecoverableServerResource.UnmarshalJSON([]byte) error +1. *ServerParametersListUpdateConfigurationsFuture.UnmarshalJSON([]byte) error +1. *ServerSecurityAlertPolicyListResultIterator.Next() error +1. *ServerSecurityAlertPolicyListResultIterator.NextWithContext(context.Context) error +1. *ServerSecurityAlertPolicyListResultPage.Next() error +1. *ServerSecurityAlertPolicyListResultPage.NextWithContext(context.Context) error +1. NewRecoverableServersClient(string) RecoverableServersClient +1. NewRecoverableServersClientWithBaseURI(string, string) RecoverableServersClient +1. NewServerBasedPerformanceTierClient(string) ServerBasedPerformanceTierClient +1. NewServerBasedPerformanceTierClientWithBaseURI(string, string) ServerBasedPerformanceTierClient +1. NewServerParametersClient(string) ServerParametersClient +1. NewServerParametersClientWithBaseURI(string, string) ServerParametersClient +1. NewServerSecurityAlertPolicyListResultIterator(ServerSecurityAlertPolicyListResultPage) ServerSecurityAlertPolicyListResultIterator +1. NewServerSecurityAlertPolicyListResultPage(ServerSecurityAlertPolicyListResult, func(context.Context, ServerSecurityAlertPolicyListResult) (ServerSecurityAlertPolicyListResult, error)) ServerSecurityAlertPolicyListResultPage +1. RecoverableServerProperties.MarshalJSON() ([]byte, error) +1. RecoverableServerResource.MarshalJSON() ([]byte, error) +1. RecoverableServersClient.Get(context.Context, string, string) (RecoverableServerResource, error) +1. RecoverableServersClient.GetPreparer(context.Context, string, string) (*http.Request, error) +1. RecoverableServersClient.GetResponder(*http.Response) (RecoverableServerResource, error) +1. RecoverableServersClient.GetSender(*http.Request) (*http.Response, error) +1. ServerBasedPerformanceTierClient.List(context.Context, string, string) (PerformanceTierListResult, error) +1. ServerBasedPerformanceTierClient.ListPreparer(context.Context, string, string) (*http.Request, error) +1. ServerBasedPerformanceTierClient.ListResponder(*http.Response) (PerformanceTierListResult, error) +1. ServerBasedPerformanceTierClient.ListSender(*http.Request) (*http.Response, error) +1. ServerParametersClient.ListUpdateConfigurations(context.Context, string, string, ConfigurationListResult) (ServerParametersListUpdateConfigurationsFuture, error) +1. ServerParametersClient.ListUpdateConfigurationsPreparer(context.Context, string, string, ConfigurationListResult) (*http.Request, error) +1. ServerParametersClient.ListUpdateConfigurationsResponder(*http.Response) (ConfigurationListResult, error) +1. ServerParametersClient.ListUpdateConfigurationsSender(*http.Request) (ServerParametersListUpdateConfigurationsFuture, error) +1. ServerSecurityAlertPoliciesClient.ListByServer(context.Context, string, string) (ServerSecurityAlertPolicyListResultPage, error) +1. ServerSecurityAlertPoliciesClient.ListByServerComplete(context.Context, string, string) (ServerSecurityAlertPolicyListResultIterator, error) +1. ServerSecurityAlertPoliciesClient.ListByServerPreparer(context.Context, string, string) (*http.Request, error) +1. ServerSecurityAlertPoliciesClient.ListByServerResponder(*http.Response) (ServerSecurityAlertPolicyListResult, error) +1. ServerSecurityAlertPoliciesClient.ListByServerSender(*http.Request) (*http.Response, error) +1. ServerSecurityAlertPolicyListResult.IsEmpty() bool +1. ServerSecurityAlertPolicyListResult.MarshalJSON() ([]byte, error) +1. ServerSecurityAlertPolicyListResultIterator.NotDone() bool +1. ServerSecurityAlertPolicyListResultIterator.Response() ServerSecurityAlertPolicyListResult +1. ServerSecurityAlertPolicyListResultIterator.Value() ServerSecurityAlertPolicy +1. ServerSecurityAlertPolicyListResultPage.NotDone() bool +1. ServerSecurityAlertPolicyListResultPage.Response() ServerSecurityAlertPolicyListResult +1. ServerSecurityAlertPolicyListResultPage.Values() []ServerSecurityAlertPolicy + +### Struct Changes + +#### New Structs + +1. RecoverableServerProperties +1. RecoverableServerResource +1. RecoverableServersClient +1. ServerBasedPerformanceTierClient +1. ServerParametersClient +1. ServerParametersListUpdateConfigurationsFuture +1. ServerSecurityAlertPolicyListResult +1. ServerSecurityAlertPolicyListResultIterator +1. ServerSecurityAlertPolicyListResultPage + +#### New Struct Fields + +1. PerformanceTierProperties.MaxBackupRetentionDays +1. PerformanceTierProperties.MaxLargeStorageMB +1. PerformanceTierProperties.MaxStorageMB +1. PerformanceTierProperties.MinBackupRetentionDays +1. PerformanceTierProperties.MinLargeStorageMB +1. PerformanceTierProperties.MinStorageMB diff --git a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/_meta.json b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/_meta.json index b76edafa6be6..cb1eef30b5c2 100644 --- a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/_meta.json +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "c7616be749e60dc269e2bb50800f06dbca065098", "readme": "/_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", "tag": "package-2017-12-01-preview", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/models.go b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/models.go index 6ce888e4c7f6..bd2132f021c9 100644 --- a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/models.go +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/models.go @@ -724,6 +724,18 @@ type PerformanceTierListResult struct { type PerformanceTierProperties struct { // ID - ID of the performance tier. ID *string `json:"id,omitempty"` + // MaxBackupRetentionDays - Maximum Backup retention in days for the performance tier edition + MaxBackupRetentionDays *int32 `json:"maxBackupRetentionDays,omitempty"` + // MinBackupRetentionDays - Minimum Backup retention in days for the performance tier edition + MinBackupRetentionDays *int32 `json:"minBackupRetentionDays,omitempty"` + // MaxStorageMB - Max storage allowed for a server. + MaxStorageMB *int32 `json:"maxStorageMB,omitempty"` + // MinLargeStorageMB - Max storage allowed for a server. + MinLargeStorageMB *int32 `json:"minLargeStorageMB,omitempty"` + // MaxLargeStorageMB - Max storage allowed for a server. + MaxLargeStorageMB *int32 `json:"maxLargeStorageMB,omitempty"` + // MinStorageMB - Max storage allowed for a server. + MinStorageMB *int32 `json:"minStorageMB,omitempty"` // ServiceLevelObjectives - Service level objectives associated with the performance tier ServiceLevelObjectives *[]PerformanceTierServiceLevelObjectives `json:"serviceLevelObjectives,omitempty"` } @@ -815,6 +827,101 @@ func (pr ProxyResource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// RecoverableServerProperties the recoverable server's properties. +type RecoverableServerProperties struct { + // LastAvailableBackupDateTime - READ-ONLY; The last available backup date time. + LastAvailableBackupDateTime *string `json:"lastAvailableBackupDateTime,omitempty"` + // ServiceLevelObjective - READ-ONLY; The service level objective + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // Edition - READ-ONLY; Edition of the performance tier. + Edition *string `json:"edition,omitempty"` + // VCore - READ-ONLY; vCore associated with the service level objective + VCore *int32 `json:"vCore,omitempty"` + // HardwareGeneration - READ-ONLY; Hardware generation associated with the service level objective + HardwareGeneration *string `json:"hardwareGeneration,omitempty"` + // Version - READ-ONLY; The PostgreSQL version + Version *string `json:"version,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableServerProperties. +func (rsp RecoverableServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableServerResource a recoverable server resource. +type RecoverableServerResource struct { + autorest.Response `json:"-"` + // RecoverableServerProperties - Resource properties. + *RecoverableServerProperties `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 RecoverableServerResource. +func (rsr RecoverableServerResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsr.RecoverableServerProperties != nil { + objectMap["properties"] = rsr.RecoverableServerProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecoverableServerResource struct. +func (rsr *RecoverableServerResource) 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 recoverableServerProperties RecoverableServerProperties + err = json.Unmarshal(*v, &recoverableServerProperties) + if err != nil { + return err + } + rsr.RecoverableServerProperties = &recoverableServerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rsr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rsr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rsr.Type = &typeVar + } + } + } + + return nil +} + // 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} @@ -1254,6 +1361,49 @@ type ServerListResult struct { Value *[]Server `json:"value,omitempty"` } +// ServerParametersListUpdateConfigurationsFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerParametersListUpdateConfigurationsFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerParametersClient) (ConfigurationListResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerParametersListUpdateConfigurationsFuture) 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 ServerParametersListUpdateConfigurationsFuture.Result. +func (future *ServerParametersListUpdateConfigurationsFuture) result(client ServerParametersClient) (clr ConfigurationListResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersListUpdateConfigurationsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + clr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresql.ServerParametersListUpdateConfigurationsFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if clr.Response.Response, err = future.GetResult(sender); err == nil && clr.Response.Response.StatusCode != http.StatusNoContent { + clr, err = client.ListUpdateConfigurationsResponder(clr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersListUpdateConfigurationsFuture", "Result", clr.Response.Response, "Failure responding to request") + } + } + return +} + // ServerPrivateEndpointConnection a private endpoint connection under a server type ServerPrivateEndpointConnection struct { // ID - READ-ONLY; Resource Id of the private endpoint connection. @@ -1962,6 +2112,172 @@ func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { return nil } +// ServerSecurityAlertPolicyListResult a list of the server's security alert policies. +type ServerSecurityAlertPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerSecurityAlertPolicyListResult. +func (ssaplr ServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ServerSecurityAlertPolicy values. +type ServerSecurityAlertPolicyListResultIterator struct { + i int + page ServerSecurityAlertPolicyListResultPage +} + +// 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 *ServerSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPolicyListResultIterator.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 *ServerSecurityAlertPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerSecurityAlertPolicyListResultIterator) 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 ServerSecurityAlertPolicyListResultIterator) Response() ServerSecurityAlertPolicyListResult { + 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 ServerSecurityAlertPolicyListResultIterator) Value() ServerSecurityAlertPolicy { + if !iter.page.NotDone() { + return ServerSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerSecurityAlertPolicyListResultIterator type. +func NewServerSecurityAlertPolicyListResultIterator(page ServerSecurityAlertPolicyListResultPage) ServerSecurityAlertPolicyListResultIterator { + return ServerSecurityAlertPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ssaplr ServerSecurityAlertPolicyListResult) IsEmpty() bool { + return ssaplr.Value == nil || len(*ssaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ssaplr ServerSecurityAlertPolicyListResult) hasNextLink() bool { + return ssaplr.NextLink != nil && len(*ssaplr.NextLink) != 0 +} + +// serverSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ssaplr ServerSecurityAlertPolicyListResult) serverSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ssaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ssaplr.NextLink))) +} + +// ServerSecurityAlertPolicyListResultPage contains a page of ServerSecurityAlertPolicy values. +type ServerSecurityAlertPolicyListResultPage struct { + fn func(context.Context, ServerSecurityAlertPolicyListResult) (ServerSecurityAlertPolicyListResult, error) + ssaplr ServerSecurityAlertPolicyListResult +} + +// 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 *ServerSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPolicyListResultPage.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.ssaplr) + if err != nil { + return err + } + page.ssaplr = 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 *ServerSecurityAlertPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.ssaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerSecurityAlertPolicyListResultPage) Response() ServerSecurityAlertPolicyListResult { + return page.ssaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerSecurityAlertPolicyListResultPage) Values() []ServerSecurityAlertPolicy { + if page.ssaplr.IsEmpty() { + return nil + } + return *page.ssaplr.Value +} + +// Creates a new instance of the ServerSecurityAlertPolicyListResultPage type. +func NewServerSecurityAlertPolicyListResultPage(cur ServerSecurityAlertPolicyListResult, getNextPage func(context.Context, ServerSecurityAlertPolicyListResult) (ServerSecurityAlertPolicyListResult, error)) ServerSecurityAlertPolicyListResultPage { + return ServerSecurityAlertPolicyListResultPage{ + fn: getNextPage, + ssaplr: cur, + } +} + // ServersRestartFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type ServersRestartFuture struct { diff --git a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/postgresqlapi/interfaces.go b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/postgresqlapi/interfaces.go index feb5c561d33e..a464112176f5 100644 --- a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/postgresqlapi/interfaces.go +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/postgresqlapi/interfaces.go @@ -71,6 +71,13 @@ type ConfigurationsClientAPI interface { var _ ConfigurationsClientAPI = (*postgresql.ConfigurationsClient)(nil) +// ServerParametersClientAPI contains the set of methods on the ServerParametersClient type. +type ServerParametersClientAPI interface { + ListUpdateConfigurations(ctx context.Context, resourceGroupName string, serverName string, value postgresql.ConfigurationListResult) (result postgresql.ServerParametersListUpdateConfigurationsFuture, err error) +} + +var _ ServerParametersClientAPI = (*postgresql.ServerParametersClient)(nil) + // LogFilesClientAPI contains the set of methods on the LogFilesClient type. type LogFilesClientAPI interface { ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.LogFileListResult, err error) @@ -88,6 +95,20 @@ type ServerAdministratorsClientAPI interface { var _ ServerAdministratorsClientAPI = (*postgresql.ServerAdministratorsClient)(nil) +// RecoverableServersClientAPI contains the set of methods on the RecoverableServersClient type. +type RecoverableServersClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.RecoverableServerResource, err error) +} + +var _ RecoverableServersClientAPI = (*postgresql.RecoverableServersClient)(nil) + +// ServerBasedPerformanceTierClientAPI contains the set of methods on the ServerBasedPerformanceTierClient type. +type ServerBasedPerformanceTierClientAPI interface { + List(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.PerformanceTierListResult, err error) +} + +var _ ServerBasedPerformanceTierClientAPI = (*postgresql.ServerBasedPerformanceTierClient)(nil) + // LocationBasedPerformanceTierClientAPI contains the set of methods on the LocationBasedPerformanceTierClient type. type LocationBasedPerformanceTierClientAPI interface { List(ctx context.Context, locationName string) (result postgresql.PerformanceTierListResult, err error) @@ -106,6 +127,8 @@ var _ CheckNameAvailabilityClientAPI = (*postgresql.CheckNameAvailabilityClient) type ServerSecurityAlertPoliciesClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters postgresql.ServerSecurityAlertPolicy) (result postgresql.ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) Get(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.ServerSecurityAlertPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.ServerSecurityAlertPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresql.ServerSecurityAlertPolicyListResultIterator, err error) } var _ ServerSecurityAlertPoliciesClientAPI = (*postgresql.ServerSecurityAlertPoliciesClient)(nil) diff --git a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/recoverableservers.go b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/recoverableservers.go new file mode 100644 index 000000000000..e2e940da94b0 --- /dev/null +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/recoverableservers.go @@ -0,0 +1,111 @@ +package postgresql + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// RecoverableServersClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type RecoverableServersClient struct { + BaseClient +} + +// NewRecoverableServersClient creates an instance of the RecoverableServersClient client. +func NewRecoverableServersClient(subscriptionID string) RecoverableServersClient { + return NewRecoverableServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecoverableServersClientWithBaseURI creates an instance of the RecoverableServersClient 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 NewRecoverableServersClientWithBaseURI(baseURI string, subscriptionID string) RecoverableServersClient { + return RecoverableServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recoverable PostgreSQL Server. +// 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. +// serverName - the name of the server. +func (client RecoverableServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result RecoverableServerResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableServersClient.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, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.RecoverableServersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresql.RecoverableServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.RecoverableServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoverableServersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBForPostgreSQL/servers/{serverName}/recoverableServers", 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 RecoverableServersClient) 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 RecoverableServersClient) GetResponder(resp *http.Response) (result RecoverableServerResource, 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/postgresql/mgmt/2017-12-01-preview/postgresql/replicas.go b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/replicas.go index 96abb1e5c915..cfe061bc0fb1 100644 --- a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/replicas.go +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/replicas.go @@ -86,7 +86,7 @@ func (client ReplicasClient) ListByServerPreparer(ctx context.Context, resourceG preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Replicas", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/replicas", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } diff --git a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serveradministrators.go b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serveradministrators.go index 15fdbcceec34..c9db816537ae 100644 --- a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serveradministrators.go +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serveradministrators.go @@ -95,7 +95,7 @@ func (client ServerAdministratorsClient) CreateOrUpdatePreparer(ctx context.Cont autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Administrators/activeDirectory", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/administrators/activeDirectory", pathParameters), autorest.WithJSON(properties), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) @@ -175,7 +175,7 @@ func (client ServerAdministratorsClient) DeletePreparer(ctx context.Context, res preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Administrators/activeDirectory", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/administrators/activeDirectory", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -260,7 +260,7 @@ func (client ServerAdministratorsClient) GetPreparer(ctx context.Context, resour preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/Administrators/activeDirectory", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL/servers/{serverName}/administrators/activeDirectory", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } diff --git a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serverbasedperformancetier.go b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serverbasedperformancetier.go new file mode 100644 index 000000000000..a7009e5526bd --- /dev/null +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serverbasedperformancetier.go @@ -0,0 +1,111 @@ +package postgresql + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ServerBasedPerformanceTierClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type ServerBasedPerformanceTierClient struct { + BaseClient +} + +// NewServerBasedPerformanceTierClient creates an instance of the ServerBasedPerformanceTierClient client. +func NewServerBasedPerformanceTierClient(subscriptionID string) ServerBasedPerformanceTierClient { + return NewServerBasedPerformanceTierClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerBasedPerformanceTierClientWithBaseURI creates an instance of the ServerBasedPerformanceTierClient 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 NewServerBasedPerformanceTierClientWithBaseURI(baseURI string, subscriptionID string) ServerBasedPerformanceTierClient { + return ServerBasedPerformanceTierClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list all the performance tiers for a PostgreSQL server. +// 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. +// serverName - the name of the server. +func (client ServerBasedPerformanceTierClient) List(ctx context.Context, resourceGroupName string, serverName string) (result PerformanceTierListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBasedPerformanceTierClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerBasedPerformanceTierClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresql.ServerBasedPerformanceTierClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerBasedPerformanceTierClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServerBasedPerformanceTierClient) ListPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBForPostgreSQL/servers/{serverName}/performanceTiers", 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 ServerBasedPerformanceTierClient) 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 ServerBasedPerformanceTierClient) ListResponder(resp *http.Response) (result PerformanceTierListResult, 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/postgresql/mgmt/2017-12-01-preview/postgresql/serverparameters.go b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serverparameters.go new file mode 100644 index 000000000000..3a89362f2fb8 --- /dev/null +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serverparameters.go @@ -0,0 +1,116 @@ +package postgresql + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ServerParametersClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type ServerParametersClient struct { + BaseClient +} + +// NewServerParametersClient creates an instance of the ServerParametersClient client. +func NewServerParametersClient(subscriptionID string) ServerParametersClient { + return NewServerParametersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerParametersClientWithBaseURI creates an instance of the ServerParametersClient 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 NewServerParametersClientWithBaseURI(baseURI string, subscriptionID string) ServerParametersClient { + return ServerParametersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListUpdateConfigurations update a list of configurations in a given server. +// 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. +// serverName - the name of the server. +// value - the parameters for updating a list of server configuration. +func (client ServerParametersClient) ListUpdateConfigurations(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult) (result ServerParametersListUpdateConfigurationsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerParametersClient.ListUpdateConfigurations") + 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.ListUpdateConfigurationsPreparer(ctx, resourceGroupName, serverName, value) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersClient", "ListUpdateConfigurations", nil, "Failure preparing request") + return + } + + result, err = client.ListUpdateConfigurationsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerParametersClient", "ListUpdateConfigurations", nil, "Failure sending request") + return + } + + return +} + +// ListUpdateConfigurationsPreparer prepares the ListUpdateConfigurations request. +func (client ServerParametersClient) ListUpdateConfigurationsPreparer(ctx context.Context, resourceGroupName string, serverName string, value ConfigurationListResult) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBForPostgreSQL/servers/{serverName}/updateConfigurations", pathParameters), + autorest.WithJSON(value), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUpdateConfigurationsSender sends the ListUpdateConfigurations request. The method will close the +// http.Response Body if it receives an error. +func (client ServerParametersClient) ListUpdateConfigurationsSender(req *http.Request) (future ServerParametersListUpdateConfigurationsFuture, 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 +} + +// ListUpdateConfigurationsResponder handles the response to the ListUpdateConfigurations request. The method always +// closes the http.Response Body. +func (client ServerParametersClient) ListUpdateConfigurationsResponder(resp *http.Response) (result ConfigurationListResult, 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/postgresql/mgmt/2017-12-01-preview/postgresql/serversecurityalertpolicies.go b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serversecurityalertpolicies.go index 9817850bcf49..69440482780a 100644 --- a/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serversecurityalertpolicies.go +++ b/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql/serversecurityalertpolicies.go @@ -10,6 +10,7 @@ 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" ) @@ -193,3 +194,128 @@ func (client ServerSecurityAlertPoliciesClient) GetResponder(resp *http.Response result.Response = autorest.Response{Response: resp} return } + +// ListByServer get the server's threat detection policies. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServerSecurityAlertPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.ssaplr.Response.Response != nil { + sc = result.ssaplr.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}}}}); err != nil { + return result, validation.NewError("postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.ssaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.ssaplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.ssaplr.hasNextLink() && result.ssaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerSecurityAlertPoliciesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-12-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.DBforPostgreSQL/servers/{serverName}/securityAlertPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) ListByServerResponder(resp *http.Response) (result ServerSecurityAlertPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerSecurityAlertPoliciesClient) listByServerNextResults(ctx context.Context, lastResults ServerSecurityAlertPolicyListResult) (result ServerSecurityAlertPolicyListResult, err error) { + req, err := lastResults.serverSecurityAlertPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerSecurityAlertPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/CHANGELOG.md b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/CHANGELOG.md index b9c893a846b8..a1ecf841edb0 100644 --- a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/CHANGELOG.md +++ b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/CHANGELOG.md @@ -1,13 +1,2 @@ -# Change History +# Unreleased -## Additive Changes - -### Struct Changes - -#### New Structs - -1. ServerPropertiesPrivateDNSZoneArguments - -#### New Struct Fields - -1. ServerProperties.PrivateDNSZoneArguments diff --git a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/_meta.json b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/_meta.json index 82a7639f5aa9..589a4b71873e 100644 --- a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/_meta.json +++ b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/_meta.json @@ -1,5 +1,5 @@ { - "commit": "ef7ffaa1ae68ab17dba86d8e0be5fd1fb615ef64", + "commit": "c7616be749e60dc269e2bb50800f06dbca065098", "readme": "/_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", "tag": "package-2020-02-14-preview", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/configurations.go b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/configurations.go index bd7cfde6d96d..05c0bb3fa85f 100644 --- a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/configurations.go +++ b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/configurations.go @@ -54,8 +54,7 @@ func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName st 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Get", err.Error()) } @@ -141,8 +140,7 @@ func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "ListByServer", err.Error()) } @@ -271,8 +269,7 @@ func (client ConfigurationsClient) Update(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Update", err.Error()) } diff --git a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/firewallrules.go b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/firewallrules.go index 2c2483d9851d..089eed78f4e2 100644 --- a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/firewallrules.go +++ b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/firewallrules.go @@ -55,8 +55,7 @@ func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGr 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, @@ -154,8 +153,7 @@ func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "Delete", err.Error()) } @@ -243,8 +241,7 @@ func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName str 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "Get", err.Error()) } @@ -330,8 +327,7 @@ func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGrou 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "ListByServer", err.Error()) } diff --git a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/servers.go b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/servers.go index 06cab4e9150a..d0a2cb18d70b 100644 --- a/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/servers.go +++ b/services/preview/postgresql/mgmt/2020-02-14-preview/postgresqlflexibleservers/servers.go @@ -54,8 +54,7 @@ func (client ServersClient) Create(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {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 { @@ -147,8 +146,7 @@ func (client ServersClient) Delete(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Delete", err.Error()) } @@ -234,8 +232,7 @@ func (client ServersClient) Get(ctx context.Context, resourceGroupName string, s 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Get", err.Error()) } @@ -438,8 +435,7 @@ func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "ListByResourceGroup", err.Error()) } @@ -565,8 +561,7 @@ func (client ServersClient) Restart(ctx context.Context, resourceGroupName strin 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Restart", err.Error()) } @@ -652,8 +647,7 @@ func (client ServersClient) Start(ctx context.Context, resourceGroupName string, 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Start", err.Error()) } @@ -739,8 +733,7 @@ func (client ServersClient) Stop(ctx context.Context, resourceGroupName string, 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Stop", err.Error()) } @@ -828,8 +821,7 @@ func (client ServersClient) Update(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Update", err.Error()) } diff --git a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/CHANGELOG.md b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/CHANGELOG.md index 15288525920d..a5342bcf7abf 100644 --- a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/CHANGELOG.md +++ b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/CHANGELOG.md @@ -1,21 +1,15 @@ -# Change History +# Unreleased ## Additive Changes -### New Funcs +### Struct Changes -1. AzureEntityResource.MarshalJSON() ([]byte, error) -1. CapabilitiesListResult.MarshalJSON() ([]byte, error) -1. CapabilityProperties.MarshalJSON() ([]byte, error) -1. DelegatedSubnetUsage.MarshalJSON() ([]byte, error) -1. ErrorAdditionalInfo.MarshalJSON() ([]byte, error) -1. ErrorResponse.MarshalJSON() ([]byte, error) -1. OperationDisplay.MarshalJSON() ([]byte, error) -1. ProxyResource.MarshalJSON() ([]byte, error) -1. Resource.MarshalJSON() ([]byte, error) -1. ServerEditionCapability.MarshalJSON() ([]byte, error) -1. ServerVersionCapability.MarshalJSON() ([]byte, error) -1. StorageEditionCapability.MarshalJSON() ([]byte, error) -1. StorageMBCapability.MarshalJSON() ([]byte, error) -1. VcoreCapability.MarshalJSON() ([]byte, error) -1. VirtualNetworkSubnetUsageResult.MarshalJSON() ([]byte, error) +#### New Structs + +1. ServerPropertiesPrivateDNSZoneArguments + +#### New Struct Fields + +1. ServerProperties.PrivateDNSZoneArguments +1. ServerProperties.SourceResourceGroupName +1. ServerProperties.SourceSubscriptionID diff --git a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/_meta.json b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/_meta.json index b1185cc498f5..c1abda9d623f 100644 --- a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/_meta.json +++ b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "c7616be749e60dc269e2bb50800f06dbca065098", "readme": "/_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", "tag": "package-2020-11-05-preview", "use": "@microsoft.azure/autorest.go@2.1.183", diff --git a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/configurations.go b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/configurations.go index bd7cfde6d96d..05c0bb3fa85f 100644 --- a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/configurations.go +++ b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/configurations.go @@ -54,8 +54,7 @@ func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName st 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Get", err.Error()) } @@ -141,8 +140,7 @@ func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "ListByServer", err.Error()) } @@ -271,8 +269,7 @@ func (client ConfigurationsClient) Update(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Update", err.Error()) } diff --git a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/databases.go b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/databases.go index a5ea3ffd7d74..43e7a773eaa8 100644 --- a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/databases.go +++ b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/databases.go @@ -55,8 +55,7 @@ func (client DatabasesClient) Create(ctx context.Context, resourceGroupName stri 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.DatabasesClient", "Create", err.Error()) } @@ -147,8 +146,7 @@ func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName stri 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.DatabasesClient", "Delete", err.Error()) } @@ -236,8 +234,7 @@ func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.DatabasesClient", "Get", err.Error()) } @@ -323,8 +320,7 @@ func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupNam 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.DatabasesClient", "ListByServer", err.Error()) } diff --git a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/firewallrules.go b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/firewallrules.go index 2c2483d9851d..089eed78f4e2 100644 --- a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/firewallrules.go +++ b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/firewallrules.go @@ -55,8 +55,7 @@ func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGr 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, @@ -154,8 +153,7 @@ func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "Delete", err.Error()) } @@ -243,8 +241,7 @@ func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName str 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "Get", err.Error()) } @@ -330,8 +327,7 @@ func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGrou 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "ListByServer", err.Error()) } diff --git a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/models.go b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/models.go index 7d3f2d6e7f6d..382a9f844c68 100644 --- a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/models.go +++ b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/models.go @@ -1376,7 +1376,7 @@ type ResourceModelWithAllowedPropertySet struct { Type *string `json:"type,omitempty"` // Location - The geo-location where the resource lives Location *string `json:"location,omitempty"` - // ManagedBy - The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. + // ManagedBy - The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. ManagedBy *string `json:"managedBy,omitempty"` // Kind - Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. Kind *string `json:"kind,omitempty"` @@ -1868,6 +1868,10 @@ type ServerProperties struct { HaEnabled HAEnabledEnum `json:"haEnabled,omitempty"` // SourceServerName - The source PostgreSQL server name to restore from. SourceServerName *string `json:"sourceServerName,omitempty"` + // SourceSubscriptionID - The subscription id of source serve PostgreSQL server name to restore from. + SourceSubscriptionID *string `json:"sourceSubscriptionId,omitempty"` + // SourceResourceGroupName - The resource group name of source serve PostgreSQL server name to restore from. + SourceResourceGroupName *string `json:"sourceResourceGroupName,omitempty"` // PointInTimeUTC - Restore point creation time (ISO8601 format), specifying the time to restore from. PointInTimeUTC *date.Time `json:"pointInTimeUTC,omitempty"` // AvailabilityZone - availability Zone information of the server. @@ -1877,6 +1881,7 @@ type ServerProperties struct { // ByokEnforcement - READ-ONLY; Status showing whether the data encryption is enabled with customer-managed keys. ByokEnforcement *string `json:"byokEnforcement,omitempty"` DelegatedSubnetArguments *ServerPropertiesDelegatedSubnetArguments `json:"delegatedSubnetArguments,omitempty"` + PrivateDNSZoneArguments *ServerPropertiesPrivateDNSZoneArguments `json:"privateDnsZoneArguments,omitempty"` // CreateMode - The mode to create a new PostgreSQL server. Possible values include: 'Default', 'PointInTimeRestore' CreateMode CreateMode `json:"createMode,omitempty"` // Tags - Application-specific metadata in the form of key-value pairs. @@ -1910,6 +1915,12 @@ func (sp ServerProperties) MarshalJSON() ([]byte, error) { if sp.SourceServerName != nil { objectMap["sourceServerName"] = sp.SourceServerName } + if sp.SourceSubscriptionID != nil { + objectMap["sourceSubscriptionId"] = sp.SourceSubscriptionID + } + if sp.SourceResourceGroupName != nil { + objectMap["sourceResourceGroupName"] = sp.SourceResourceGroupName + } if sp.PointInTimeUTC != nil { objectMap["pointInTimeUTC"] = sp.PointInTimeUTC } @@ -1919,6 +1930,9 @@ func (sp ServerProperties) MarshalJSON() ([]byte, error) { if sp.DelegatedSubnetArguments != nil { objectMap["delegatedSubnetArguments"] = sp.DelegatedSubnetArguments } + if sp.PrivateDNSZoneArguments != nil { + objectMap["privateDnsZoneArguments"] = sp.PrivateDNSZoneArguments + } if sp.CreateMode != "" { objectMap["createMode"] = sp.CreateMode } @@ -1946,6 +1960,12 @@ type ServerPropertiesForUpdate struct { MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` } +// ServerPropertiesPrivateDNSZoneArguments ... +type ServerPropertiesPrivateDNSZoneArguments struct { + // PrivateDNSZoneArmResourceID - private dns zone arm resource id. + PrivateDNSZoneArmResourceID *string `json:"privateDnsZoneArmResourceId,omitempty"` +} + // ServersCreateFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type ServersCreateFuture struct { diff --git a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/servers.go b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/servers.go index 06cab4e9150a..d0a2cb18d70b 100644 --- a/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/servers.go +++ b/services/preview/postgresql/mgmt/2020-11-05-preview/postgresqlflexibleservers/servers.go @@ -54,8 +54,7 @@ func (client ServersClient) Create(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {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 { @@ -147,8 +146,7 @@ func (client ServersClient) Delete(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Delete", err.Error()) } @@ -234,8 +232,7 @@ func (client ServersClient) Get(ctx context.Context, resourceGroupName string, s 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Get", err.Error()) } @@ -438,8 +435,7 @@ func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGro 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "ListByResourceGroup", err.Error()) } @@ -565,8 +561,7 @@ func (client ServersClient) Restart(ctx context.Context, resourceGroupName strin 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Restart", err.Error()) } @@ -652,8 +647,7 @@ func (client ServersClient) Start(ctx context.Context, resourceGroupName string, 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Start", err.Error()) } @@ -739,8 +733,7 @@ func (client ServersClient) Stop(ctx context.Context, resourceGroupName string, 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Stop", err.Error()) } @@ -828,8 +821,7 @@ func (client ServersClient) Update(ctx context.Context, resourceGroupName string 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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Update", err.Error()) } diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/CHANGELOG.md b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/_meta.json b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/_meta.json new file mode 100644 index 000000000000..a7552cff42f5 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "c7616be749e60dc269e2bb50800f06dbca065098", + "readme": "/_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", + "tag": "package-flexibleserver-2021-06-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-flexibleserver-2021-06-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/advisors.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/advisors.go new file mode 100644 index 000000000000..f3572cd0529e --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/advisors.go @@ -0,0 +1,248 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// AdvisorsClient is the the Microsoft Azure management API provides create, read, update, and delete functionality for +// Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, log +// files and configurations with new business model. +type AdvisorsClient struct { + BaseClient +} + +// NewAdvisorsClient creates an instance of the AdvisorsClient client. +func NewAdvisorsClient(subscriptionID string) AdvisorsClient { + return NewAdvisorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAdvisorsClientWithBaseURI creates an instance of the AdvisorsClient 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 NewAdvisorsClientWithBaseURI(baseURI string, subscriptionID string) AdvisorsClient { + return AdvisorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get a recommendation action advisor. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// advisorName - the advisor name for recommendation action. +func (client AdvisorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, advisorName string) (result Advisor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdvisorsClient.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("postgresqlflexibleservers.AdvisorsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, advisorName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.AdvisorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.AdvisorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.AdvisorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AdvisorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, advisorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advisorName": autorest.Encode("path", advisorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBforPostgreSQL/flexibleServers/{serverName}/advisors/{advisorName}", 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 AdvisorsClient) 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 AdvisorsClient) GetResponder(resp *http.Response) (result Advisor, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list recommendation action advisors. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client AdvisorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result AdvisorsResultListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdvisorsClient.ListByServer") + defer func() { + sc := -1 + if result.arl.Response.Response != nil { + sc = result.arl.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("postgresqlflexibleservers.AdvisorsClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.AdvisorsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.arl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.AdvisorsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.arl, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.AdvisorsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.arl.hasNextLink() && result.arl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client AdvisorsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBforPostgreSQL/flexibleServers/{serverName}/advisors", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client AdvisorsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client AdvisorsClient) ListByServerResponder(resp *http.Response) (result AdvisorsResultList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client AdvisorsClient) listByServerNextResults(ctx context.Context, lastResults AdvisorsResultList) (result AdvisorsResultList, err error) { + req, err := lastResults.advisorsResultListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.AdvisorsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.AdvisorsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.AdvisorsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client AdvisorsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result AdvisorsResultListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdvisorsClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/checknameavailability.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/checknameavailability.go new file mode 100644 index 000000000000..29c14233cc24 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/checknameavailability.go @@ -0,0 +1,118 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// CheckNameAvailabilityClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type CheckNameAvailabilityClient struct { + BaseClient +} + +// NewCheckNameAvailabilityClient creates an instance of the CheckNameAvailabilityClient client. +func NewCheckNameAvailabilityClient(subscriptionID string) CheckNameAvailabilityClient { + return NewCheckNameAvailabilityClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCheckNameAvailabilityClientWithBaseURI creates an instance of the CheckNameAvailabilityClient 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 NewCheckNameAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckNameAvailabilityClient { + return CheckNameAvailabilityClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute check the availability of name for resource +// Parameters: +// nameAvailabilityRequest - the required parameters for checking if resource name is available. +func (client CheckNameAvailabilityClient) Execute(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest) (result NameAvailability, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CheckNameAvailabilityClient.Execute") + 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: nameAvailabilityRequest, + Constraints: []validation.Constraint{{Target: "nameAvailabilityRequest.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", err.Error()) + } + + req, err := client.ExecutePreparer(ctx, nameAvailabilityRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client CheckNameAvailabilityClient) ExecutePreparer(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest) (*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.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/checkNameAvailability", pathParameters), + autorest.WithJSON(nameAvailabilityRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client CheckNameAvailabilityClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client CheckNameAvailabilityClient) ExecuteResponder(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 +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/client.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/client.go new file mode 100644 index 000000000000..3248bf62952c --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/client.go @@ -0,0 +1,43 @@ +// Package postgresqlflexibleservers implements the Azure ARM Postgresqlflexibleservers service API version . +// +// The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL +// resources including servers, databases, firewall rules, VNET rules, security alert policies, log files and +// configurations with new business model. +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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 Postgresqlflexibleservers + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Postgresqlflexibleservers. +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/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/configurations.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/configurations.go new file mode 100644 index 000000000000..633f87cff388 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/configurations.go @@ -0,0 +1,434 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ConfigurationsClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type ConfigurationsClient struct { + BaseClient +} + +// NewConfigurationsClient creates an instance of the ConfigurationsClient client. +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return NewConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationsClientWithBaseURI creates an instance of the ConfigurationsClient 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 NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return ConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets information about a configuration of server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.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("postgresqlflexibleservers.ConfigurationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/configurations/{configurationName}", 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 ConfigurationsClient) 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 ConfigurationsClient) GetResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the configurations in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.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("postgresqlflexibleservers.ConfigurationsClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.clr.hasNextLink() && result.clr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ConfigurationsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/configurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) ListByServerResponder(resp *http.Response) (result ConfigurationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ConfigurationsClient) listByServerNextResults(ctx context.Context, lastResults ConfigurationListResult) (result ConfigurationListResult, err error) { + req, err := lastResults.configurationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConfigurationsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Put updates a configuration of a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +// parameters - the required parameters for updating a server configuration. +func (client ConfigurationsClient) Put(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsPutFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Put") + 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: 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("postgresqlflexibleservers.ConfigurationsClient", "Put", err.Error()) + } + + req, err := client.PutPreparer(ctx, resourceGroupName, serverName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Put", nil, "Failure preparing request") + return + } + + result, err = client.PutSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Put", nil, "Failure sending request") + return + } + + return +} + +// PutPreparer prepares the Put request. +func (client ConfigurationsClient) PutPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/configurations/{configurationName}", pathParameters), + autorest.WithJSON(parameters), + 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 ConfigurationsClient) PutSender(req *http.Request) (future ConfigurationsPutFuture, 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 +} + +// PutResponder handles the response to the Put request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) PutResponder(resp *http.Response) (result Configuration, 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 a configuration of a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +// parameters - the required parameters for updating a server configuration. +func (client ConfigurationsClient) Update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.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: 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("postgresqlflexibleservers.ConfigurationsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/configurations/{configurationName}", 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 ConfigurationsClient) UpdateSender(req *http.Request) (future ConfigurationsUpdateFuture, 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 ConfigurationsClient) UpdateResponder(resp *http.Response) (result Configuration, 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/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/databases.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/databases.go new file mode 100644 index 000000000000..43e7a773eaa8 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/databases.go @@ -0,0 +1,428 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// DatabasesClient is the the Microsoft Azure management API provides create, read, update, and delete functionality +// for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, +// log files and configurations with new business model. +type DatabasesClient struct { + BaseClient +} + +// NewDatabasesClient creates an instance of the DatabasesClient client. +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient 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 NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the required parameters for creating or updating a database. +func (client DatabasesClient) Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (result DatabasesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Create") + 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: 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("postgresqlflexibleservers.DatabasesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DatabasesClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-05-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.DBForPostgreSql/flexibleServers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithJSON(parameters), + 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 DatabasesClient) CreateSender(req *http.Request) (future DatabasesCreateFuture, 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 +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateResponder(resp *http.Response) (result Database, 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 a database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.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: 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("postgresqlflexibleservers.DatabasesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-05-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.DBForPostgreSql/flexibleServers/{serverName}/databases/{databaseName}", 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 DatabasesClient) DeleteSender(req *http.Request) (future DatabasesDeleteFuture, 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 DatabasesClient) 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 gets information about a database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.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("postgresqlflexibleservers.DatabasesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-05-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.DBForPostgreSql/flexibleServers/{serverName}/databases/{databaseName}", 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 DatabasesClient) 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 DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the databases in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.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("postgresqlflexibleservers.DatabasesClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client DatabasesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-05-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.DBForPostgreSql/flexibleServers/{serverName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listByServerNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/enums.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/enums.go new file mode 100644 index 000000000000..872a143fa54b --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/enums.go @@ -0,0 +1,252 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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. + +// ConfigurationDataType enumerates the values for configuration data type. +type ConfigurationDataType string + +const ( + // Boolean ... + Boolean ConfigurationDataType = "Boolean" + // Enumeration ... + Enumeration ConfigurationDataType = "Enumeration" + // Integer ... + Integer ConfigurationDataType = "Integer" + // Numeric ... + Numeric ConfigurationDataType = "Numeric" +) + +// PossibleConfigurationDataTypeValues returns an array of possible values for the ConfigurationDataType const type. +func PossibleConfigurationDataTypeValues() []ConfigurationDataType { + return []ConfigurationDataType{Boolean, Enumeration, Integer, Numeric} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// CreateMode enumerates the values for create mode. +type CreateMode string + +const ( + // Create ... + Create CreateMode = "Create" + // Default ... + Default CreateMode = "Default" + // PointInTimeRestore ... + PointInTimeRestore CreateMode = "PointInTimeRestore" + // Update ... + Update CreateMode = "Update" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{Create, Default, PointInTimeRestore, Update} +} + +// CreateModeForUpdate enumerates the values for create mode for update. +type CreateModeForUpdate string + +const ( + // CreateModeForUpdateDefault ... + CreateModeForUpdateDefault CreateModeForUpdate = "Default" + // CreateModeForUpdateUpdate ... + CreateModeForUpdateUpdate CreateModeForUpdate = "Update" +) + +// PossibleCreateModeForUpdateValues returns an array of possible values for the CreateModeForUpdate const type. +func PossibleCreateModeForUpdateValues() []CreateModeForUpdate { + return []CreateModeForUpdate{CreateModeForUpdateDefault, CreateModeForUpdateUpdate} +} + +// GeoRedundantBackupEnum enumerates the values for geo redundant backup enum. +type GeoRedundantBackupEnum string + +const ( + // Disabled ... + Disabled GeoRedundantBackupEnum = "Disabled" + // Enabled ... + Enabled GeoRedundantBackupEnum = "Enabled" +) + +// PossibleGeoRedundantBackupEnumValues returns an array of possible values for the GeoRedundantBackupEnum const type. +func PossibleGeoRedundantBackupEnumValues() []GeoRedundantBackupEnum { + return []GeoRedundantBackupEnum{Disabled, Enabled} +} + +// HighAvailabilityMode enumerates the values for high availability mode. +type HighAvailabilityMode string + +const ( + // HighAvailabilityModeDisabled ... + HighAvailabilityModeDisabled HighAvailabilityMode = "Disabled" + // HighAvailabilityModeZoneRedundant ... + HighAvailabilityModeZoneRedundant HighAvailabilityMode = "ZoneRedundant" +) + +// PossibleHighAvailabilityModeValues returns an array of possible values for the HighAvailabilityMode const type. +func PossibleHighAvailabilityModeValues() []HighAvailabilityMode { + return []HighAvailabilityMode{HighAvailabilityModeDisabled, HighAvailabilityModeZoneRedundant} +} + +// OperationOrigin enumerates the values for operation origin. +type OperationOrigin string + +const ( + // OperationOriginNotSpecified ... + OperationOriginNotSpecified OperationOrigin = "NotSpecified" + // OperationOriginSystem ... + OperationOriginSystem OperationOrigin = "system" + // OperationOriginUser ... + OperationOriginUser OperationOrigin = "user" +) + +// PossibleOperationOriginValues returns an array of possible values for the OperationOrigin const type. +func PossibleOperationOriginValues() []OperationOrigin { + return []OperationOrigin{OperationOriginNotSpecified, OperationOriginSystem, OperationOriginUser} +} + +// QueryPerformanceInsightResetDataResultState enumerates the values for query performance insight reset data +// result state. +type QueryPerformanceInsightResetDataResultState string + +const ( + // Failed ... + Failed QueryPerformanceInsightResetDataResultState = "Failed" + // Succeeded ... + Succeeded QueryPerformanceInsightResetDataResultState = "Succeeded" +) + +// PossibleQueryPerformanceInsightResetDataResultStateValues returns an array of possible values for the QueryPerformanceInsightResetDataResultState const type. +func PossibleQueryPerformanceInsightResetDataResultStateValues() []QueryPerformanceInsightResetDataResultState { + return []QueryPerformanceInsightResetDataResultState{Failed, Succeeded} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // SystemAssigned ... + SystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{SystemAssigned} +} + +// ServerHAState enumerates the values for server ha state. +type ServerHAState string + +const ( + // CreatingStandby ... + CreatingStandby ServerHAState = "CreatingStandby" + // FailingOver ... + FailingOver ServerHAState = "FailingOver" + // Healthy ... + Healthy ServerHAState = "Healthy" + // NotEnabled ... + NotEnabled ServerHAState = "NotEnabled" + // RemovingStandby ... + RemovingStandby ServerHAState = "RemovingStandby" + // ReplicatingData ... + ReplicatingData ServerHAState = "ReplicatingData" +) + +// PossibleServerHAStateValues returns an array of possible values for the ServerHAState const type. +func PossibleServerHAStateValues() []ServerHAState { + return []ServerHAState{CreatingStandby, FailingOver, Healthy, NotEnabled, RemovingStandby, ReplicatingData} +} + +// ServerPublicNetworkAccessState enumerates the values for server public network access state. +type ServerPublicNetworkAccessState string + +const ( + // ServerPublicNetworkAccessStateDisabled ... + ServerPublicNetworkAccessStateDisabled ServerPublicNetworkAccessState = "Disabled" + // ServerPublicNetworkAccessStateEnabled ... + ServerPublicNetworkAccessStateEnabled ServerPublicNetworkAccessState = "Enabled" +) + +// PossibleServerPublicNetworkAccessStateValues returns an array of possible values for the ServerPublicNetworkAccessState const type. +func PossibleServerPublicNetworkAccessStateValues() []ServerPublicNetworkAccessState { + return []ServerPublicNetworkAccessState{ServerPublicNetworkAccessStateDisabled, ServerPublicNetworkAccessStateEnabled} +} + +// ServerState enumerates the values for server state. +type ServerState string + +const ( + // ServerStateDisabled ... + ServerStateDisabled ServerState = "Disabled" + // ServerStateDropping ... + ServerStateDropping ServerState = "Dropping" + // ServerStateReady ... + ServerStateReady ServerState = "Ready" + // ServerStateStarting ... + ServerStateStarting ServerState = "Starting" + // ServerStateStopped ... + ServerStateStopped ServerState = "Stopped" + // ServerStateStopping ... + ServerStateStopping ServerState = "Stopping" + // ServerStateUpdating ... + ServerStateUpdating ServerState = "Updating" +) + +// PossibleServerStateValues returns an array of possible values for the ServerState const type. +func PossibleServerStateValues() []ServerState { + return []ServerState{ServerStateDisabled, ServerStateDropping, ServerStateReady, ServerStateStarting, ServerStateStopped, ServerStateStopping, ServerStateUpdating} +} + +// ServerVersion enumerates the values for server version. +type ServerVersion string + +const ( + // OneOne ... + OneOne ServerVersion = "11" + // OneThree ... + OneThree ServerVersion = "13" + // OneTwo ... + OneTwo ServerVersion = "12" +) + +// PossibleServerVersionValues returns an array of possible values for the ServerVersion const type. +func PossibleServerVersionValues() []ServerVersion { + return []ServerVersion{OneOne, OneThree, OneTwo} +} + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // Burstable ... + Burstable SkuTier = "Burstable" + // GeneralPurpose ... + GeneralPurpose SkuTier = "GeneralPurpose" + // MemoryOptimized ... + MemoryOptimized SkuTier = "MemoryOptimized" +) + +// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. +func PossibleSkuTierValues() []SkuTier { + return []SkuTier{Burstable, GeneralPurpose, MemoryOptimized} +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/firewallrules.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/firewallrules.go new file mode 100644 index 000000000000..0b1b39e8c8f6 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/firewallrules.go @@ -0,0 +1,436 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// FirewallRulesClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type FirewallRulesClient struct { + BaseClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the FirewallRulesClient 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 NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new firewall rule or updates an existing firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +// parameters - the required parameters for creating or updating a firewall rule. +func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (result FirewallRulesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.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: 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: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Pattern, Rule: `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`, Chain: nil}}}, + {Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Pattern, Rule: `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, firewallRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (future FirewallRulesCreateOrUpdateFuture, 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 FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, 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 a PostgreSQL server firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRulesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.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: 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("postgresqlflexibleservers.FirewallRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) DeleteSender(req *http.Request) (future FirewallRulesDeleteFuture, 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 FirewallRulesClient) 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 list all the firewall rules in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.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("postgresqlflexibleservers.FirewallRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", 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 FirewallRulesClient) 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 FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the firewall rules in a given PostgreSQL server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.frlr.Response.Response != nil { + sc = result.frlr.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("postgresqlflexibleservers.FirewallRulesClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.frlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.frlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.frlr.hasNextLink() && result.frlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FirewallRulesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client FirewallRulesClient) listByServerNextResults(ctx context.Context, lastResults FirewallRuleListResult) (result FirewallRuleListResult, err error) { + req, err := lastResults.firewallRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client FirewallRulesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/getprivatednszonesuffix.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/getprivatednszonesuffix.go new file mode 100644 index 000000000000..3b77a3100cfb --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/getprivatednszonesuffix.go @@ -0,0 +1,116 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// GetPrivateDNSZoneSuffixClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type GetPrivateDNSZoneSuffixClient struct { + BaseClient +} + +// NewGetPrivateDNSZoneSuffixClient creates an instance of the GetPrivateDNSZoneSuffixClient client. +func NewGetPrivateDNSZoneSuffixClient(subscriptionID string) GetPrivateDNSZoneSuffixClient { + return NewGetPrivateDNSZoneSuffixClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGetPrivateDNSZoneSuffixClientWithBaseURI creates an instance of the GetPrivateDNSZoneSuffixClient 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 NewGetPrivateDNSZoneSuffixClientWithBaseURI(baseURI string, subscriptionID string) GetPrivateDNSZoneSuffixClient { + return GetPrivateDNSZoneSuffixClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute get private DNS zone suffix in the cloud +// Parameters: +// body - the required parameters for getting private DNS zone suffix based on server type. +func (client GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context, body string) (result String, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GetPrivateDNSZoneSuffixClient.Execute") + 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("postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", err.Error()) + } + + req, err := client.ExecutePreparer(ctx, body) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client GetPrivateDNSZoneSuffixClient) ExecutePreparer(ctx context.Context, body string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-31-privatepreview" + 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.DBForPostgreSql/getPrivateDnsZoneSuffix", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client GetPrivateDNSZoneSuffixClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client GetPrivateDNSZoneSuffixClient) ExecuteResponder(resp *http.Response) (result String, 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/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/locationbasedcapabilities.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/locationbasedcapabilities.go new file mode 100644 index 000000000000..730032363ebd --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/locationbasedcapabilities.go @@ -0,0 +1,157 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// LocationBasedCapabilitiesClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type LocationBasedCapabilitiesClient struct { + BaseClient +} + +// NewLocationBasedCapabilitiesClient creates an instance of the LocationBasedCapabilitiesClient client. +func NewLocationBasedCapabilitiesClient(subscriptionID string) LocationBasedCapabilitiesClient { + return NewLocationBasedCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLocationBasedCapabilitiesClientWithBaseURI creates an instance of the LocationBasedCapabilitiesClient 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 NewLocationBasedCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) LocationBasedCapabilitiesClient { + return LocationBasedCapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute get capabilities at specified location in a given subscription. +// Parameters: +// locationName - the name of the location. +func (client LocationBasedCapabilitiesClient) Execute(ctx context.Context, locationName string) (result CapabilitiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationBasedCapabilitiesClient.Execute") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.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("postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", err.Error()) + } + + result.fn = client.executeNextResults + req, err := client.ExecutePreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", resp, "Failure sending request") + return + } + + result.clr, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", resp, "Failure responding to request") + return + } + if result.clr.hasNextLink() && result.clr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client LocationBasedCapabilitiesClient) ExecutePreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "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.DBForPostgreSql/locations/{locationName}/capabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client LocationBasedCapabilitiesClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client LocationBasedCapabilitiesClient) ExecuteResponder(resp *http.Response) (result CapabilitiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// executeNextResults retrieves the next set of results, if any. +func (client LocationBasedCapabilitiesClient) executeNextResults(ctx context.Context, lastResults CapabilitiesListResult) (result CapabilitiesListResult, err error) { + req, err := lastResults.capabilitiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "executeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "executeNextResults", resp, "Failure sending next results request") + } + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "executeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ExecuteComplete enumerates all values, automatically crossing page boundaries as required. +func (client LocationBasedCapabilitiesClient) ExecuteComplete(ctx context.Context, locationName string) (result CapabilitiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationBasedCapabilitiesClient.Execute") + 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.Execute(ctx, locationName) + return +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/models.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/models.go new file mode 100644 index 000000000000..8549e3da5a15 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/models.go @@ -0,0 +1,3876 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers" + +// Advisor represents a recommendation action advisor. +type Advisor struct { + autorest.Response `json:"-"` + // Properties - The properties of a recommendation action advisor. + Properties interface{} `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 Advisor. +func (a Advisor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.Properties != nil { + objectMap["properties"] = a.Properties + } + return json.Marshal(objectMap) +} + +// AdvisorsResultList a list of query statistics. +type AdvisorsResultList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of recommendation action advisors. + Value *[]Advisor `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdvisorsResultList. +func (arl AdvisorsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AdvisorsResultListIterator provides access to a complete listing of Advisor values. +type AdvisorsResultListIterator struct { + i int + page AdvisorsResultListPage +} + +// 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 *AdvisorsResultListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdvisorsResultListIterator.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 *AdvisorsResultListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AdvisorsResultListIterator) 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 AdvisorsResultListIterator) Response() AdvisorsResultList { + 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 AdvisorsResultListIterator) Value() Advisor { + if !iter.page.NotDone() { + return Advisor{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AdvisorsResultListIterator type. +func NewAdvisorsResultListIterator(page AdvisorsResultListPage) AdvisorsResultListIterator { + return AdvisorsResultListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (arl AdvisorsResultList) IsEmpty() bool { + return arl.Value == nil || len(*arl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (arl AdvisorsResultList) hasNextLink() bool { + return arl.NextLink != nil && len(*arl.NextLink) != 0 +} + +// advisorsResultListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (arl AdvisorsResultList) advisorsResultListPreparer(ctx context.Context) (*http.Request, error) { + if !arl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(arl.NextLink))) +} + +// AdvisorsResultListPage contains a page of Advisor values. +type AdvisorsResultListPage struct { + fn func(context.Context, AdvisorsResultList) (AdvisorsResultList, error) + arl AdvisorsResultList +} + +// 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 *AdvisorsResultListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdvisorsResultListPage.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.arl) + if err != nil { + return err + } + page.arl = 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 *AdvisorsResultListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AdvisorsResultListPage) NotDone() bool { + return !page.arl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AdvisorsResultListPage) Response() AdvisorsResultList { + return page.arl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AdvisorsResultListPage) Values() []Advisor { + if page.arl.IsEmpty() { + return nil + } + return *page.arl.Value +} + +// Creates a new instance of the AdvisorsResultListPage type. +func NewAdvisorsResultListPage(cur AdvisorsResultList, getNextPage func(context.Context, AdvisorsResultList) (AdvisorsResultList, error)) AdvisorsResultListPage { + return AdvisorsResultListPage{ + fn: getNextPage, + arl: cur, + } +} + +// 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) +} + +// Backup backup properties of a server +type Backup struct { + // BackupRetentionDays - Backup retention days for the server. + BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"` + // GeoRedundantBackup - A value indicating whether Geo-Redundant backup is enabled on the server. Possible values include: 'Enabled', 'Disabled' + GeoRedundantBackup GeoRedundantBackupEnum `json:"geoRedundantBackup,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest restore point time (ISO8601 format) for server. + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for Backup. +func (b Backup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if b.BackupRetentionDays != nil { + objectMap["backupRetentionDays"] = b.BackupRetentionDays + } + if b.GeoRedundantBackup != "" { + objectMap["geoRedundantBackup"] = b.GeoRedundantBackup + } + return json.Marshal(objectMap) +} + +// CapabilitiesListResult location capability +type CapabilitiesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; A list of supported capabilities. + Value *[]CapabilityProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for CapabilitiesListResult. +func (clr CapabilitiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CapabilitiesListResultIterator provides access to a complete listing of CapabilityProperties values. +type CapabilitiesListResultIterator struct { + i int + page CapabilitiesListResultPage +} + +// 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 *CapabilitiesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesListResultIterator.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 *CapabilitiesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CapabilitiesListResultIterator) 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 CapabilitiesListResultIterator) Response() CapabilitiesListResult { + 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 CapabilitiesListResultIterator) Value() CapabilityProperties { + if !iter.page.NotDone() { + return CapabilityProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CapabilitiesListResultIterator type. +func NewCapabilitiesListResultIterator(page CapabilitiesListResultPage) CapabilitiesListResultIterator { + return CapabilitiesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CapabilitiesListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (clr CapabilitiesListResult) hasNextLink() bool { + return clr.NextLink != nil && len(*clr.NextLink) != 0 +} + +// capabilitiesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CapabilitiesListResult) capabilitiesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !clr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CapabilitiesListResultPage contains a page of CapabilityProperties values. +type CapabilitiesListResultPage struct { + fn func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error) + clr CapabilitiesListResult +} + +// 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 *CapabilitiesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesListResultPage.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.clr) + if err != nil { + return err + } + page.clr = 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 *CapabilitiesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CapabilitiesListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CapabilitiesListResultPage) Response() CapabilitiesListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CapabilitiesListResultPage) Values() []CapabilityProperties { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the CapabilitiesListResultPage type. +func NewCapabilitiesListResultPage(cur CapabilitiesListResult, getNextPage func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error)) CapabilitiesListResultPage { + return CapabilitiesListResultPage{ + fn: getNextPage, + clr: cur, + } +} + +// CapabilityProperties location capabilities. +type CapabilityProperties struct { + // Zone - READ-ONLY; zone name + Zone *string `json:"zone,omitempty"` + // GeoBackupSupported - READ-ONLY; A value indicating whether a new server in this region can have geo-backups to paired region. + GeoBackupSupported *bool `json:"geoBackupSupported,omitempty"` + // ZoneRedundantHaSupported - READ-ONLY; A value indicating whether a new server in this region can support multi zone HA. + ZoneRedundantHaSupported *bool `json:"zoneRedundantHaSupported,omitempty"` + // ZoneRedundantHaAndGeoBackupSupported - READ-ONLY; A value indicating whether a new server in this region can have geo-backups to paired region. + ZoneRedundantHaAndGeoBackupSupported *bool `json:"zoneRedundantHaAndGeoBackupSupported,omitempty"` + // SupportedFlexibleServerEditions - READ-ONLY + SupportedFlexibleServerEditions *[]FlexibleServerEditionCapability `json:"supportedFlexibleServerEditions,omitempty"` + // SupportedHyperscaleNodeEditions - READ-ONLY + SupportedHyperscaleNodeEditions *[]HyperscaleNodeEditionCapability `json:"supportedHyperscaleNodeEditions,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for CapabilityProperties. +func (cp CapabilityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CloudError an error response from the Batch service. +type CloudError struct { + Error *ErrorResponse `json:"error,omitempty"` +} + +// Configuration represents a Configuration. +type Configuration struct { + autorest.Response `json:"-"` + // ConfigurationProperties - The properties of a configuration. + *ConfigurationProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,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 Configuration. +func (c Configuration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ConfigurationProperties != nil { + objectMap["properties"] = c.ConfigurationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Configuration struct. +func (c *Configuration) 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 configurationProperties ConfigurationProperties + err = json.Unmarshal(*v, &configurationProperties) + if err != nil { + return err + } + c.ConfigurationProperties = &configurationProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + c.SystemData = &systemData + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ConfigurationListResult a list of server configurations. +type ConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - The list of server configurations. + Value *[]Configuration `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConfigurationListResultIterator provides access to a complete listing of Configuration values. +type ConfigurationListResultIterator struct { + i int + page ConfigurationListResultPage +} + +// 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 *ConfigurationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultIterator.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 *ConfigurationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConfigurationListResultIterator) 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 ConfigurationListResultIterator) Response() ConfigurationListResult { + 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 ConfigurationListResultIterator) Value() Configuration { + if !iter.page.NotDone() { + return Configuration{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ConfigurationListResultIterator type. +func NewConfigurationListResultIterator(page ConfigurationListResultPage) ConfigurationListResultIterator { + return ConfigurationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr ConfigurationListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (clr ConfigurationListResult) hasNextLink() bool { + return clr.NextLink != nil && len(*clr.NextLink) != 0 +} + +// configurationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr ConfigurationListResult) configurationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !clr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// ConfigurationListResultPage contains a page of Configuration values. +type ConfigurationListResultPage struct { + fn func(context.Context, ConfigurationListResult) (ConfigurationListResult, error) + clr ConfigurationListResult +} + +// 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 *ConfigurationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultPage.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.clr) + if err != nil { + return err + } + page.clr = 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 *ConfigurationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConfigurationListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConfigurationListResultPage) Response() ConfigurationListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConfigurationListResultPage) Values() []Configuration { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the ConfigurationListResultPage type. +func NewConfigurationListResultPage(cur ConfigurationListResult, getNextPage func(context.Context, ConfigurationListResult) (ConfigurationListResult, error)) ConfigurationListResultPage { + return ConfigurationListResultPage{ + fn: getNextPage, + clr: cur, + } +} + +// ConfigurationProperties the properties of a configuration. +type ConfigurationProperties struct { + // Value - Value of the configuration. + Value *string `json:"value,omitempty"` + // Description - READ-ONLY; Description of the configuration. + Description *string `json:"description,omitempty"` + // DefaultValue - READ-ONLY; Default value of the configuration. + DefaultValue *string `json:"defaultValue,omitempty"` + // DataType - READ-ONLY; Data type of the configuration. Possible values include: 'Boolean', 'Numeric', 'Integer', 'Enumeration' + DataType ConfigurationDataType `json:"dataType,omitempty"` + // AllowedValues - READ-ONLY; Allowed values of the configuration. + AllowedValues *string `json:"allowedValues,omitempty"` + // Source - Source of the configuration. + Source *string `json:"source,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationProperties. +func (cp ConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.Value != nil { + objectMap["value"] = cp.Value + } + if cp.Source != nil { + objectMap["source"] = cp.Source + } + return json.Marshal(objectMap) +} + +// ConfigurationsPutFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConfigurationsPutFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ConfigurationsClient) (Configuration, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ConfigurationsPutFuture) 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 ConfigurationsPutFuture.Result. +func (future *ConfigurationsPutFuture) result(client ConfigurationsClient) (c Configuration, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsPutFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + c.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ConfigurationsPutFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.PutResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsPutFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ConfigurationsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConfigurationsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ConfigurationsClient) (Configuration, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ConfigurationsUpdateFuture) 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 ConfigurationsUpdateFuture.Result. +func (future *ConfigurationsUpdateFuture) result(client ConfigurationsClient) (c Configuration, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + c.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ConfigurationsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.UpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// Database represents a Database. +type Database struct { + autorest.Response `json:"-"` + // DatabaseProperties - The properties of a database. + *DatabaseProperties `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 Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Database struct. +func (d *Database) 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 databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + d.DatabaseProperties = &databaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseListResult a List of databases. +type DatabaseListResult struct { + autorest.Response `json:"-"` + // Value - The list of databases housed in a server + Value *[]Database `json:"value,omitempty"` + // NextLink - The link used to get the next page of databases. + NextLink *string `json:"nextLink,omitempty"` +} + +// DatabaseListResultIterator provides access to a complete listing of Database values. +type DatabaseListResultIterator struct { + i int + page DatabaseListResultPage +} + +// 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 *DatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultIterator.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 *DatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseListResultIterator) 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 DatabaseListResultIterator) Response() DatabaseListResult { + 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 DatabaseListResultIterator) Value() Database { + if !iter.page.NotDone() { + return Database{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseListResultIterator type. +func NewDatabaseListResultIterator(page DatabaseListResultPage) DatabaseListResultIterator { + return DatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DatabaseListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dlr DatabaseListResult) hasNextLink() bool { + return dlr.NextLink != nil && len(*dlr.NextLink) != 0 +} + +// databaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DatabaseListResult) databaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DatabaseListResultPage contains a page of Database values. +type DatabaseListResultPage struct { + fn func(context.Context, DatabaseListResult) (DatabaseListResult, error) + dlr DatabaseListResult +} + +// 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 *DatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultPage.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.dlr) + if err != nil { + return err + } + page.dlr = 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 *DatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseListResultPage) Response() DatabaseListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseListResultPage) Values() []Database { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DatabaseListResultPage type. +func NewDatabaseListResultPage(cur DatabaseListResult, getNextPage func(context.Context, DatabaseListResult) (DatabaseListResult, error)) DatabaseListResultPage { + return DatabaseListResultPage{ + fn: getNextPage, + dlr: cur, + } +} + +// DatabaseProperties the properties of a database. +type DatabaseProperties struct { + // Charset - The charset of the database. + Charset *string `json:"charset,omitempty"` + // Collation - The collation of the database. + Collation *string `json:"collation,omitempty"` +} + +// DatabasesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesCreateFuture) 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 DatabasesCreateFuture.Result. +func (future *DatabasesCreateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.DatabasesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesCreateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesDeleteFuture) 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 DatabasesDeleteFuture.Result. +func (future *DatabasesDeleteFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.DatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DelegatedSubnetUsage delegated subnet usage data. +type DelegatedSubnetUsage struct { + // SubnetName - READ-ONLY; name of the subnet + SubnetName *string `json:"subnetName,omitempty"` + // Usage - READ-ONLY; Number of used delegated subnets + Usage *int64 `json:"usage,omitempty"` +} + +// MarshalJSON is the custom marshaler for DelegatedSubnetUsage. +func (dsu DelegatedSubnetUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// 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) +} + +// 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 { + // 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 *[]ErrorResponse `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorResponse. +func (er ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// FirewallRule represents a server firewall rule. +type FirewallRule struct { + autorest.Response `json:"-"` + // FirewallRuleProperties - The properties of a firewall rule. + *FirewallRuleProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,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 FirewallRule. +func (fr FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fr.FirewallRuleProperties != nil { + objectMap["properties"] = fr.FirewallRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FirewallRule struct. +func (fr *FirewallRule) 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 firewallRuleProperties FirewallRuleProperties + err = json.Unmarshal(*v, &firewallRuleProperties) + if err != nil { + return err + } + fr.FirewallRuleProperties = &firewallRuleProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + fr.SystemData = &systemData + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fr.Type = &typeVar + } + } + } + + return nil +} + +// FirewallRuleListResult a list of firewall rules. +type FirewallRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of firewall rules in a server. + Value *[]FirewallRule `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// FirewallRuleListResultIterator provides access to a complete listing of FirewallRule values. +type FirewallRuleListResultIterator struct { + i int + page FirewallRuleListResultPage +} + +// 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 *FirewallRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultIterator.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 *FirewallRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter FirewallRuleListResultIterator) 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 FirewallRuleListResultIterator) Response() FirewallRuleListResult { + 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 FirewallRuleListResultIterator) Value() FirewallRule { + if !iter.page.NotDone() { + return FirewallRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the FirewallRuleListResultIterator type. +func NewFirewallRuleListResultIterator(page FirewallRuleListResultPage) FirewallRuleListResultIterator { + return FirewallRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (frlr FirewallRuleListResult) IsEmpty() bool { + return frlr.Value == nil || len(*frlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (frlr FirewallRuleListResult) hasNextLink() bool { + return frlr.NextLink != nil && len(*frlr.NextLink) != 0 +} + +// firewallRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (frlr FirewallRuleListResult) firewallRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !frlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(frlr.NextLink))) +} + +// FirewallRuleListResultPage contains a page of FirewallRule values. +type FirewallRuleListResultPage struct { + fn func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error) + frlr FirewallRuleListResult +} + +// 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 *FirewallRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultPage.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.frlr) + if err != nil { + return err + } + page.frlr = 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 *FirewallRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page FirewallRuleListResultPage) NotDone() bool { + return !page.frlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page FirewallRuleListResultPage) Response() FirewallRuleListResult { + return page.frlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page FirewallRuleListResultPage) Values() []FirewallRule { + if page.frlr.IsEmpty() { + return nil + } + return *page.frlr.Value +} + +// Creates a new instance of the FirewallRuleListResultPage type. +func NewFirewallRuleListResultPage(cur FirewallRuleListResult, getNextPage func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)) FirewallRuleListResultPage { + return FirewallRuleListResultPage{ + fn: getNextPage, + frlr: cur, + } +} + +// FirewallRuleProperties the properties of a server firewall rule. +type FirewallRuleProperties struct { + // StartIPAddress - The start IP address of the server firewall rule. Must be IPv4 format. + StartIPAddress *string `json:"startIpAddress,omitempty"` + // EndIPAddress - The end IP address of the server firewall rule. Must be IPv4 format. + EndIPAddress *string `json:"endIpAddress,omitempty"` +} + +// FirewallRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FirewallRulesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FirewallRulesClient) (FirewallRule, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FirewallRulesCreateOrUpdateFuture) 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 FirewallRulesCreateOrUpdateFuture.Result. +func (future *FirewallRulesCreateOrUpdateFuture) result(client FirewallRulesClient) (fr FirewallRule, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fr.Response.Response, err = future.GetResult(sender); err == nil && fr.Response.Response.StatusCode != http.StatusNoContent { + fr, err = client.CreateOrUpdateResponder(fr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture", "Result", fr.Response.Response, "Failure responding to request") + } + } + return +} + +// FirewallRulesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FirewallRulesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FirewallRulesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FirewallRulesDeleteFuture) 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 FirewallRulesDeleteFuture.Result. +func (future *FirewallRulesDeleteFuture) result(client FirewallRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.FirewallRulesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FlexibleServerEditionCapability flexible server edition capabilities. +type FlexibleServerEditionCapability struct { + // Name - READ-ONLY; Server edition name + Name *string `json:"name,omitempty"` + // SupportedStorageEditions - READ-ONLY; The list of editions supported by this server edition. + SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of server versions supported by this server edition. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for FlexibleServerEditionCapability. +func (fsec FlexibleServerEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// HighAvailability high availability properties of a server +type HighAvailability struct { + // Mode - The HA mode for the server. Possible values include: 'HighAvailabilityModeDisabled', 'HighAvailabilityModeZoneRedundant' + Mode HighAvailabilityMode `json:"mode,omitempty"` + // State - READ-ONLY; A state of a HA server that is visible to user. Possible values include: 'NotEnabled', 'CreatingStandby', 'ReplicatingData', 'FailingOver', 'Healthy', 'RemovingStandby' + State ServerHAState `json:"state,omitempty"` + // StandbyAvailabilityZone - availability zone information of the standby. + StandbyAvailabilityZone *string `json:"standbyAvailabilityZone,omitempty"` +} + +// MarshalJSON is the custom marshaler for HighAvailability. +func (ha HighAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ha.Mode != "" { + objectMap["mode"] = ha.Mode + } + if ha.StandbyAvailabilityZone != nil { + objectMap["standbyAvailabilityZone"] = ha.StandbyAvailabilityZone + } + return json.Marshal(objectMap) +} + +// HyperscaleNodeEditionCapability hyperscale node edition capabilities. +type HyperscaleNodeEditionCapability struct { + // Name - READ-ONLY; Server edition name + Name *string `json:"name,omitempty"` + // SupportedStorageEditions - READ-ONLY; The list of editions supported by this server edition. + SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of server versions supported by this server edition. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // SupportedNodeTypes - READ-ONLY; The list of Node Types supported by this server edition. + SupportedNodeTypes *[]NodeTypeCapability `json:"supportedNodeTypes,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for HyperscaleNodeEditionCapability. +func (hnec HyperscaleNodeEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Identity identity for the resource. +type Identity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'SystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.Type != "" { + objectMap["type"] = i.Type + } + return json.Marshal(objectMap) +} + +// MaintenanceWindow maintenance window properties of a server. +type MaintenanceWindow struct { + // CustomWindow - indicates whether custom window is enabled or disabled + CustomWindow *string `json:"customWindow,omitempty"` + // StartHour - start hour for maintenance window + StartHour *int32 `json:"startHour,omitempty"` + // StartMinute - start minute for maintenance window + StartMinute *int32 `json:"startMinute,omitempty"` + // DayOfWeek - day of week for maintenance window + DayOfWeek *int32 `json:"dayOfWeek,omitempty"` +} + +// NameAvailability represents a resource name availability. +type NameAvailability struct { + autorest.Response `json:"-"` + // Message - Error Message. + Message *string `json:"message,omitempty"` + // NameAvailable - Indicates whether the resource name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Name - name of the PostgreSQL server. + Name *string `json:"name,omitempty"` + // Type - type of the server + Type *string `json:"type,omitempty"` +} + +// NameAvailabilityRequest request from client to check resource name availability. +type NameAvailabilityRequest struct { + // Name - Resource name to verify. + Name *string `json:"name,omitempty"` + // Type - Resource type used for verification. + Type *string `json:"type,omitempty"` +} + +// Network network properties of a server +type Network struct { + // PublicNetworkAccess - READ-ONLY; public network access is enabled or not. Possible values include: 'ServerPublicNetworkAccessStateEnabled', 'ServerPublicNetworkAccessStateDisabled' + PublicNetworkAccess ServerPublicNetworkAccessState `json:"publicNetworkAccess,omitempty"` + // DelegatedSubnetResourceID - delegated subnet arm resource id. + DelegatedSubnetResourceID *string `json:"delegatedSubnetResourceId,omitempty"` + // PrivateDNSZoneArmResourceID - private dns zone arm resource id. + PrivateDNSZoneArmResourceID *string `json:"privateDnsZoneArmResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for Network. +func (n Network) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if n.DelegatedSubnetResourceID != nil { + objectMap["delegatedSubnetResourceId"] = n.DelegatedSubnetResourceID + } + if n.PrivateDNSZoneArmResourceID != nil { + objectMap["privateDnsZoneArmResourceId"] = n.PrivateDNSZoneArmResourceID + } + return json.Marshal(objectMap) +} + +// NodeTypeCapability node type capability +type NodeTypeCapability struct { + // Name - READ-ONLY; note type name + Name *string `json:"name,omitempty"` + // NodeType - READ-ONLY; note type + NodeType *string `json:"nodeType,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for NodeTypeCapability. +func (ntc NodeTypeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Operation REST API operation definition. +type Operation struct { + // Name - READ-ONLY; The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; The localized display information for this particular operation or action. + Display *OperationDisplay `json:"display,omitempty"` + // IsDataAction - Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation. Possible values include: 'OperationOriginNotSpecified', 'OperationOriginUser', 'OperationOriginSystem' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - READ-ONLY; Additional descriptions for the operation. + Properties map[string]interface{} `json:"properties"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.IsDataAction != nil { + objectMap["isDataAction"] = o.IsDataAction + } + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Operation resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Operation description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult a list of resource provider operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - Collection of available operation details + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL 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"` +} + +// Plan plan for the resource. +type Plan struct { + // Name - A user defined name of the 3rd Party Artifact that is being procured. + Name *string `json:"name,omitempty"` + // Publisher - The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string `json:"publisher,omitempty"` + // Product - The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. + Product *string `json:"product,omitempty"` + // PromotionCode - A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The version of the desired product/artifact. + Version *string `json:"version,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) +} + +// QueryPerformanceInsightResetDataResult result of Query Performance Insight data reset. +type QueryPerformanceInsightResetDataResult struct { + autorest.Response `json:"-"` + // Status - Indicates result of the operation. Possible values include: 'Succeeded', 'Failed' + Status QueryPerformanceInsightResetDataResultState `json:"status,omitempty"` + // Message - result operation message. + Message *string `json:"message,omitempty"` +} + +// QueryStatistic represents a Query Statistic. +type QueryStatistic struct { + // QueryStatisticProperties - The properties of a query statistic. + *QueryStatisticProperties `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 QueryStatistic. +func (qs QueryStatistic) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qs.QueryStatisticProperties != nil { + objectMap["properties"] = qs.QueryStatisticProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QueryStatistic struct. +func (qs *QueryStatistic) 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 queryStatisticProperties QueryStatisticProperties + err = json.Unmarshal(*v, &queryStatisticProperties) + if err != nil { + return err + } + qs.QueryStatisticProperties = &queryStatisticProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + qs.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + qs.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + qs.Type = &typeVar + } + } + } + + return nil +} + +// QueryStatisticProperties the properties of a query statistic. +type QueryStatisticProperties struct { + // QueryID - Database query identifier. + QueryID *string `json:"queryId,omitempty"` + // StartTime - Observation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Observation end time. + EndTime *date.Time `json:"endTime,omitempty"` + // AggregationFunction - Aggregation function name. + AggregationFunction *string `json:"aggregationFunction,omitempty"` + // DatabaseNames - The list of database names. + DatabaseNames *[]string `json:"databaseNames,omitempty"` + // QueryExecutionCount - Number of query executions in this time interval. + QueryExecutionCount *int64 `json:"queryExecutionCount,omitempty"` + // MetricName - Metric name. + MetricName *string `json:"metricName,omitempty"` + // MetricDisplayName - Metric display name. + MetricDisplayName *string `json:"metricDisplayName,omitempty"` + // MetricValue - Metric value. + MetricValue *float64 `json:"metricValue,omitempty"` + // MetricValueUnit - Metric value unit. + MetricValueUnit *string `json:"metricValueUnit,omitempty"` +} + +// QueryText represents a Query Text. +type QueryText struct { + autorest.Response `json:"-"` + // QueryTextProperties - The properties of a query text. + *QueryTextProperties `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 QueryText. +func (qt QueryText) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qt.QueryTextProperties != nil { + objectMap["properties"] = qt.QueryTextProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QueryText struct. +func (qt *QueryText) 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 queryTextProperties QueryTextProperties + err = json.Unmarshal(*v, &queryTextProperties) + if err != nil { + return err + } + qt.QueryTextProperties = &queryTextProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + qt.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + qt.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + qt.Type = &typeVar + } + } + } + + return nil +} + +// QueryTextProperties the properties of a query text. +type QueryTextProperties struct { + // QueryID - Query identifier unique to the server. + QueryID *string `json:"queryId,omitempty"` + // QueryText - Query text. + QueryText *string `json:"queryText,omitempty"` +} + +// QueryTextsResultList a list of query texts. +type QueryTextsResultList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of query texts. + Value *[]QueryText `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueryTextsResultList. +func (qtrl QueryTextsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// QueryTextsResultListIterator provides access to a complete listing of QueryText values. +type QueryTextsResultListIterator struct { + i int + page QueryTextsResultListPage +} + +// 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 *QueryTextsResultListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryTextsResultListIterator.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 *QueryTextsResultListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter QueryTextsResultListIterator) 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 QueryTextsResultListIterator) Response() QueryTextsResultList { + 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 QueryTextsResultListIterator) Value() QueryText { + if !iter.page.NotDone() { + return QueryText{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the QueryTextsResultListIterator type. +func NewQueryTextsResultListIterator(page QueryTextsResultListPage) QueryTextsResultListIterator { + return QueryTextsResultListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (qtrl QueryTextsResultList) IsEmpty() bool { + return qtrl.Value == nil || len(*qtrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (qtrl QueryTextsResultList) hasNextLink() bool { + return qtrl.NextLink != nil && len(*qtrl.NextLink) != 0 +} + +// queryTextsResultListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (qtrl QueryTextsResultList) queryTextsResultListPreparer(ctx context.Context) (*http.Request, error) { + if !qtrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(qtrl.NextLink))) +} + +// QueryTextsResultListPage contains a page of QueryText values. +type QueryTextsResultListPage struct { + fn func(context.Context, QueryTextsResultList) (QueryTextsResultList, error) + qtrl QueryTextsResultList +} + +// 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 *QueryTextsResultListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryTextsResultListPage.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.qtrl) + if err != nil { + return err + } + page.qtrl = 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 *QueryTextsResultListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page QueryTextsResultListPage) NotDone() bool { + return !page.qtrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page QueryTextsResultListPage) Response() QueryTextsResultList { + return page.qtrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page QueryTextsResultListPage) Values() []QueryText { + if page.qtrl.IsEmpty() { + return nil + } + return *page.qtrl.Value +} + +// Creates a new instance of the QueryTextsResultListPage type. +func NewQueryTextsResultListPage(cur QueryTextsResultList, getNextPage func(context.Context, QueryTextsResultList) (QueryTextsResultList, error)) QueryTextsResultListPage { + return QueryTextsResultListPage{ + fn: getNextPage, + qtrl: cur, + } +} + +// RecommendationAction represents a Recommendation Action. +type RecommendationAction struct { + // RecommendationActionProperties - The properties of a recommendation action. + *RecommendationActionProperties `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 RecommendationAction. +func (ra RecommendationAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ra.RecommendationActionProperties != nil { + objectMap["properties"] = ra.RecommendationActionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecommendationAction struct. +func (ra *RecommendationAction) 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 recommendationActionProperties RecommendationActionProperties + err = json.Unmarshal(*v, &recommendationActionProperties) + if err != nil { + return err + } + ra.RecommendationActionProperties = &recommendationActionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ra.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ra.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ra.Type = &typeVar + } + } + } + + return nil +} + +// RecommendationActionProperties the properties of a recommendation action. +type RecommendationActionProperties struct { + // AdvisorName - Advisor name. + AdvisorName *string `json:"advisorName,omitempty"` + // SessionID - Recommendation action session identifier. + SessionID *string `json:"sessionId,omitempty"` + // ActionID - Recommendation action identifier. + ActionID *int32 `json:"actionId,omitempty"` + // CreatedTime - Recommendation action creation time. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // ExpirationTime - Recommendation action expiration time. + ExpirationTime *date.Time `json:"expirationTime,omitempty"` + // Reason - Recommendation action reason. + Reason *string `json:"reason,omitempty"` + // RecommendationType - Recommendation action type. + RecommendationType *string `json:"recommendationType,omitempty"` + // Details - Recommendation action details. + Details map[string]*string `json:"details"` +} + +// MarshalJSON is the custom marshaler for RecommendationActionProperties. +func (rap RecommendationActionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rap.AdvisorName != nil { + objectMap["advisorName"] = rap.AdvisorName + } + if rap.SessionID != nil { + objectMap["sessionId"] = rap.SessionID + } + if rap.ActionID != nil { + objectMap["actionId"] = rap.ActionID + } + if rap.CreatedTime != nil { + objectMap["createdTime"] = rap.CreatedTime + } + if rap.ExpirationTime != nil { + objectMap["expirationTime"] = rap.ExpirationTime + } + if rap.Reason != nil { + objectMap["reason"] = rap.Reason + } + if rap.RecommendationType != nil { + objectMap["recommendationType"] = rap.RecommendationType + } + if rap.Details != nil { + objectMap["details"] = rap.Details + } + return json.Marshal(objectMap) +} + +// RecommendationActionsResultList a list of recommendation actions. +type RecommendationActionsResultList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of recommendation action advisors. + Value *[]RecommendationAction `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendationActionsResultList. +func (rarl RecommendationActionsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecommendationActionsResultListIterator provides access to a complete listing of RecommendationAction +// values. +type RecommendationActionsResultListIterator struct { + i int + page RecommendationActionsResultListPage +} + +// 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 *RecommendationActionsResultListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationActionsResultListIterator.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 *RecommendationActionsResultListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RecommendationActionsResultListIterator) 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 RecommendationActionsResultListIterator) Response() RecommendationActionsResultList { + 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 RecommendationActionsResultListIterator) Value() RecommendationAction { + if !iter.page.NotDone() { + return RecommendationAction{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RecommendationActionsResultListIterator type. +func NewRecommendationActionsResultListIterator(page RecommendationActionsResultListPage) RecommendationActionsResultListIterator { + return RecommendationActionsResultListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rarl RecommendationActionsResultList) IsEmpty() bool { + return rarl.Value == nil || len(*rarl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rarl RecommendationActionsResultList) hasNextLink() bool { + return rarl.NextLink != nil && len(*rarl.NextLink) != 0 +} + +// recommendationActionsResultListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rarl RecommendationActionsResultList) recommendationActionsResultListPreparer(ctx context.Context) (*http.Request, error) { + if !rarl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rarl.NextLink))) +} + +// RecommendationActionsResultListPage contains a page of RecommendationAction values. +type RecommendationActionsResultListPage struct { + fn func(context.Context, RecommendationActionsResultList) (RecommendationActionsResultList, error) + rarl RecommendationActionsResultList +} + +// 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 *RecommendationActionsResultListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendationActionsResultListPage.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.rarl) + if err != nil { + return err + } + page.rarl = 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 *RecommendationActionsResultListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RecommendationActionsResultListPage) NotDone() bool { + return !page.rarl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RecommendationActionsResultListPage) Response() RecommendationActionsResultList { + return page.rarl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RecommendationActionsResultListPage) Values() []RecommendationAction { + if page.rarl.IsEmpty() { + return nil + } + return *page.rarl.Value +} + +// Creates a new instance of the RecommendationActionsResultListPage type. +func NewRecommendationActionsResultListPage(cur RecommendationActionsResultList, getNextPage func(context.Context, RecommendationActionsResultList) (RecommendationActionsResultList, error)) RecommendationActionsResultListPage { + return RecommendationActionsResultListPage{ + fn: getNextPage, + rarl: cur, + } +} + +// 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) +} + +// ResourceModelWithAllowedPropertySet the resource model definition containing the full set of allowed +// properties for a resource. Except properties bag, there cannot be a top level property outside of this +// set. +type ResourceModelWithAllowedPropertySet 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"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ManagedBy - The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. + ManagedBy *string `json:"managedBy,omitempty"` + // Kind - Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + Identity *ResourceModelWithAllowedPropertySetIdentity `json:"identity,omitempty"` + Sku *ResourceModelWithAllowedPropertySetSku `json:"sku,omitempty"` + Plan *ResourceModelWithAllowedPropertySetPlan `json:"plan,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceModelWithAllowedPropertySet. +func (rmwaps ResourceModelWithAllowedPropertySet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmwaps.Location != nil { + objectMap["location"] = rmwaps.Location + } + if rmwaps.ManagedBy != nil { + objectMap["managedBy"] = rmwaps.ManagedBy + } + if rmwaps.Kind != nil { + objectMap["kind"] = rmwaps.Kind + } + if rmwaps.Tags != nil { + objectMap["tags"] = rmwaps.Tags + } + if rmwaps.Identity != nil { + objectMap["identity"] = rmwaps.Identity + } + if rmwaps.Sku != nil { + objectMap["sku"] = rmwaps.Sku + } + if rmwaps.Plan != nil { + objectMap["plan"] = rmwaps.Plan + } + return json.Marshal(objectMap) +} + +// ResourceModelWithAllowedPropertySetIdentity ... +type ResourceModelWithAllowedPropertySetIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'SystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceModelWithAllowedPropertySetIdentity. +func (rmwaps ResourceModelWithAllowedPropertySetIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmwaps.Type != "" { + objectMap["type"] = rmwaps.Type + } + return json.Marshal(objectMap) +} + +// ResourceModelWithAllowedPropertySetPlan ... +type ResourceModelWithAllowedPropertySetPlan struct { + // Name - A user defined name of the 3rd Party Artifact that is being procured. + Name *string `json:"name,omitempty"` + // Publisher - The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string `json:"publisher,omitempty"` + // Product - The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. + Product *string `json:"product,omitempty"` + // PromotionCode - A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The version of the desired product/artifact. + Version *string `json:"version,omitempty"` +} + +// ResourceModelWithAllowedPropertySetSku ... +type ResourceModelWithAllowedPropertySetSku struct { + // Name - The name of the sku, typically, tier + family + cores, e.g. Standard_D4s_v3. + Name *string `json:"name,omitempty"` + // Tier - The tier of the particular SKU, e.g. Burstable. Possible values include: 'Burstable', 'GeneralPurpose', 'MemoryOptimized' + Tier SkuTier `json:"tier,omitempty"` +} + +// RestartParameter represents server restart parameters. +type RestartParameter struct { + // RestartWithFailover - Indicates whether to restart the server with failover. + RestartWithFailover *bool `json:"restartWithFailover,omitempty"` + // FailoverMode - Failover mode. + FailoverMode *string `json:"failoverMode,omitempty"` +} + +// Server represents a server. +type Server struct { + autorest.Response `json:"-"` + // Identity - The Azure Active Directory identity of the server. + Identity *Identity `json:"identity,omitempty"` + // Sku - The SKU (pricing tier) of the server. + Sku *Sku `json:"sku,omitempty"` + // ServerProperties - Properties of the server. + *ServerProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // 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 Server. +func (s Server) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.Identity != nil { + objectMap["identity"] = s.Identity + } + if s.Sku != nil { + objectMap["sku"] = s.Sku + } + if s.ServerProperties != nil { + objectMap["properties"] = s.ServerProperties + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + if s.Location != nil { + objectMap["location"] = s.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Server struct. +func (s *Server) 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 "identity": + if v != nil { + var identity Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + s.Identity = &identity + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + s.Sku = &sku + } + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + s.ServerProperties = &serverProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + s.SystemData = &systemData + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ServerForUpdate represents a server to be updated. +type ServerForUpdate struct { + // Location - The location the resource resides in. + Location *string `json:"location,omitempty"` + // Sku - The SKU (pricing tier) of the server. + Sku *Sku `json:"sku,omitempty"` + // ServerPropertiesForUpdate - Properties of the server. + *ServerPropertiesForUpdate `json:"properties,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerForUpdate. +func (sfu ServerForUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sfu.Location != nil { + objectMap["location"] = sfu.Location + } + if sfu.Sku != nil { + objectMap["sku"] = sfu.Sku + } + if sfu.ServerPropertiesForUpdate != nil { + objectMap["properties"] = sfu.ServerPropertiesForUpdate + } + if sfu.Tags != nil { + objectMap["tags"] = sfu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerForUpdate struct. +func (sfu *ServerForUpdate) 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 "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sfu.Location = &location + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + sfu.Sku = &sku + } + case "properties": + if v != nil { + var serverPropertiesForUpdate ServerPropertiesForUpdate + err = json.Unmarshal(*v, &serverPropertiesForUpdate) + if err != nil { + return err + } + sfu.ServerPropertiesForUpdate = &serverPropertiesForUpdate + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sfu.Tags = tags + } + } + } + + return nil +} + +// ServerListResult a list of servers. +type ServerListResult struct { + autorest.Response `json:"-"` + // Value - The list of flexible servers + Value *[]Server `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServerListResultIterator provides access to a complete listing of Server values. +type ServerListResultIterator struct { + i int + page ServerListResultPage +} + +// 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 *ServerListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultIterator.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 *ServerListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerListResultIterator) 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 ServerListResultIterator) Response() ServerListResult { + 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 ServerListResultIterator) Value() Server { + if !iter.page.NotDone() { + return Server{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerListResultIterator type. +func NewServerListResultIterator(page ServerListResultPage) ServerListResultIterator { + return ServerListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServerListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServerListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 0 +} + +// serverListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServerListResult) serverListResultPreparer(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))) +} + +// ServerListResultPage contains a page of Server values. +type ServerListResultPage struct { + fn func(context.Context, ServerListResult) (ServerListResult, error) + slr ServerListResult +} + +// 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 *ServerListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultPage.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 *ServerListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerListResultPage) Response() ServerListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerListResultPage) Values() []Server { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the ServerListResultPage type. +func NewServerListResultPage(cur ServerListResult, getNextPage func(context.Context, ServerListResult) (ServerListResult, error)) ServerListResultPage { + return ServerListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// ServerProperties the properties of a server. +type ServerProperties struct { + // AdministratorLogin - The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for server creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Version - PostgreSQL Server version. Possible values include: 'OneThree', 'OneTwo', 'OneOne' + Version ServerVersion `json:"version,omitempty"` + // MinorVersion - READ-ONLY; The minor version of the server. + MinorVersion *string `json:"minorVersion,omitempty"` + // State - READ-ONLY; A state of a server that is visible to user. Possible values include: 'ServerStateReady', 'ServerStateDropping', 'ServerStateDisabled', 'ServerStateStarting', 'ServerStateStopping', 'ServerStateStopped', 'ServerStateUpdating' + State ServerState `json:"state,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of a server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // Storage - Storage properties of a server. + Storage *Storage `json:"storage,omitempty"` + // Backup - Backup properties of a server. + Backup *Backup `json:"backup,omitempty"` + // Network - Network properties of a server. + Network *Network `json:"network,omitempty"` + // HighAvailability - High availability properties of a server. + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + // MaintenanceWindow - Maintenance window properties of a server. + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + // SourceServerResourceID - The source server resource ID to restore from. It's required when 'createMode' is 'PointInTimeRestore'. + SourceServerResourceID *string `json:"sourceServerResourceId,omitempty"` + // PointInTimeUTC - Restore point creation time (ISO8601 format), specifying the time to restore from. It's required when 'createMode' is 'PointInTimeRestore'. + PointInTimeUTC *date.Time `json:"pointInTimeUTC,omitempty"` + // AvailabilityZone - availability zone information of the server. + AvailabilityZone *string `json:"availabilityZone,omitempty"` + // CreateMode - The mode to create a new PostgreSQL server. Possible values include: 'Default', 'Create', 'Update', 'PointInTimeRestore' + CreateMode CreateMode `json:"createMode,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerProperties. +func (sp ServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.AdministratorLogin != nil { + objectMap["administratorLogin"] = sp.AdministratorLogin + } + if sp.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = sp.AdministratorLoginPassword + } + if sp.Version != "" { + objectMap["version"] = sp.Version + } + if sp.Storage != nil { + objectMap["storage"] = sp.Storage + } + if sp.Backup != nil { + objectMap["backup"] = sp.Backup + } + if sp.Network != nil { + objectMap["network"] = sp.Network + } + if sp.HighAvailability != nil { + objectMap["highAvailability"] = sp.HighAvailability + } + if sp.MaintenanceWindow != nil { + objectMap["maintenanceWindow"] = sp.MaintenanceWindow + } + if sp.SourceServerResourceID != nil { + objectMap["sourceServerResourceId"] = sp.SourceServerResourceID + } + if sp.PointInTimeUTC != nil { + objectMap["pointInTimeUTC"] = sp.PointInTimeUTC + } + if sp.AvailabilityZone != nil { + objectMap["availabilityZone"] = sp.AvailabilityZone + } + if sp.CreateMode != "" { + objectMap["createMode"] = sp.CreateMode + } + if sp.Tags != nil { + objectMap["tags"] = sp.Tags + } + return json.Marshal(objectMap) +} + +// ServerPropertiesForUpdate ... +type ServerPropertiesForUpdate struct { + // AdministratorLoginPassword - The password of the administrator login. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Storage - Storage properties of a server. + Storage *Storage `json:"storage,omitempty"` + // Backup - Backup properties of a server. + Backup *Backup `json:"backup,omitempty"` + // HighAvailability - High availability properties of a server. + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + // MaintenanceWindow - Maintenance window properties of a server. + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + // CreateMode - The mode to update a new PostgreSQL server. Possible values include: 'CreateModeForUpdateDefault', 'CreateModeForUpdateUpdate' + CreateMode CreateModeForUpdate `json:"createMode,omitempty"` +} + +// ServersCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersCreateFuture) 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 ServersCreateFuture.Result. +func (future *ServersCreateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.CreateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersCreateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersDeleteFuture) 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 ServersDeleteFuture.Result. +func (future *ServersDeleteFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersRestartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersRestartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersRestartFuture) 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 ServersRestartFuture.Result. +func (future *ServersRestartFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersRestartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersRestartFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersStartFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersStartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersStartFuture) 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 ServersStartFuture.Result. +func (future *ServersStartFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersStartFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersStopFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersStopFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersStopFuture) 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 ServersStopFuture.Result. +func (future *ServersStopFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersStopFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersStopFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersUpdateFuture) 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 ServersUpdateFuture.Result. +func (future *ServersUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.UpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerVersionCapability server version capabilities. +type ServerVersionCapability struct { + // Name - READ-ONLY; server version + Name *string `json:"name,omitempty"` + // SupportedVcores - READ-ONLY + SupportedVcores *[]VcoreCapability `json:"supportedVcores,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVersionCapability. +func (svc ServerVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Sku sku information related properties of a server. +type Sku struct { + // Name - The name of the sku, typically, tier + family + cores, e.g. Standard_D4s_v3. + Name *string `json:"name,omitempty"` + // Tier - The tier of the particular SKU, e.g. Burstable. Possible values include: 'Burstable', 'GeneralPurpose', 'MemoryOptimized' + Tier SkuTier `json:"tier,omitempty"` +} + +// Storage storage properties of a server +type Storage struct { + // StorageSizeGB - Max storage allowed for a server. + StorageSizeGB *int32 `json:"storageSizeGB,omitempty"` +} + +// StorageEditionCapability storage edition capability +type StorageEditionCapability struct { + // Name - READ-ONLY; storage edition name + Name *string `json:"name,omitempty"` + // SupportedStorageMB - READ-ONLY + SupportedStorageMB *[]StorageMBCapability `json:"supportedStorageMB,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageEditionCapability. +func (sec StorageEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// StorageMBCapability storage size in MB capability +type StorageMBCapability struct { + // Name - READ-ONLY; storage MB name + Name *string `json:"name,omitempty"` + // SupportedIops - READ-ONLY; supported IOPS + SupportedIops *int64 `json:"supportedIops,omitempty"` + // StorageSizeMB - READ-ONLY; storage size in MB + StorageSizeMB *int64 `json:"storageSizeMB,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageMBCapability. +func (smc StorageMBCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// String ... +type String struct { + autorest.Response `json:"-"` + Value *string `json:"value,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: 'User', 'Application', 'ManagedIdentity', 'Key' + 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: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TopQueryStatisticsInput input to get top query statistics +type TopQueryStatisticsInput struct { + // TopQueryStatisticsInputProperties - The properties of a wait statistics input. + *TopQueryStatisticsInputProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for TopQueryStatisticsInput. +func (tqsi TopQueryStatisticsInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tqsi.TopQueryStatisticsInputProperties != nil { + objectMap["properties"] = tqsi.TopQueryStatisticsInputProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TopQueryStatisticsInput struct. +func (tqsi *TopQueryStatisticsInput) 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 topQueryStatisticsInputProperties TopQueryStatisticsInputProperties + err = json.Unmarshal(*v, &topQueryStatisticsInputProperties) + if err != nil { + return err + } + tqsi.TopQueryStatisticsInputProperties = &topQueryStatisticsInputProperties + } + } + } + + return nil +} + +// TopQueryStatisticsInputProperties the properties for input to get top query statistics +type TopQueryStatisticsInputProperties struct { + // NumberOfTopQueries - Max number of top queries to return. + NumberOfTopQueries *int32 `json:"numberOfTopQueries,omitempty"` + // AggregationFunction - Aggregation function name. + AggregationFunction *string `json:"aggregationFunction,omitempty"` + // ObservedMetric - Observed metric name. + ObservedMetric *string `json:"observedMetric,omitempty"` + // ObservationStartTime - Observation start time. + ObservationStartTime *date.Time `json:"observationStartTime,omitempty"` + // ObservationEndTime - Observation end time. + ObservationEndTime *date.Time `json:"observationEndTime,omitempty"` + // AggregationWindow - Aggregation interval type in ISO 8601 format. + AggregationWindow *string `json:"aggregationWindow,omitempty"` +} + +// TopQueryStatisticsResultList a list of query statistics. +type TopQueryStatisticsResultList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of top query statistics. + Value *[]QueryStatistic `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for TopQueryStatisticsResultList. +func (tqsrl TopQueryStatisticsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TopQueryStatisticsResultListIterator provides access to a complete listing of QueryStatistic values. +type TopQueryStatisticsResultListIterator struct { + i int + page TopQueryStatisticsResultListPage +} + +// 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 *TopQueryStatisticsResultListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopQueryStatisticsResultListIterator.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 *TopQueryStatisticsResultListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TopQueryStatisticsResultListIterator) 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 TopQueryStatisticsResultListIterator) Response() TopQueryStatisticsResultList { + 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 TopQueryStatisticsResultListIterator) Value() QueryStatistic { + if !iter.page.NotDone() { + return QueryStatistic{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TopQueryStatisticsResultListIterator type. +func NewTopQueryStatisticsResultListIterator(page TopQueryStatisticsResultListPage) TopQueryStatisticsResultListIterator { + return TopQueryStatisticsResultListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tqsrl TopQueryStatisticsResultList) IsEmpty() bool { + return tqsrl.Value == nil || len(*tqsrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tqsrl TopQueryStatisticsResultList) hasNextLink() bool { + return tqsrl.NextLink != nil && len(*tqsrl.NextLink) != 0 +} + +// topQueryStatisticsResultListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tqsrl TopQueryStatisticsResultList) topQueryStatisticsResultListPreparer(ctx context.Context) (*http.Request, error) { + if !tqsrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tqsrl.NextLink))) +} + +// TopQueryStatisticsResultListPage contains a page of QueryStatistic values. +type TopQueryStatisticsResultListPage struct { + fn func(context.Context, TopQueryStatisticsResultList) (TopQueryStatisticsResultList, error) + tqsrl TopQueryStatisticsResultList +} + +// 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 *TopQueryStatisticsResultListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopQueryStatisticsResultListPage.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.tqsrl) + if err != nil { + return err + } + page.tqsrl = 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 *TopQueryStatisticsResultListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TopQueryStatisticsResultListPage) NotDone() bool { + return !page.tqsrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TopQueryStatisticsResultListPage) Response() TopQueryStatisticsResultList { + return page.tqsrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TopQueryStatisticsResultListPage) Values() []QueryStatistic { + if page.tqsrl.IsEmpty() { + return nil + } + return *page.tqsrl.Value +} + +// Creates a new instance of the TopQueryStatisticsResultListPage type. +func NewTopQueryStatisticsResultListPage(cur TopQueryStatisticsResultList, getNextPage func(context.Context, TopQueryStatisticsResultList) (TopQueryStatisticsResultList, error)) TopQueryStatisticsResultListPage { + return TopQueryStatisticsResultListPage{ + fn: getNextPage, + tqsrl: cur, + } +} + +// 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) +} + +// VcoreCapability vcores capability +type VcoreCapability struct { + // Name - READ-ONLY; vCore name + Name *string `json:"name,omitempty"` + // VCores - READ-ONLY; supported vCores + VCores *int64 `json:"vCores,omitempty"` + // SupportedIops - READ-ONLY; supported IOPS + SupportedIops *int64 `json:"supportedIops,omitempty"` + // SupportedMemoryPerVcoreMB - READ-ONLY; supported memory per vCore in MB + SupportedMemoryPerVcoreMB *int64 `json:"supportedMemoryPerVcoreMB,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for VcoreCapability. +func (vc VcoreCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualNetworkSubnetUsageParameter virtual network subnet usage parameter +type VirtualNetworkSubnetUsageParameter struct { + // VirtualNetworkArmResourceID - Virtual network resource id. + VirtualNetworkArmResourceID *string `json:"virtualNetworkArmResourceId,omitempty"` +} + +// VirtualNetworkSubnetUsageResult virtual network subnet usage data. +type VirtualNetworkSubnetUsageResult struct { + autorest.Response `json:"-"` + // DelegatedSubnetsUsage - READ-ONLY + DelegatedSubnetsUsage *[]DelegatedSubnetUsage `json:"delegatedSubnetsUsage,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkSubnetUsageResult. +func (vnsur VirtualNetworkSubnetUsageResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WaitStatistic represents a Wait Statistic. +type WaitStatistic struct { + // WaitStatisticProperties - The properties of a wait statistic. + *WaitStatisticProperties `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 WaitStatistic. +func (ws WaitStatistic) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ws.WaitStatisticProperties != nil { + objectMap["properties"] = ws.WaitStatisticProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WaitStatistic struct. +func (ws *WaitStatistic) 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 waitStatisticProperties WaitStatisticProperties + err = json.Unmarshal(*v, &waitStatisticProperties) + if err != nil { + return err + } + ws.WaitStatisticProperties = &waitStatisticProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ws.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ws.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ws.Type = &typeVar + } + } + } + + return nil +} + +// WaitStatisticProperties the properties of a wait statistic. +type WaitStatisticProperties struct { + // StartTime - Observation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Observation end time. + EndTime *date.Time `json:"endTime,omitempty"` + // EventName - Wait event name. + EventName *string `json:"eventName,omitempty"` + // EventTypeName - Wait event type name. + EventTypeName *string `json:"eventTypeName,omitempty"` + // QueryID - Database query identifier. + QueryID *int64 `json:"queryId,omitempty"` + // DatabaseName - Database Name. + DatabaseName *string `json:"databaseName,omitempty"` + // UserID - Database user identifier. + UserID *int64 `json:"userId,omitempty"` + // Count - Wait event count observed in this time interval. + Count *int64 `json:"count,omitempty"` + // TotalTimeInMs - Total time of wait in milliseconds in this time interval. + TotalTimeInMs *float64 `json:"totalTimeInMs,omitempty"` +} + +// WaitStatisticsInput input to get wait statistics +type WaitStatisticsInput struct { + // WaitStatisticsInputProperties - The properties of a wait statistics input. + *WaitStatisticsInputProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for WaitStatisticsInput. +func (wsi WaitStatisticsInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wsi.WaitStatisticsInputProperties != nil { + objectMap["properties"] = wsi.WaitStatisticsInputProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WaitStatisticsInput struct. +func (wsi *WaitStatisticsInput) 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 waitStatisticsInputProperties WaitStatisticsInputProperties + err = json.Unmarshal(*v, &waitStatisticsInputProperties) + if err != nil { + return err + } + wsi.WaitStatisticsInputProperties = &waitStatisticsInputProperties + } + } + } + + return nil +} + +// WaitStatisticsInputProperties the properties for input to get wait statistics +type WaitStatisticsInputProperties struct { + // ObservationStartTime - Observation start time. + ObservationStartTime *date.Time `json:"observationStartTime,omitempty"` + // ObservationEndTime - Observation end time. + ObservationEndTime *date.Time `json:"observationEndTime,omitempty"` + // AggregationWindow - Aggregation interval type in ISO 8601 format. + AggregationWindow *string `json:"aggregationWindow,omitempty"` +} + +// WaitStatisticsResultList a list of wait statistics. +type WaitStatisticsResultList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of wait statistics. + Value *[]WaitStatistic `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for WaitStatisticsResultList. +func (wsrl WaitStatisticsResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WaitStatisticsResultListIterator provides access to a complete listing of WaitStatistic values. +type WaitStatisticsResultListIterator struct { + i int + page WaitStatisticsResultListPage +} + +// 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 *WaitStatisticsResultListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WaitStatisticsResultListIterator.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 *WaitStatisticsResultListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WaitStatisticsResultListIterator) 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 WaitStatisticsResultListIterator) Response() WaitStatisticsResultList { + 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 WaitStatisticsResultListIterator) Value() WaitStatistic { + if !iter.page.NotDone() { + return WaitStatistic{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WaitStatisticsResultListIterator type. +func NewWaitStatisticsResultListIterator(page WaitStatisticsResultListPage) WaitStatisticsResultListIterator { + return WaitStatisticsResultListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wsrl WaitStatisticsResultList) IsEmpty() bool { + return wsrl.Value == nil || len(*wsrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wsrl WaitStatisticsResultList) hasNextLink() bool { + return wsrl.NextLink != nil && len(*wsrl.NextLink) != 0 +} + +// waitStatisticsResultListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wsrl WaitStatisticsResultList) waitStatisticsResultListPreparer(ctx context.Context) (*http.Request, error) { + if !wsrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wsrl.NextLink))) +} + +// WaitStatisticsResultListPage contains a page of WaitStatistic values. +type WaitStatisticsResultListPage struct { + fn func(context.Context, WaitStatisticsResultList) (WaitStatisticsResultList, error) + wsrl WaitStatisticsResultList +} + +// 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 *WaitStatisticsResultListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WaitStatisticsResultListPage.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.wsrl) + if err != nil { + return err + } + page.wsrl = 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 *WaitStatisticsResultListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WaitStatisticsResultListPage) NotDone() bool { + return !page.wsrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WaitStatisticsResultListPage) Response() WaitStatisticsResultList { + return page.wsrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WaitStatisticsResultListPage) Values() []WaitStatistic { + if page.wsrl.IsEmpty() { + return nil + } + return *page.wsrl.Value +} + +// Creates a new instance of the WaitStatisticsResultListPage type. +func NewWaitStatisticsResultListPage(cur WaitStatisticsResultList, getNextPage func(context.Context, WaitStatisticsResultList) (WaitStatisticsResultList, error)) WaitStatisticsResultListPage { + return WaitStatisticsResultListPage{ + fn: getNextPage, + wsrl: cur, + } +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/operations.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/operations.go new file mode 100644 index 000000000000..f1013115b27c --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/operations.go @@ -0,0 +1,100 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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 the Microsoft Azure management API provides create, read, update, and delete functionality +// for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, +// log files and configurations with new business model. +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. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure responding to request") + 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.DBForPostgreSql/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 +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/postgresqlflexibleserversapi/interfaces.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/postgresqlflexibleserversapi/interfaces.go new file mode 100644 index 000000000000..219151ee71ed --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/postgresqlflexibleserversapi/interfaces.go @@ -0,0 +1,147 @@ +package postgresqlflexibleserversapi + +// Copyright (c) Microsoft Corporation. All rights 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/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers" +) + +// ServersClientAPI contains the set of methods on the ServersClient type. +type ServersClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, parameters postgresqlflexibleservers.Server) (result postgresqlflexibleservers.ServersCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ServersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.Server, err error) + List(ctx context.Context) (result postgresqlflexibleservers.ServerListResultPage, err error) + ListComplete(ctx context.Context) (result postgresqlflexibleservers.ServerListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result postgresqlflexibleservers.ServerListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result postgresqlflexibleservers.ServerListResultIterator, err error) + Restart(ctx context.Context, resourceGroupName string, serverName string, parameters *postgresqlflexibleservers.RestartParameter) (result postgresqlflexibleservers.ServersRestartFuture, err error) + Start(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ServersStartFuture, err error) + Stop(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ServersStopFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, parameters postgresqlflexibleservers.ServerForUpdate) (result postgresqlflexibleservers.ServersUpdateFuture, err error) +} + +var _ ServersClientAPI = (*postgresqlflexibleservers.ServersClient)(nil) + +// FirewallRulesClientAPI contains the set of methods on the FirewallRulesClient type. +type FirewallRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters postgresqlflexibleservers.FirewallRule) (result postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result postgresqlflexibleservers.FirewallRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result postgresqlflexibleservers.FirewallRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.FirewallRuleListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.FirewallRuleListResultIterator, err error) +} + +var _ FirewallRulesClientAPI = (*postgresqlflexibleservers.FirewallRulesClient)(nil) + +// ConfigurationsClientAPI contains the set of methods on the ConfigurationsClient type. +type ConfigurationsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (result postgresqlflexibleservers.Configuration, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ConfigurationListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ConfigurationListResultIterator, err error) + Put(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters postgresqlflexibleservers.Configuration) (result postgresqlflexibleservers.ConfigurationsPutFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters postgresqlflexibleservers.Configuration) (result postgresqlflexibleservers.ConfigurationsUpdateFuture, err error) +} + +var _ ConfigurationsClientAPI = (*postgresqlflexibleservers.ConfigurationsClient)(nil) + +// CheckNameAvailabilityClientAPI contains the set of methods on the CheckNameAvailabilityClient type. +type CheckNameAvailabilityClientAPI interface { + Execute(ctx context.Context, nameAvailabilityRequest postgresqlflexibleservers.NameAvailabilityRequest) (result postgresqlflexibleservers.NameAvailability, err error) +} + +var _ CheckNameAvailabilityClientAPI = (*postgresqlflexibleservers.CheckNameAvailabilityClient)(nil) + +// LocationBasedCapabilitiesClientAPI contains the set of methods on the LocationBasedCapabilitiesClient type. +type LocationBasedCapabilitiesClientAPI interface { + Execute(ctx context.Context, locationName string) (result postgresqlflexibleservers.CapabilitiesListResultPage, err error) + ExecuteComplete(ctx context.Context, locationName string) (result postgresqlflexibleservers.CapabilitiesListResultIterator, err error) +} + +var _ LocationBasedCapabilitiesClientAPI = (*postgresqlflexibleservers.LocationBasedCapabilitiesClient)(nil) + +// VirtualNetworkSubnetUsageClientAPI contains the set of methods on the VirtualNetworkSubnetUsageClient type. +type VirtualNetworkSubnetUsageClientAPI interface { + Execute(ctx context.Context, locationName string, parameters postgresqlflexibleservers.VirtualNetworkSubnetUsageParameter) (result postgresqlflexibleservers.VirtualNetworkSubnetUsageResult, err error) +} + +var _ VirtualNetworkSubnetUsageClientAPI = (*postgresqlflexibleservers.VirtualNetworkSubnetUsageClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result postgresqlflexibleservers.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*postgresqlflexibleservers.OperationsClient)(nil) + +// DatabasesClientAPI contains the set of methods on the DatabasesClient type. +type DatabasesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters postgresqlflexibleservers.Database) (result postgresqlflexibleservers.DatabasesCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result postgresqlflexibleservers.DatabasesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result postgresqlflexibleservers.Database, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.DatabaseListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.DatabaseListResultIterator, err error) +} + +var _ DatabasesClientAPI = (*postgresqlflexibleservers.DatabasesClient)(nil) + +// GetPrivateDNSZoneSuffixClientAPI contains the set of methods on the GetPrivateDNSZoneSuffixClient type. +type GetPrivateDNSZoneSuffixClientAPI interface { + Execute(ctx context.Context, body string) (result postgresqlflexibleservers.String, err error) +} + +var _ GetPrivateDNSZoneSuffixClientAPI = (*postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient)(nil) + +// AdvisorsClientAPI contains the set of methods on the AdvisorsClient type. +type AdvisorsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, advisorName string) (result postgresqlflexibleservers.Advisor, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.AdvisorsResultListPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.AdvisorsResultListIterator, err error) +} + +var _ AdvisorsClientAPI = (*postgresqlflexibleservers.AdvisorsClient)(nil) + +// RecommendedActionsClientAPI contains the set of methods on the RecommendedActionsClient type. +type RecommendedActionsClientAPI interface { + ListByServer(ctx context.Context, resourceGroupName string, serverName string, advisorName string, sessionID string) (result postgresqlflexibleservers.RecommendationActionsResultListPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, advisorName string, sessionID string) (result postgresqlflexibleservers.RecommendationActionsResultListIterator, err error) +} + +var _ RecommendedActionsClientAPI = (*postgresqlflexibleservers.RecommendedActionsClient)(nil) + +// QueryPerformanceInsightDataClientAPI contains the set of methods on the QueryPerformanceInsightDataClient type. +type QueryPerformanceInsightDataClientAPI interface { + Reset(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.QueryPerformanceInsightResetDataResult, err error) +} + +var _ QueryPerformanceInsightDataClientAPI = (*postgresqlflexibleservers.QueryPerformanceInsightDataClient)(nil) + +// QueryTextsClientAPI contains the set of methods on the QueryTextsClient type. +type QueryTextsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, queryID string) (result postgresqlflexibleservers.QueryText, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string, queryIds []string) (result postgresqlflexibleservers.QueryTextsResultListPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, queryIds []string) (result postgresqlflexibleservers.QueryTextsResultListIterator, err error) +} + +var _ QueryTextsClientAPI = (*postgresqlflexibleservers.QueryTextsClient)(nil) + +// TopQueryStatisticsClientAPI contains the set of methods on the TopQueryStatisticsClient type. +type TopQueryStatisticsClientAPI interface { + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.TopQueryStatisticsResultListPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.TopQueryStatisticsResultListIterator, err error) +} + +var _ TopQueryStatisticsClientAPI = (*postgresqlflexibleservers.TopQueryStatisticsClient)(nil) + +// WaitStatisticsClientAPI contains the set of methods on the WaitStatisticsClient type. +type WaitStatisticsClientAPI interface { + ListByServer(ctx context.Context, resourceGroupName string, serverName string, parameters postgresqlflexibleservers.WaitStatisticsInput) (result postgresqlflexibleservers.WaitStatisticsResultListPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, parameters postgresqlflexibleservers.WaitStatisticsInput) (result postgresqlflexibleservers.WaitStatisticsResultListIterator, err error) +} + +var _ WaitStatisticsClientAPI = (*postgresqlflexibleservers.WaitStatisticsClient)(nil) diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/queryperformanceinsightdata.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/queryperformanceinsightdata.go new file mode 100644 index 000000000000..1d3e76f12508 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/queryperformanceinsightdata.go @@ -0,0 +1,120 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// QueryPerformanceInsightDataClient is the the Microsoft Azure management API provides create, read, update, and +// delete functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, +// security alert policies, log files and configurations with new business model. +type QueryPerformanceInsightDataClient struct { + BaseClient +} + +// NewQueryPerformanceInsightDataClient creates an instance of the QueryPerformanceInsightDataClient client. +func NewQueryPerformanceInsightDataClient(subscriptionID string) QueryPerformanceInsightDataClient { + return NewQueryPerformanceInsightDataClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewQueryPerformanceInsightDataClientWithBaseURI creates an instance of the QueryPerformanceInsightDataClient 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 NewQueryPerformanceInsightDataClientWithBaseURI(baseURI string, subscriptionID string) QueryPerformanceInsightDataClient { + return QueryPerformanceInsightDataClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Reset reset data for Query Performance Insight. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client QueryPerformanceInsightDataClient) Reset(ctx context.Context, resourceGroupName string, serverName string) (result QueryPerformanceInsightResetDataResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryPerformanceInsightDataClient.Reset") + 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("postgresqlflexibleservers.QueryPerformanceInsightDataClient", "Reset", err.Error()) + } + + req, err := client.ResetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryPerformanceInsightDataClient", "Reset", nil, "Failure preparing request") + return + } + + resp, err := client.ResetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryPerformanceInsightDataClient", "Reset", resp, "Failure sending request") + return + } + + result, err = client.ResetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryPerformanceInsightDataClient", "Reset", resp, "Failure responding to request") + return + } + + return +} + +// ResetPreparer prepares the Reset request. +func (client QueryPerformanceInsightDataClient) ResetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBforPostgreSQL/flexibleServers/{serverName}/resetQueryPerformanceInsightData", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResetSender sends the Reset request. The method will close the +// http.Response Body if it receives an error. +func (client QueryPerformanceInsightDataClient) ResetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ResetResponder handles the response to the Reset request. The method always +// closes the http.Response Body. +func (client QueryPerformanceInsightDataClient) ResetResponder(resp *http.Response) (result QueryPerformanceInsightResetDataResult, 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/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/querytexts.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/querytexts.go new file mode 100644 index 000000000000..a2ce05dd5cc4 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/querytexts.go @@ -0,0 +1,252 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// QueryTextsClient is the the Microsoft Azure management API provides create, read, update, and delete functionality +// for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, +// log files and configurations with new business model. +type QueryTextsClient struct { + BaseClient +} + +// NewQueryTextsClient creates an instance of the QueryTextsClient client. +func NewQueryTextsClient(subscriptionID string) QueryTextsClient { + return NewQueryTextsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewQueryTextsClientWithBaseURI creates an instance of the QueryTextsClient 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 NewQueryTextsClientWithBaseURI(baseURI string, subscriptionID string) QueryTextsClient { + return QueryTextsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieve the Query-Store query texts for the queryId. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// queryID - the Query-Store query identifier. +func (client QueryTextsClient) Get(ctx context.Context, resourceGroupName string, serverName string, queryID string) (result QueryText, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryTextsClient.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("postgresqlflexibleservers.QueryTextsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, queryID) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryTextsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryTextsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryTextsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client QueryTextsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, queryID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "queryId": autorest.Encode("path", queryID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBforPostgreSQL/flexibleServers/{serverName}/queryTexts/{queryId}", 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 QueryTextsClient) 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 QueryTextsClient) GetResponder(resp *http.Response) (result QueryText, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer retrieve the Query-Store query texts for specified queryIds. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// queryIds - the query identifiers +func (client QueryTextsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, queryIds []string) (result QueryTextsResultListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryTextsClient.ListByServer") + defer func() { + sc := -1 + if result.qtrl.Response.Response != nil { + sc = result.qtrl.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: queryIds, + Constraints: []validation.Constraint{{Target: "queryIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.QueryTextsClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName, queryIds) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryTextsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.qtrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryTextsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.qtrl, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryTextsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.qtrl.hasNextLink() && result.qtrl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client QueryTextsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, queryIds []string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "queryIds": queryIds, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/queryTexts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client QueryTextsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client QueryTextsClient) ListByServerResponder(resp *http.Response) (result QueryTextsResultList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client QueryTextsClient) listByServerNextResults(ctx context.Context, lastResults QueryTextsResultList) (result QueryTextsResultList, err error) { + req, err := lastResults.queryTextsResultListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryTextsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryTextsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.QueryTextsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client QueryTextsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, queryIds []string) (result QueryTextsResultListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryTextsClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName, queryIds) + return +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/recommendedactions.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/recommendedactions.go new file mode 100644 index 000000000000..86eab4e5000e --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/recommendedactions.go @@ -0,0 +1,168 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// RecommendedActionsClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type RecommendedActionsClient struct { + BaseClient +} + +// NewRecommendedActionsClient creates an instance of the RecommendedActionsClient client. +func NewRecommendedActionsClient(subscriptionID string) RecommendedActionsClient { + return NewRecommendedActionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecommendedActionsClientWithBaseURI creates an instance of the RecommendedActionsClient 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 NewRecommendedActionsClientWithBaseURI(baseURI string, subscriptionID string) RecommendedActionsClient { + return RecommendedActionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer retrieve recommended actions from the advisor. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// advisorName - the advisor name for recommendation action. +// sessionID - the recommendation action session identifier. +func (client RecommendedActionsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, advisorName string, sessionID string) (result RecommendationActionsResultListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendedActionsClient.ListByServer") + defer func() { + sc := -1 + if result.rarl.Response.Response != nil { + sc = result.rarl.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("postgresqlflexibleservers.RecommendedActionsClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName, advisorName, sessionID) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.RecommendedActionsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.rarl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.RecommendedActionsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.rarl, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.RecommendedActionsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.rarl.hasNextLink() && result.rarl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client RecommendedActionsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, advisorName string, sessionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advisorName": autorest.Encode("path", advisorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(sessionID) > 0 { + queryParameters["sessionId"] = autorest.Encode("query", sessionID) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advisors/{advisorName}/recommendedActions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client RecommendedActionsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RecommendedActionsClient) ListByServerResponder(resp *http.Response) (result RecommendationActionsResultList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client RecommendedActionsClient) listByServerNextResults(ctx context.Context, lastResults RecommendationActionsResultList) (result RecommendationActionsResultList, err error) { + req, err := lastResults.recommendationActionsResultListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.RecommendedActionsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.RecommendedActionsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.RecommendedActionsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client RecommendedActionsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, advisorName string, sessionID string) (result RecommendationActionsResultListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendedActionsClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName, advisorName, sessionID) + return +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/servers.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/servers.go new file mode 100644 index 000000000000..60dfe69da461 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/servers.go @@ -0,0 +1,898 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// ServersClient is the the Microsoft Azure management API provides create, read, update, and delete functionality for +// Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, log +// files and configurations with new business model. +type ServersClient struct { + BaseClient +} + +// NewServersClient creates an instance of the ServersClient client. +func NewServersClient(subscriptionID string) ServersClient { + return NewServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServersClientWithBaseURI creates an instance of the ServersClient 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 NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { + return ServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a new server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the required parameters for creating or updating a server. +func (client ServersClient) Create(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (result ServersCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Create") + 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: 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: 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("postgresqlflexibleservers.ServersClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ServersClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}", pathParameters), + autorest.WithJSON(parameters), + 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 ServersClient) CreateSender(req *http.Request) (future ServersCreateFuture, 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 +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ServersClient) CreateResponder(resp *http.Response) (result Server, 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 a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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: 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("postgresqlflexibleservers.ServersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}", 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 ServersClient) DeleteSender(req *http.Request) (future ServersDeleteFuture, 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 ServersClient) 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 gets information about a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result Server, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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("postgresqlflexibleservers.ServersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}", 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 ServersClient) 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 ServersClient) GetResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all the servers in a given subscription. +func (client ServersClient) List(ctx context.Context) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.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("postgresqlflexibleservers.ServersClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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, "postgresqlflexibleservers.ServersClient", "List", resp, "Failure sending request") + return + } + + result.slr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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 ServersClient) ListPreparer(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.DBForPostgreSql/flexibleServers", 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 ServersClient) 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 ServersClient) ListResponder(resp *http.Response) (result ServerListResult, 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 ServersClient) listNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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, "postgresqlflexibleservers.ServersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListComplete(ctx context.Context) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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 the servers in a given resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.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("postgresqlflexibleservers.ServersClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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, "postgresqlflexibleservers.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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 ServersClient) 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.DBForPostgreSql/flexibleServers", 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 ServersClient) 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 ServersClient) ListByResourceGroupResponder(resp *http.Response) (result ServerListResult, 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 ServersClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "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, "postgresqlflexibleservers.ServersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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 +} + +// Restart restarts a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the parameters for restarting a server. +func (client ServersClient) Restart(ctx context.Context, resourceGroupName string, serverName string, parameters *RestartParameter) (result ServersRestartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Restart") + 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: 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("postgresqlflexibleservers.ServersClient", "Restart", err.Error()) + } + + req, err := client.RestartPreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Restart", nil, "Failure preparing request") + return + } + + result, err = client.RestartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Restart", nil, "Failure sending request") + return + } + + return +} + +// RestartPreparer prepares the Restart request. +func (client ServersClient) RestartPreparer(ctx context.Context, resourceGroupName string, serverName string, parameters *RestartParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/restart", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + 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 ServersClient) RestartSender(req *http.Request) (future ServersRestartFuture, 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 ServersClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Start starts a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Start(ctx context.Context, resourceGroupName string, serverName string) (result ServersStartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Start") + 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: 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("postgresqlflexibleservers.ServersClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Start", nil, "Failure preparing request") + return + } + + result, err = client.StartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Start", nil, "Failure sending request") + return + } + + return +} + +// StartPreparer prepares the Start request. +func (client ServersClient) StartPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) StartSender(req *http.Request) (future ServersStartFuture, 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 +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client ServersClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stops a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Stop(ctx context.Context, resourceGroupName string, serverName string) (result ServersStopFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Stop") + 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: 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("postgresqlflexibleservers.ServersClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Stop", nil, "Failure preparing request") + return + } + + result, err = client.StopSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Stop", nil, "Failure sending request") + return + } + + return +} + +// StopPreparer prepares the Stop request. +func (client ServersClient) StopPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBForPostgreSql/flexibleServers/{serverName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) StopSender(req *http.Request) (future ServersStopFuture, 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 +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client ServersClient) StopResponder(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 server. The request body can contain one to many of the properties present in the normal +// server definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the required parameters for updating a server. +func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate) (result ServersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.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: 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("postgresqlflexibleservers.ServersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{serverName}", 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 ServersClient) UpdateSender(req *http.Request) (future ServersUpdateFuture, 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 ServersClient) UpdateResponder(resp *http.Response) (result Server, 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/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/topquerystatistics.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/topquerystatistics.go new file mode 100644 index 000000000000..ec3457999bc9 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/topquerystatistics.go @@ -0,0 +1,162 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// TopQueryStatisticsClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type TopQueryStatisticsClient struct { + BaseClient +} + +// NewTopQueryStatisticsClient creates an instance of the TopQueryStatisticsClient client. +func NewTopQueryStatisticsClient(subscriptionID string) TopQueryStatisticsClient { + return NewTopQueryStatisticsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTopQueryStatisticsClientWithBaseURI creates an instance of the TopQueryStatisticsClient 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 NewTopQueryStatisticsClientWithBaseURI(baseURI string, subscriptionID string) TopQueryStatisticsClient { + return TopQueryStatisticsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer retrieve the Query-Store top queries for specified metric and aggregation. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client TopQueryStatisticsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result TopQueryStatisticsResultListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopQueryStatisticsClient.ListByServer") + defer func() { + sc := -1 + if result.tqsrl.Response.Response != nil { + sc = result.tqsrl.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("postgresqlflexibleservers.TopQueryStatisticsClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.TopQueryStatisticsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.tqsrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.TopQueryStatisticsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.tqsrl, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.TopQueryStatisticsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.tqsrl.hasNextLink() && result.tqsrl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client TopQueryStatisticsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.DBforPostgreSQL/flexibleServers/{serverName}/topQueryStatistics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client TopQueryStatisticsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client TopQueryStatisticsClient) ListByServerResponder(resp *http.Response) (result TopQueryStatisticsResultList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client TopQueryStatisticsClient) listByServerNextResults(ctx context.Context, lastResults TopQueryStatisticsResultList) (result TopQueryStatisticsResultList, err error) { + req, err := lastResults.topQueryStatisticsResultListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.TopQueryStatisticsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.TopQueryStatisticsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.TopQueryStatisticsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client TopQueryStatisticsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result TopQueryStatisticsResultListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopQueryStatisticsClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/version.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/version.go new file mode 100644 index 000000000000..ea164af0a4ce --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/version.go @@ -0,0 +1,19 @@ +package postgresqlflexibleservers + +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() + " postgresqlflexibleservers/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/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/virtualnetworksubnetusage.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/virtualnetworksubnetusage.go new file mode 100644 index 000000000000..8d2804fefc4b --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/virtualnetworksubnetusage.go @@ -0,0 +1,118 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// VirtualNetworkSubnetUsageClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type VirtualNetworkSubnetUsageClient struct { + BaseClient +} + +// NewVirtualNetworkSubnetUsageClient creates an instance of the VirtualNetworkSubnetUsageClient client. +func NewVirtualNetworkSubnetUsageClient(subscriptionID string) VirtualNetworkSubnetUsageClient { + return NewVirtualNetworkSubnetUsageClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualNetworkSubnetUsageClientWithBaseURI creates an instance of the VirtualNetworkSubnetUsageClient 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 NewVirtualNetworkSubnetUsageClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkSubnetUsageClient { + return VirtualNetworkSubnetUsageClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute get virtual network subnet usage for a given vNet resource id. +// Parameters: +// locationName - the name of the location. +// parameters - the required parameters for creating or updating a server. +func (client VirtualNetworkSubnetUsageClient) Execute(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter) (result VirtualNetworkSubnetUsageResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkSubnetUsageClient.Execute") + 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("postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", err.Error()) + } + + req, err := client.ExecutePreparer(ctx, locationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client VirtualNetworkSubnetUsageClient) ExecutePreparer(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "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.DBForPostgreSql/locations/{locationName}/checkVirtualNetworkSubnetUsage", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkSubnetUsageClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client VirtualNetworkSubnetUsageClient) ExecuteResponder(resp *http.Response) (result VirtualNetworkSubnetUsageResult, 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/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/waitstatistics.go b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/waitstatistics.go new file mode 100644 index 000000000000..fd935c53f8e3 --- /dev/null +++ b/services/preview/postgresql/mgmt/2021-06-01-preview/postgresqlflexibleservers/waitstatistics.go @@ -0,0 +1,170 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights 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" +) + +// WaitStatisticsClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type WaitStatisticsClient struct { + BaseClient +} + +// NewWaitStatisticsClient creates an instance of the WaitStatisticsClient client. +func NewWaitStatisticsClient(subscriptionID string) WaitStatisticsClient { + return NewWaitStatisticsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWaitStatisticsClientWithBaseURI creates an instance of the WaitStatisticsClient 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 NewWaitStatisticsClientWithBaseURI(baseURI string, subscriptionID string) WaitStatisticsClient { + return WaitStatisticsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer retrieve wait statistics for specified aggregation window. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the required parameters for retrieving wait statistics. +func (client WaitStatisticsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, parameters WaitStatisticsInput) (result WaitStatisticsResultListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WaitStatisticsClient.ListByServer") + defer func() { + sc := -1 + if result.wsrl.Response.Response != nil { + sc = result.wsrl.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: parameters, + Constraints: []validation.Constraint{{Target: "parameters.WaitStatisticsInputProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.WaitStatisticsInputProperties.ObservationStartTime", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WaitStatisticsInputProperties.ObservationEndTime", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WaitStatisticsInputProperties.AggregationWindow", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.WaitStatisticsClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.WaitStatisticsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.wsrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.WaitStatisticsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.wsrl, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.WaitStatisticsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.wsrl.hasNextLink() && result.wsrl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client WaitStatisticsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, parameters WaitStatisticsInput) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "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.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/waitStatistics", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client WaitStatisticsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client WaitStatisticsClient) ListByServerResponder(resp *http.Response) (result WaitStatisticsResultList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client WaitStatisticsClient) listByServerNextResults(ctx context.Context, lastResults WaitStatisticsResultList) (result WaitStatisticsResultList, err error) { + req, err := lastResults.waitStatisticsResultListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.WaitStatisticsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.WaitStatisticsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.WaitStatisticsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client WaitStatisticsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, parameters WaitStatisticsInput) (result WaitStatisticsResultListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WaitStatisticsClient.ListByServer") + 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.ListByServer(ctx, resourceGroupName, serverName, parameters) + return +}