diff --git a/profiles/preview/preview/sql/mgmt/sql/models.go b/profiles/preview/preview/sql/mgmt/sql/models.go index 487de81e36f6..597bcffb002c 100644 --- a/profiles/preview/preview/sql/mgmt/sql/models.go +++ b/profiles/preview/preview/sql/mgmt/sql/models.go @@ -114,6 +114,13 @@ const ( Recommended SensitivityLabelSource = original.Recommended ) +type AdministratorListResult = original.AdministratorListResult +type AdministratorListResultIterator = original.AdministratorListResultIterator +type AdministratorListResultPage = original.AdministratorListResultPage +type AdministratorProperties = original.AdministratorProperties +type AdministratorsClient = original.AdministratorsClient +type AdministratorsCreateOrUpdateFuture = original.AdministratorsCreateOrUpdateFuture +type AdministratorsDeleteFuture = original.AdministratorsDeleteFuture type BaseClient = original.BaseClient type CompleteDatabaseRestoreDefinition = original.CompleteDatabaseRestoreDefinition type DatabaseSecurityAlertListResult = original.DatabaseSecurityAlertListResult @@ -186,6 +193,7 @@ type SensitivityLabelListResult = original.SensitivityLabelListResult type SensitivityLabelListResultIterator = original.SensitivityLabelListResultIterator type SensitivityLabelListResultPage = original.SensitivityLabelListResultPage type SensitivityLabelProperties = original.SensitivityLabelProperties +type ServerAzureADAdministrator = original.ServerAzureADAdministrator type ServerVulnerabilityAssessment = original.ServerVulnerabilityAssessment type ServerVulnerabilityAssessmentListResult = original.ServerVulnerabilityAssessmentListResult type ServerVulnerabilityAssessmentListResultIterator = original.ServerVulnerabilityAssessmentListResultIterator @@ -204,6 +212,18 @@ type VulnerabilityAssessmentRecurringScansProperties = original.VulnerabilityAss func New(subscriptionID string) BaseClient { return original.New(subscriptionID) } +func NewAdministratorListResultIterator(page AdministratorListResultPage) AdministratorListResultIterator { + return original.NewAdministratorListResultIterator(page) +} +func NewAdministratorListResultPage(getNextPage func(context.Context, AdministratorListResult) (AdministratorListResult, error)) AdministratorListResultPage { + return original.NewAdministratorListResultPage(getNextPage) +} +func NewAdministratorsClient(subscriptionID string) AdministratorsClient { + return original.NewAdministratorsClient(subscriptionID) +} +func NewAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) AdministratorsClient { + return original.NewAdministratorsClientWithBaseURI(baseURI, subscriptionID) +} func NewDatabaseSecurityAlertListResultIterator(page DatabaseSecurityAlertListResultPage) DatabaseSecurityAlertListResultIterator { return original.NewDatabaseSecurityAlertListResultIterator(page) } diff --git a/profiles/preview/preview/sql/mgmt/sql/sqlapi/models.go b/profiles/preview/preview/sql/mgmt/sql/sqlapi/models.go index 46419e0025a9..a9ec3234fe4c 100644 --- a/profiles/preview/preview/sql/mgmt/sql/sqlapi/models.go +++ b/profiles/preview/preview/sql/mgmt/sql/sqlapi/models.go @@ -21,6 +21,7 @@ package sqlapi import original "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2018-06-01-preview/sql/sqlapi" +type AdministratorsClientAPI = original.AdministratorsClientAPI type DatabaseSecurityAlertPoliciesClientAPI = original.DatabaseSecurityAlertPoliciesClientAPI type DatabasesClientAPI = original.DatabasesClientAPI type ElasticPoolsClientAPI = original.ElasticPoolsClientAPI diff --git a/services/preview/sql/mgmt/2018-06-01-preview/sql/administrators.go b/services/preview/sql/mgmt/2018-06-01-preview/sql/administrators.go new file mode 100644 index 000000000000..adbec4f30c87 --- /dev/null +++ b/services/preview/sql/mgmt/2018-06-01-preview/sql/administrators.go @@ -0,0 +1,411 @@ +package sql + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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" +) + +// AdministratorsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type AdministratorsClient struct { + BaseClient +} + +// NewAdministratorsClient creates an instance of the AdministratorsClient client. +func NewAdministratorsClient(subscriptionID string) AdministratorsClient { + return NewAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAdministratorsClientWithBaseURI creates an instance of the AdministratorsClient client. +func NewAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) AdministratorsClient { + return AdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an existing Azure Active Directory administrator. +// 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. +// parameters - the requested Azure Active Directory administrator Resource state. +func (client AdministratorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, administratorName string, parameters ServerAzureADAdministrator) (result AdministratorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AdministratorProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.AdministratorProperties.AdministratorType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorProperties.Login", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorProperties.Sid", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.AdministratorsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, administratorName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AdministratorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, administratorName string, parameters ServerAzureADAdministrator) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", administratorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", 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 AdministratorsClient) CreateOrUpdateSender(req *http.Request) (future AdministratorsCreateOrUpdateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AdministratorsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the Azure Active Directory administrator with the given name. +// 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. +// administratorName - the name of server active directory administrator. +func (client AdministratorsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, administratorName string) (result AdministratorsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, administratorName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AdministratorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, administratorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", administratorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-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.Sql/servers/{serverName}/administrators/{administratorName}", 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 AdministratorsClient) DeleteSender(req *http.Request) (future AdministratorsDeleteFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AdministratorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a Azure Active Directory administrator. +// 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. +// administratorName - the name of server active directory administrator. +func (client AdministratorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, administratorName string) (result ServerAzureADAdministrator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorsClient.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, administratorName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AdministratorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, administratorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", administratorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-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.Sql/servers/{serverName}/administrators/{administratorName}", 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 AdministratorsClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AdministratorsClient) GetResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of Azure Active Directory administrators in a 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 AdministratorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result AdministratorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorsClient.ListByServer") + defer func() { + sc := -1 + if result.alr.Response.Response != nil { + sc = result.alr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.alr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "ListByServer", resp, "Failure responding to request") + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client AdministratorsClient) 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 = "2018-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.Sql/servers/{serverName}/administrators", 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 AdministratorsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client AdministratorsClient) ListByServerResponder(resp *http.Response) (result AdministratorListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 AdministratorsClient) listByServerNextResults(ctx context.Context, lastResults AdministratorListResult) (result AdministratorListResult, err error) { + req, err := lastResults.administratorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.AdministratorsClient", "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, "sql.AdministratorsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client AdministratorsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result AdministratorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorsClient.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/sql/mgmt/2018-06-01-preview/sql/models.go b/services/preview/sql/mgmt/2018-06-01-preview/sql/models.go index 6a41d0d53f0b..8f7778740328 100644 --- a/services/preview/sql/mgmt/2018-06-01-preview/sql/models.go +++ b/services/preview/sql/mgmt/2018-06-01-preview/sql/models.go @@ -213,6 +213,217 @@ func PossibleSensitivityLabelSourceValues() []SensitivityLabelSource { return []SensitivityLabelSource{Current, Recommended} } +// AdministratorListResult a list of active directory administrators. +type AdministratorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerAzureADAdministrator `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AdministratorListResultIterator provides access to a complete listing of ServerAzureADAdministrator +// values. +type AdministratorListResultIterator struct { + i int + page AdministratorListResultPage +} + +// 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 *AdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorListResultIterator.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 *AdministratorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AdministratorListResultIterator) 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 AdministratorListResultIterator) Response() AdministratorListResult { + 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 AdministratorListResultIterator) Value() ServerAzureADAdministrator { + if !iter.page.NotDone() { + return ServerAzureADAdministrator{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AdministratorListResultIterator type. +func NewAdministratorListResultIterator(page AdministratorListResultPage) AdministratorListResultIterator { + return AdministratorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr AdministratorListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// administratorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr AdministratorListResult) administratorListResultPreparer(ctx context.Context) (*http.Request, error) { + if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// AdministratorListResultPage contains a page of ServerAzureADAdministrator values. +type AdministratorListResultPage struct { + fn func(context.Context, AdministratorListResult) (AdministratorListResult, error) + alr AdministratorListResult +} + +// 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 *AdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.alr) + if err != nil { + return err + } + page.alr = next + 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 *AdministratorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AdministratorListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AdministratorListResultPage) Response() AdministratorListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AdministratorListResultPage) Values() []ServerAzureADAdministrator { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// Creates a new instance of the AdministratorListResultPage type. +func NewAdministratorListResultPage(getNextPage func(context.Context, AdministratorListResult) (AdministratorListResult, error)) AdministratorListResultPage { + return AdministratorListResultPage{fn: getNextPage} +} + +// AdministratorProperties properties of a active directory administrator. +type AdministratorProperties struct { + // AdministratorType - Type of the sever administrator. + AdministratorType *string `json:"administratorType,omitempty"` + // Login - Login name of the server administrator. + Login *string `json:"login,omitempty"` + // Sid - SID (object ID) of the server administrator. + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - Tenant ID of the administrator. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// AdministratorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type AdministratorsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AdministratorsCreateOrUpdateFuture) Result(client AdministratorsClient) (saaa ServerAzureADAdministrator, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("sql.AdministratorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if saaa.Response.Response, err = future.GetResult(sender); err == nil && saaa.Response.Response.StatusCode != http.StatusNoContent { + saaa, err = client.CreateOrUpdateResponder(saaa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsCreateOrUpdateFuture", "Result", saaa.Response.Response, "Failure responding to request") + } + } + return +} + +// AdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AdministratorsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AdministratorsDeleteFuture) Result(client AdministratorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("sql.AdministratorsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + // CompleteDatabaseRestoreDefinition contains the information necessary to perform a complete database // restore operation. type CompleteDatabaseRestoreDefinition struct { @@ -2682,6 +2893,79 @@ type SensitivityLabelProperties struct { IsDisabled *bool `json:"isDisabled,omitempty"` } +// ServerAzureADAdministrator azure Active Directory administrator. +type ServerAzureADAdministrator struct { + autorest.Response `json:"-"` + // AdministratorProperties - Resource properties. + *AdministratorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerAzureADAdministrator. +func (saaa ServerAzureADAdministrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if saaa.AdministratorProperties != nil { + objectMap["properties"] = saaa.AdministratorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerAzureADAdministrator struct. +func (saaa *ServerAzureADAdministrator) 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 administratorProperties AdministratorProperties + err = json.Unmarshal(*v, &administratorProperties) + if err != nil { + return err + } + saaa.AdministratorProperties = &administratorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + saaa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + saaa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + saaa.Type = &typeVar + } + } + } + + return nil +} + // ServerVulnerabilityAssessment a server vulnerability assessment. type ServerVulnerabilityAssessment struct { autorest.Response `json:"-"` diff --git a/services/preview/sql/mgmt/2018-06-01-preview/sql/sqlapi/interfaces.go b/services/preview/sql/mgmt/2018-06-01-preview/sql/sqlapi/interfaces.go index e448e7707d38..87af543f8d1c 100644 --- a/services/preview/sql/mgmt/2018-06-01-preview/sql/sqlapi/interfaces.go +++ b/services/preview/sql/mgmt/2018-06-01-preview/sql/sqlapi/interfaces.go @@ -139,3 +139,13 @@ type PrivateEndpointConnectionsClientAPI interface { } var _ PrivateEndpointConnectionsClientAPI = (*sql.PrivateEndpointConnectionsClient)(nil) + +// AdministratorsClientAPI contains the set of methods on the AdministratorsClient type. +type AdministratorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, administratorName string, parameters sql.ServerAzureADAdministrator) (result sql.AdministratorsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, administratorName string) (result sql.AdministratorsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, administratorName string) (result sql.ServerAzureADAdministrator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.AdministratorListResultPage, err error) +} + +var _ AdministratorsClientAPI = (*sql.AdministratorsClient)(nil)