diff --git a/sdk/resourcemanager/sql/armsql/CHANGELOG.md b/sdk/resourcemanager/sql/armsql/CHANGELOG.md index 4e011cf1f9a7..7ce47dc84b43 100644 --- a/sdk/resourcemanager/sql/armsql/CHANGELOG.md +++ b/sdk/resourcemanager/sql/armsql/CHANGELOG.md @@ -1,5 +1,50 @@ # Release History +## 0.3.0 (2021-11-18) +### Breaking Changes + +- Function `*SyncGroupsClient.ListLogs` parameter(s) have been changed from `(string, string, string, string, string, string, Enum75, *SyncGroupsListLogsOptions)` to `(string, string, string, string, string, string, Enum74, *SyncGroupsListLogsOptions)` +- Const `Enum75Success` has been removed +- Const `Enum75All` has been removed +- Const `Enum75Error` has been removed +- Const `Enum75Warning` has been removed +- Function `Enum75.ToPtr` has been removed +- Function `*ServerConnectionPoliciesClient.CreateOrUpdate` has been removed +- Function `PossibleEnum75Values` has been removed +- Struct `ServerConnectionPoliciesCreateOrUpdateOptions` has been removed + +### New Content + +- New const `Enum74Warning` +- New const `Enum74All` +- New const `Enum74Error` +- New const `Enum74Success` +- New function `ServerConnectionPoliciesCreateOrUpdatePollerResponse.PollUntilDone(context.Context, time.Duration) (ServerConnectionPoliciesCreateOrUpdateResponse, error)` +- New function `ServerConnectionPolicyListResult.MarshalJSON() ([]byte, error)` +- New function `*ServerConnectionPoliciesCreateOrUpdatePoller.Poll(context.Context) (*http.Response, error)` +- New function `*ServerConnectionPoliciesListByServerPager.NextPage(context.Context) bool` +- New function `*ServerConnectionPoliciesClient.ListByServer(string, string, *ServerConnectionPoliciesListByServerOptions) *ServerConnectionPoliciesListByServerPager` +- New function `Enum74.ToPtr() *Enum74` +- New function `*ServerConnectionPoliciesListByServerPager.Err() error` +- New function `*ServerConnectionPoliciesCreateOrUpdatePollerResponse.Resume(context.Context, *ServerConnectionPoliciesClient, string) error` +- New function `PossibleEnum74Values() []Enum74` +- New function `*ServerConnectionPoliciesListByServerPager.PageResponse() ServerConnectionPoliciesListByServerResponse` +- New function `*ServerConnectionPoliciesCreateOrUpdatePoller.Done() bool` +- New function `*ServerConnectionPoliciesClient.BeginCreateOrUpdate(context.Context, string, string, ConnectionPolicyName, ServerConnectionPolicy, *ServerConnectionPoliciesBeginCreateOrUpdateOptions) (ServerConnectionPoliciesCreateOrUpdatePollerResponse, error)` +- New function `*ServerConnectionPoliciesCreateOrUpdatePoller.ResumeToken() (string, error)` +- New function `*ServerConnectionPoliciesCreateOrUpdatePoller.FinalResponse(context.Context) (ServerConnectionPoliciesCreateOrUpdateResponse, error)` +- New struct `ServerConnectionPoliciesBeginCreateOrUpdateOptions` +- New struct `ServerConnectionPoliciesCreateOrUpdatePoller` +- New struct `ServerConnectionPoliciesCreateOrUpdatePollerResponse` +- New struct `ServerConnectionPoliciesListByServerOptions` +- New struct `ServerConnectionPoliciesListByServerPager` +- New struct `ServerConnectionPoliciesListByServerResponse` +- New struct `ServerConnectionPoliciesListByServerResult` +- New struct `ServerConnectionPolicyListResult` + +Total 10 breaking change(s), 34 additive change(s). + + ## 0.2.1 (Unreleased) ### Features Added diff --git a/sdk/resourcemanager/sql/armsql/autorest.md b/sdk/resourcemanager/sql/armsql/autorest.md index c9a4d573fcb8..07b03f7d4772 100644 --- a/sdk/resourcemanager/sql/armsql/autorest.md +++ b/sdk/resourcemanager/sql/armsql/autorest.md @@ -5,10 +5,10 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/69eacf00a36d565d3220d5dd6f4a5293664f1ae9/specification/sql/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/69eacf00a36d565d3220d5dd6f4a5293664f1ae9/specification/sql/resource-manager/readme.go.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/sql/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/sql/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.2.0 +module-version: 0.3.0 modelerfour: seal-single-value-enum-by-default: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/sql/armsql/go.mod b/sdk/resourcemanager/sql/armsql/go.mod index bcacc9b4f2e4..cb345ea16eae 100644 --- a/sdk/resourcemanager/sql/armsql/go.mod +++ b/sdk/resourcemanager/sql/armsql/go.mod @@ -3,6 +3,6 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql go 1.16 require ( - github.com/Azure/azure-sdk-for-go v59.0.0+incompatible + github.com/Azure/azure-sdk-for-go v59.2.0+incompatible github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 ) diff --git a/sdk/resourcemanager/sql/armsql/go.sum b/sdk/resourcemanager/sql/armsql/go.sum index aa0f0c68fa01..e33416043ba9 100644 --- a/sdk/resourcemanager/sql/armsql/go.sum +++ b/sdk/resourcemanager/sql/armsql/go.sum @@ -1,5 +1,5 @@ -github.com/Azure/azure-sdk-for-go v59.0.0+incompatible h1:I1ULJqny1qQhUBFy11yDXHhW3pLvbhwV0PTn7mjp9V0= -github.com/Azure/azure-sdk-for-go v59.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go v59.2.0+incompatible h1:mbxiZy1K820hQ+dI+YIO/+a0wQDYqOu18BAGe4lXjVk= +github.com/Azure/azure-sdk-for-go v59.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= diff --git a/sdk/resourcemanager/sql/armsql/zz_generated_constants.go b/sdk/resourcemanager/sql/armsql/zz_generated_constants.go index 1f6858b37286..b233e31403e8 100644 --- a/sdk/resourcemanager/sql/armsql/zz_generated_constants.go +++ b/sdk/resourcemanager/sql/armsql/zz_generated_constants.go @@ -10,7 +10,7 @@ package armsql const ( module = "armsql" - version = "v0.2.1" + version = "v0.3.0" ) type AdministratorName string @@ -1011,27 +1011,27 @@ func (c EncryptionProtectorName) ToPtr() *EncryptionProtectorName { return &c } -type Enum75 string +type Enum74 string const ( - Enum75All Enum75 = "All" - Enum75Error Enum75 = "Error" - Enum75Success Enum75 = "Success" - Enum75Warning Enum75 = "Warning" + Enum74All Enum74 = "All" + Enum74Error Enum74 = "Error" + Enum74Success Enum74 = "Success" + Enum74Warning Enum74 = "Warning" ) -// PossibleEnum75Values returns the possible values for the Enum75 const type. -func PossibleEnum75Values() []Enum75 { - return []Enum75{ - Enum75All, - Enum75Error, - Enum75Success, - Enum75Warning, +// PossibleEnum74Values returns the possible values for the Enum74 const type. +func PossibleEnum74Values() []Enum74 { + return []Enum74{ + Enum74All, + Enum74Error, + Enum74Success, + Enum74Warning, } } -// ToPtr returns a *Enum75 pointing to the current value. -func (c Enum75) ToPtr() *Enum75 { +// ToPtr returns a *Enum74 pointing to the current value. +func (c Enum74) ToPtr() *Enum74 { return &c } diff --git a/sdk/resourcemanager/sql/armsql/zz_generated_models.go b/sdk/resourcemanager/sql/armsql/zz_generated_models.go index de068bd52968..9673ea7f1689 100644 --- a/sdk/resourcemanager/sql/armsql/zz_generated_models.go +++ b/sdk/resourcemanager/sql/armsql/zz_generated_models.go @@ -10566,8 +10566,8 @@ type ServerCommunicationLinksListByServerOptions struct { // placeholder for future optional parameters } -// ServerConnectionPoliciesCreateOrUpdateOptions contains the optional parameters for the ServerConnectionPolicies.CreateOrUpdate method. -type ServerConnectionPoliciesCreateOrUpdateOptions struct { +// ServerConnectionPoliciesBeginCreateOrUpdateOptions contains the optional parameters for the ServerConnectionPolicies.BeginCreateOrUpdate method. +type ServerConnectionPoliciesBeginCreateOrUpdateOptions struct { // placeholder for future optional parameters } @@ -10576,10 +10576,15 @@ type ServerConnectionPoliciesGetOptions struct { // placeholder for future optional parameters } -// ServerConnectionPolicy - A server secure connection policy. +// ServerConnectionPoliciesListByServerOptions contains the optional parameters for the ServerConnectionPolicies.ListByServer method. +type ServerConnectionPoliciesListByServerOptions struct { + // placeholder for future optional parameters +} + +// ServerConnectionPolicy - A server connection policy type ServerConnectionPolicy struct { ProxyResource - // The properties of the server secure connection policy. + // Resource properties. Properties *ServerConnectionPolicyProperties `json:"properties,omitempty"` // READ-ONLY; Metadata used for the Azure portal experience. @@ -10599,7 +10604,24 @@ func (s ServerConnectionPolicy) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// ServerConnectionPolicyProperties - The properties of a server secure connection policy. +// ServerConnectionPolicyListResult - A list of server connection policy objects. +type ServerConnectionPolicyListResult struct { + // READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Array of results. + Value []*ServerConnectionPolicy `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServerConnectionPolicyListResult. +func (s ServerConnectionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// ServerConnectionPolicyProperties - The properties of a server connection policy. type ServerConnectionPolicyProperties struct { // REQUIRED; The server connection type. ConnectionType *ServerConnectionType `json:"connectionType,omitempty"` diff --git a/sdk/resourcemanager/sql/armsql/zz_generated_pagers.go b/sdk/resourcemanager/sql/armsql/zz_generated_pagers.go index be508bed7345..1f808658f85c 100644 --- a/sdk/resourcemanager/sql/armsql/zz_generated_pagers.go +++ b/sdk/resourcemanager/sql/armsql/zz_generated_pagers.go @@ -5416,6 +5416,60 @@ func (p *ServerBlobAuditingPoliciesListByServerPager) PageResponse() ServerBlobA return p.current } +// ServerConnectionPoliciesListByServerPager provides operations for iterating over paged responses. +type ServerConnectionPoliciesListByServerPager struct { + client *ServerConnectionPoliciesClient + current ServerConnectionPoliciesListByServerResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ServerConnectionPoliciesListByServerResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ServerConnectionPoliciesListByServerPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ServerConnectionPoliciesListByServerPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ServerConnectionPolicyListResult.NextLink == nil || len(*p.current.ServerConnectionPolicyListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByServerHandleError(resp) + return false + } + result, err := p.client.listByServerHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ServerConnectionPoliciesListByServerResponse page. +func (p *ServerConnectionPoliciesListByServerPager) PageResponse() ServerConnectionPoliciesListByServerResponse { + return p.current +} + // ServerDNSAliasesListByServerPager provides operations for iterating over paged responses. type ServerDNSAliasesListByServerPager struct { client *ServerDNSAliasesClient diff --git a/sdk/resourcemanager/sql/armsql/zz_generated_pollers.go b/sdk/resourcemanager/sql/armsql/zz_generated_pollers.go index 9f28e991e4d2..a4111474a5a4 100644 --- a/sdk/resourcemanager/sql/armsql/zz_generated_pollers.go +++ b/sdk/resourcemanager/sql/armsql/zz_generated_pollers.go @@ -3841,6 +3841,49 @@ func (p *ServerCommunicationLinksCreateOrUpdatePoller) ResumeToken() (string, er return p.pt.ResumeToken() } +// ServerConnectionPoliciesCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ServerConnectionPoliciesCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ServerConnectionPoliciesCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ServerConnectionPoliciesCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ServerConnectionPoliciesCreateOrUpdateResponse will be returned. +func (p *ServerConnectionPoliciesCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ServerConnectionPoliciesCreateOrUpdateResponse, error) { + respType := ServerConnectionPoliciesCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ServerConnectionPolicy) + if err != nil { + return ServerConnectionPoliciesCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ServerConnectionPoliciesCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + // ServerDNSAliasesAcquirePoller provides polling facilities until the operation reaches a terminal state. type ServerDNSAliasesAcquirePoller struct { pt *azcore.Poller diff --git a/sdk/resourcemanager/sql/armsql/zz_generated_response_types.go b/sdk/resourcemanager/sql/armsql/zz_generated_response_types.go index e0c8e52c5dd2..2aa03913be3c 100644 --- a/sdk/resourcemanager/sql/armsql/zz_generated_response_types.go +++ b/sdk/resourcemanager/sql/armsql/zz_generated_response_types.go @@ -7365,6 +7365,46 @@ type ServerCommunicationLinksListByServerResult struct { ServerCommunicationLinkListResult } +// ServerConnectionPoliciesCreateOrUpdatePollerResponse contains the response from method ServerConnectionPolicies.CreateOrUpdate. +type ServerConnectionPoliciesCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ServerConnectionPoliciesCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ServerConnectionPoliciesCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ServerConnectionPoliciesCreateOrUpdateResponse, error) { + respType := ServerConnectionPoliciesCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ServerConnectionPolicy) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ServerConnectionPoliciesCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ServerConnectionPoliciesCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ServerConnectionPoliciesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ServerConnectionPoliciesClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ServerConnectionPoliciesCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + // ServerConnectionPoliciesCreateOrUpdateResponse contains the response from method ServerConnectionPolicies.CreateOrUpdate. type ServerConnectionPoliciesCreateOrUpdateResponse struct { ServerConnectionPoliciesCreateOrUpdateResult @@ -7389,6 +7429,18 @@ type ServerConnectionPoliciesGetResult struct { ServerConnectionPolicy } +// ServerConnectionPoliciesListByServerResponse contains the response from method ServerConnectionPolicies.ListByServer. +type ServerConnectionPoliciesListByServerResponse struct { + ServerConnectionPoliciesListByServerResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ServerConnectionPoliciesListByServerResult contains the result from method ServerConnectionPolicies.ListByServer. +type ServerConnectionPoliciesListByServerResult struct { + ServerConnectionPolicyListResult +} + // ServerDNSAliasesAcquirePollerResponse contains the response from method ServerDNSAliases.Acquire. type ServerDNSAliasesAcquirePollerResponse struct { // Poller contains an initialized poller. diff --git a/sdk/resourcemanager/sql/armsql/zz_generated_serverconnectionpolicies_client.go b/sdk/resourcemanager/sql/armsql/zz_generated_serverconnectionpolicies_client.go index 128e88b8afb1..e4a9d291e6a2 100644 --- a/sdk/resourcemanager/sql/armsql/zz_generated_serverconnectionpolicies_client.go +++ b/sdk/resourcemanager/sql/armsql/zz_generated_serverconnectionpolicies_client.go @@ -41,30 +41,46 @@ func NewServerConnectionPoliciesClient(subscriptionID string, credential azcore. return &ServerConnectionPoliciesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} } -// CreateOrUpdate - Creates or updates the server's connection policy. +// BeginCreateOrUpdate - Updates a server connection policy // If the operation fails it returns a generic error. -func (client *ServerConnectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, connectionPolicyName ConnectionPolicyName, parameters ServerConnectionPolicy, options *ServerConnectionPoliciesCreateOrUpdateOptions) (ServerConnectionPoliciesCreateOrUpdateResponse, error) { +func (client *ServerConnectionPoliciesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, connectionPolicyName ConnectionPolicyName, parameters ServerConnectionPolicy, options *ServerConnectionPoliciesBeginCreateOrUpdateOptions) (ServerConnectionPoliciesCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, connectionPolicyName, parameters, options) + if err != nil { + return ServerConnectionPoliciesCreateOrUpdatePollerResponse{}, err + } + result := ServerConnectionPoliciesCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ServerConnectionPoliciesClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ServerConnectionPoliciesCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ServerConnectionPoliciesCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Updates a server connection policy +// If the operation fails it returns a generic error. +func (client *ServerConnectionPoliciesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, connectionPolicyName ConnectionPolicyName, parameters ServerConnectionPolicy, options *ServerConnectionPoliciesBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, connectionPolicyName, parameters, options) if err != nil { - return ServerConnectionPoliciesCreateOrUpdateResponse{}, err + return nil, err } resp, err := client.pl.Do(req) if err != nil { - return ServerConnectionPoliciesCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ServerConnectionPoliciesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) } - return client.createOrUpdateHandleResponse(resp) + return resp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ServerConnectionPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, connectionPolicyName ConnectionPolicyName, parameters ServerConnectionPolicy, options *ServerConnectionPoliciesCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ServerConnectionPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, connectionPolicyName ConnectionPolicyName, parameters ServerConnectionPolicy, options *ServerConnectionPoliciesBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -77,26 +93,21 @@ func (client *ServerConnectionPoliciesClient) createOrUpdateCreateRequest(ctx co return nil, errors.New("parameter connectionPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectionPolicyName}", url.PathEscape(string(connectionPolicyName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2014-04-01") + reqQP.Set("api-version", "2021-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, runtime.MarshalAsJSON(req, parameters) } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *ServerConnectionPoliciesClient) createOrUpdateHandleResponse(resp *http.Response) (ServerConnectionPoliciesCreateOrUpdateResponse, error) { - result := ServerConnectionPoliciesCreateOrUpdateResponse{RawResponse: resp} - if err := runtime.UnmarshalAsJSON(resp, &result.ServerConnectionPolicy); err != nil { - return ServerConnectionPoliciesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) - } - return result, nil -} - // createOrUpdateHandleError handles the CreateOrUpdate error response. func (client *ServerConnectionPoliciesClient) createOrUpdateHandleError(resp *http.Response) error { body, err := runtime.Payload(resp) @@ -109,7 +120,7 @@ func (client *ServerConnectionPoliciesClient) createOrUpdateHandleError(resp *ht return runtime.NewResponseError(errors.New(string(body)), resp) } -// Get - Gets the server's secure connection policy. +// Get - Gets a server connection policy // If the operation fails it returns a generic error. func (client *ServerConnectionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, connectionPolicyName ConnectionPolicyName, options *ServerConnectionPoliciesGetOptions) (ServerConnectionPoliciesGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, connectionPolicyName, options) @@ -129,10 +140,6 @@ func (client *ServerConnectionPoliciesClient) Get(ctx context.Context, resourceG // getCreateRequest creates the Get request. func (client *ServerConnectionPoliciesClient) getCreateRequest(ctx context.Context, resourceGroupName string, serverName string, connectionPolicyName ConnectionPolicyName, options *ServerConnectionPoliciesGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -145,12 +152,16 @@ func (client *ServerConnectionPoliciesClient) getCreateRequest(ctx context.Conte return nil, errors.New("parameter connectionPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectionPolicyName}", url.PathEscape(string(connectionPolicyName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2014-04-01") + reqQP.Set("api-version", "2021-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -176,3 +187,64 @@ func (client *ServerConnectionPoliciesClient) getHandleError(resp *http.Response } return runtime.NewResponseError(errors.New(string(body)), resp) } + +// ListByServer - Lists connection policy +// If the operation fails it returns a generic error. +func (client *ServerConnectionPoliciesClient) ListByServer(resourceGroupName string, serverName string, options *ServerConnectionPoliciesListByServerOptions) *ServerConnectionPoliciesListByServerPager { + return &ServerConnectionPoliciesListByServerPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByServerCreateRequest(ctx, resourceGroupName, serverName, options) + }, + advancer: func(ctx context.Context, resp ServerConnectionPoliciesListByServerResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ServerConnectionPolicyListResult.NextLink) + }, + } +} + +// listByServerCreateRequest creates the ListByServer request. +func (client *ServerConnectionPoliciesClient) listByServerCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *ServerConnectionPoliciesListByServerOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByServerHandleResponse handles the ListByServer response. +func (client *ServerConnectionPoliciesClient) listByServerHandleResponse(resp *http.Response) (ServerConnectionPoliciesListByServerResponse, error) { + result := ServerConnectionPoliciesListByServerResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ServerConnectionPolicyListResult); err != nil { + return ServerConnectionPoliciesListByServerResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByServerHandleError handles the ListByServer error response. +func (client *ServerConnectionPoliciesClient) listByServerHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} diff --git a/sdk/resourcemanager/sql/armsql/zz_generated_syncgroups_client.go b/sdk/resourcemanager/sql/armsql/zz_generated_syncgroups_client.go index a872dcfd7083..7c8ef1304759 100644 --- a/sdk/resourcemanager/sql/armsql/zz_generated_syncgroups_client.go +++ b/sdk/resourcemanager/sql/armsql/zz_generated_syncgroups_client.go @@ -476,7 +476,7 @@ func (client *SyncGroupsClient) listHubSchemasHandleError(resp *http.Response) e // ListLogs - Gets a collection of sync group logs. // If the operation fails it returns a generic error. -func (client *SyncGroupsClient) ListLogs(resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParam Enum75, options *SyncGroupsListLogsOptions) *SyncGroupsListLogsPager { +func (client *SyncGroupsClient) ListLogs(resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParam Enum74, options *SyncGroupsListLogsOptions) *SyncGroupsListLogsPager { return &SyncGroupsListLogsPager{ client: client, requester: func(ctx context.Context) (*policy.Request, error) { @@ -489,7 +489,7 @@ func (client *SyncGroupsClient) ListLogs(resourceGroupName string, serverName st } // listLogsCreateRequest creates the ListLogs request. -func (client *SyncGroupsClient) listLogsCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParam Enum75, options *SyncGroupsListLogsOptions) (*policy.Request, error) { +func (client *SyncGroupsClient) listLogsCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParam Enum74, options *SyncGroupsListLogsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty")