rclone/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/syncgroups.go
2018-01-16 13:20:59 +00:00

1163 lines
46 KiB
Go

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 (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"net/http"
)
// SyncGroupsClient 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 SyncGroupsClient struct {
ManagementClient
}
// NewSyncGroupsClient creates an instance of the SyncGroupsClient client.
func NewSyncGroupsClient(subscriptionID string) SyncGroupsClient {
return NewSyncGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewSyncGroupsClientWithBaseURI creates an instance of the SyncGroupsClient client.
func NewSyncGroupsClientWithBaseURI(baseURI string, subscriptionID string) SyncGroupsClient {
return SyncGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CancelSync cancels a sync group synchronization.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted. syncGroupName is the name of the sync group.
func (client SyncGroupsClient) CancelSync(resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) {
req, err := client.CancelSyncPreparer(resourceGroupName, serverName, databaseName, syncGroupName)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", nil, "Failure preparing request")
return
}
resp, err := client.CancelSyncSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", resp, "Failure sending request")
return
}
result, err = client.CancelSyncResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", resp, "Failure responding to request")
}
return
}
// CancelSyncPreparer prepares the CancelSync request.
func (client SyncGroupsClient) CancelSyncPreparer(resourceGroupName string, serverName string, databaseName string, syncGroupName 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),
"syncGroupName": autorest.Encode("path", syncGroupName),
}
const APIVersion = "2015-05-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.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// CancelSyncSender sends the CancelSync request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) CancelSyncSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client))
}
// CancelSyncResponder handles the response to the CancelSync request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) CancelSyncResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// CreateOrUpdate creates or updates a sync group. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted. syncGroupName is the name of the sync group. parameters is the requested
// sync group resource state.
func (client SyncGroupsClient) CreateOrUpdate(resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup, cancel <-chan struct{}) (<-chan SyncGroup, <-chan error) {
resultChan := make(chan SyncGroup, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result SyncGroup
defer func() {
if err != nil {
errChan <- err
}
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, serverName, databaseName, syncGroupName, parameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CreateOrUpdate", resp, "Failure sending request")
return
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CreateOrUpdate", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client SyncGroupsClient) CreateOrUpdatePreparer(resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup, cancel <-chan struct{}) (*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),
"syncGroupName": autorest.Encode("path", syncGroupName),
}
const APIVersion = "2015-05-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client),
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncGroup, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes a sync group. This method may poll for completion. Polling can be canceled by passing the cancel
// channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted. syncGroupName is the name of the sync group.
func (client SyncGroupsClient) Delete(resourceGroupName string, serverName string, databaseName string, syncGroupName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
if err != nil {
errChan <- err
}
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, serverName, databaseName, syncGroupName, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Delete", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// DeletePreparer prepares the Delete request.
func (client SyncGroupsClient) DeletePreparer(resourceGroupName string, serverName string, databaseName string, syncGroupName string, cancel <-chan struct{}) (*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),
"syncGroupName": autorest.Encode("path", syncGroupName),
}
const APIVersion = "2015-05-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}/databases/{databaseName}/syncGroups/{syncGroupName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client),
azure.DoPollForAsynchronous(client.PollingDelay))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) 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 sync group.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted. syncGroupName is the name of the sync group.
func (client SyncGroupsClient) Get(resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroup, err error) {
req, err := client.GetPreparer(resourceGroupName, serverName, databaseName, syncGroupName)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "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.SyncGroupsClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client SyncGroupsClient) GetPreparer(resourceGroupName string, serverName string, databaseName string, syncGroupName 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),
"syncGroupName": autorest.Encode("path", syncGroupName),
}
const APIVersion = "2015-05-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}/databases/{databaseName}/syncGroups/{syncGroupName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client))
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) GetResponder(resp *http.Response) (result SyncGroup, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListByDatabase lists sync groups under a hub database.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted.
func (client SyncGroupsClient) ListByDatabase(resourceGroupName string, serverName string, databaseName string) (result SyncGroupListResult, err error) {
req, err := client.ListByDatabasePreparer(resourceGroupName, serverName, databaseName)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", nil, "Failure preparing request")
return
}
resp, err := client.ListByDatabaseSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure sending request")
return
}
result, err = client.ListByDatabaseResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure responding to request")
}
return
}
// ListByDatabasePreparer prepares the ListByDatabase request.
func (client SyncGroupsClient) ListByDatabasePreparer(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 = "2015-05-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}/databases/{databaseName}/syncGroups", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListByDatabaseSender sends the ListByDatabase request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client))
}
// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) ListByDatabaseResponder(resp *http.Response) (result SyncGroupListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListByDatabaseNextResults retrieves the next set of results, if any.
func (client SyncGroupsClient) ListByDatabaseNextResults(lastResults SyncGroupListResult) (result SyncGroupListResult, err error) {
req, err := lastResults.SyncGroupListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListByDatabaseSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure sending next results request")
}
result, err = client.ListByDatabaseResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure responding to next results request")
}
return
}
// ListByDatabaseComplete gets all elements from the list without paging.
func (client SyncGroupsClient) ListByDatabaseComplete(resourceGroupName string, serverName string, databaseName string, cancel <-chan struct{}) (<-chan SyncGroup, <-chan error) {
resultChan := make(chan SyncGroup)
errChan := make(chan error, 1)
go func() {
defer func() {
close(resultChan)
close(errChan)
}()
list, err := client.ListByDatabase(resourceGroupName, serverName, databaseName)
if err != nil {
errChan <- err
return
}
if list.Value != nil {
for _, item := range *list.Value {
select {
case <-cancel:
return
case resultChan <- item:
// Intentionally left blank
}
}
}
for list.NextLink != nil {
list, err = client.ListByDatabaseNextResults(list)
if err != nil {
errChan <- err
return
}
if list.Value != nil {
for _, item := range *list.Value {
select {
case <-cancel:
return
case resultChan <- item:
// Intentionally left blank
}
}
}
}
}()
return resultChan, errChan
}
// ListHubSchemas gets a collection of hub database schemas.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted. syncGroupName is the name of the sync group.
func (client SyncGroupsClient) ListHubSchemas(resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncFullSchemaPropertiesListResult, err error) {
req, err := client.ListHubSchemasPreparer(resourceGroupName, serverName, databaseName, syncGroupName)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", nil, "Failure preparing request")
return
}
resp, err := client.ListHubSchemasSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure sending request")
return
}
result, err = client.ListHubSchemasResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure responding to request")
}
return
}
// ListHubSchemasPreparer prepares the ListHubSchemas request.
func (client SyncGroupsClient) ListHubSchemasPreparer(resourceGroupName string, serverName string, databaseName string, syncGroupName 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),
"syncGroupName": autorest.Encode("path", syncGroupName),
}
const APIVersion = "2015-05-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}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListHubSchemasSender sends the ListHubSchemas request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) ListHubSchemasSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client))
}
// ListHubSchemasResponder handles the response to the ListHubSchemas request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) ListHubSchemasResponder(resp *http.Response) (result SyncFullSchemaPropertiesListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListHubSchemasNextResults retrieves the next set of results, if any.
func (client SyncGroupsClient) ListHubSchemasNextResults(lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) {
req, err := lastResults.SyncFullSchemaPropertiesListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListHubSchemasSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure sending next results request")
}
result, err = client.ListHubSchemasResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure responding to next results request")
}
return
}
// ListHubSchemasComplete gets all elements from the list without paging.
func (client SyncGroupsClient) ListHubSchemasComplete(resourceGroupName string, serverName string, databaseName string, syncGroupName string, cancel <-chan struct{}) (<-chan SyncFullSchemaProperties, <-chan error) {
resultChan := make(chan SyncFullSchemaProperties)
errChan := make(chan error, 1)
go func() {
defer func() {
close(resultChan)
close(errChan)
}()
list, err := client.ListHubSchemas(resourceGroupName, serverName, databaseName, syncGroupName)
if err != nil {
errChan <- err
return
}
if list.Value != nil {
for _, item := range *list.Value {
select {
case <-cancel:
return
case resultChan <- item:
// Intentionally left blank
}
}
}
for list.NextLink != nil {
list, err = client.ListHubSchemasNextResults(list)
if err != nil {
errChan <- err
return
}
if list.Value != nil {
for _, item := range *list.Value {
select {
case <-cancel:
return
case resultChan <- item:
// Intentionally left blank
}
}
}
}
}()
return resultChan, errChan
}
// ListLogs gets a collection of sync group logs.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted. syncGroupName is the name of the sync group. startTime is get logs
// generated after this time. endTime is get logs generated before this time. typeParameter is the types of logs to
// retrieve. continuationToken is the continuation token for this operation.
func (client SyncGroupsClient) ListLogs(resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result SyncGroupLogListResult, err error) {
req, err := client.ListLogsPreparer(resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", nil, "Failure preparing request")
return
}
resp, err := client.ListLogsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure sending request")
return
}
result, err = client.ListLogsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure responding to request")
}
return
}
// ListLogsPreparer prepares the ListLogs request.
func (client SyncGroupsClient) ListLogsPreparer(resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken 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),
"syncGroupName": autorest.Encode("path", syncGroupName),
}
const APIVersion = "2015-05-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
"endTime": autorest.Encode("query", endTime),
"startTime": autorest.Encode("query", startTime),
"type": autorest.Encode("query", typeParameter),
}
if len(continuationToken) > 0 {
queryParameters["continuationToken"] = autorest.Encode("query", continuationToken)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListLogsSender sends the ListLogs request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) ListLogsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client))
}
// ListLogsResponder handles the response to the ListLogs request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) ListLogsResponder(resp *http.Response) (result SyncGroupLogListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListLogsNextResults retrieves the next set of results, if any.
func (client SyncGroupsClient) ListLogsNextResults(lastResults SyncGroupLogListResult) (result SyncGroupLogListResult, err error) {
req, err := lastResults.SyncGroupLogListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListLogsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure sending next results request")
}
result, err = client.ListLogsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure responding to next results request")
}
return
}
// ListLogsComplete gets all elements from the list without paging.
func (client SyncGroupsClient) ListLogsComplete(resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string, cancel <-chan struct{}) (<-chan SyncGroupLogProperties, <-chan error) {
resultChan := make(chan SyncGroupLogProperties)
errChan := make(chan error, 1)
go func() {
defer func() {
close(resultChan)
close(errChan)
}()
list, err := client.ListLogs(resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken)
if err != nil {
errChan <- err
return
}
if list.Value != nil {
for _, item := range *list.Value {
select {
case <-cancel:
return
case resultChan <- item:
// Intentionally left blank
}
}
}
for list.NextLink != nil {
list, err = client.ListLogsNextResults(list)
if err != nil {
errChan <- err
return
}
if list.Value != nil {
for _, item := range *list.Value {
select {
case <-cancel:
return
case resultChan <- item:
// Intentionally left blank
}
}
}
}
}()
return resultChan, errChan
}
// ListSyncDatabaseIds gets a collection of sync database ids.
//
// locationName is the name of the region where the resource is located.
func (client SyncGroupsClient) ListSyncDatabaseIds(locationName string) (result SyncDatabaseIDListResult, err error) {
req, err := client.ListSyncDatabaseIdsPreparer(locationName)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", nil, "Failure preparing request")
return
}
resp, err := client.ListSyncDatabaseIdsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure sending request")
return
}
result, err = client.ListSyncDatabaseIdsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure responding to request")
}
return
}
// ListSyncDatabaseIdsPreparer prepares the ListSyncDatabaseIds request.
func (client SyncGroupsClient) ListSyncDatabaseIdsPreparer(locationName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"locationName": autorest.Encode("path", locationName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2015-05-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListSyncDatabaseIdsSender sends the ListSyncDatabaseIds request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) ListSyncDatabaseIdsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client))
}
// ListSyncDatabaseIdsResponder handles the response to the ListSyncDatabaseIds request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) ListSyncDatabaseIdsResponder(resp *http.Response) (result SyncDatabaseIDListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListSyncDatabaseIdsNextResults retrieves the next set of results, if any.
func (client SyncGroupsClient) ListSyncDatabaseIdsNextResults(lastResults SyncDatabaseIDListResult) (result SyncDatabaseIDListResult, err error) {
req, err := lastResults.SyncDatabaseIDListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListSyncDatabaseIdsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure sending next results request")
}
result, err = client.ListSyncDatabaseIdsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure responding to next results request")
}
return
}
// ListSyncDatabaseIdsComplete gets all elements from the list without paging.
func (client SyncGroupsClient) ListSyncDatabaseIdsComplete(locationName string, cancel <-chan struct{}) (<-chan SyncDatabaseIDProperties, <-chan error) {
resultChan := make(chan SyncDatabaseIDProperties)
errChan := make(chan error, 1)
go func() {
defer func() {
close(resultChan)
close(errChan)
}()
list, err := client.ListSyncDatabaseIds(locationName)
if err != nil {
errChan <- err
return
}
if list.Value != nil {
for _, item := range *list.Value {
select {
case <-cancel:
return
case resultChan <- item:
// Intentionally left blank
}
}
}
for list.NextLink != nil {
list, err = client.ListSyncDatabaseIdsNextResults(list)
if err != nil {
errChan <- err
return
}
if list.Value != nil {
for _, item := range *list.Value {
select {
case <-cancel:
return
case resultChan <- item:
// Intentionally left blank
}
}
}
}
}()
return resultChan, errChan
}
// RefreshHubSchema refreshes a hub database schema. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted. syncGroupName is the name of the sync group.
func (client SyncGroupsClient) RefreshHubSchema(resourceGroupName string, serverName string, databaseName string, syncGroupName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
if err != nil {
errChan <- err
}
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.RefreshHubSchemaPreparer(resourceGroupName, serverName, databaseName, syncGroupName, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "RefreshHubSchema", nil, "Failure preparing request")
return
}
resp, err := client.RefreshHubSchemaSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "RefreshHubSchema", resp, "Failure sending request")
return
}
result, err = client.RefreshHubSchemaResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "RefreshHubSchema", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// RefreshHubSchemaPreparer prepares the RefreshHubSchema request.
func (client SyncGroupsClient) RefreshHubSchemaPreparer(resourceGroupName string, serverName string, databaseName string, syncGroupName string, cancel <-chan struct{}) (*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),
"syncGroupName": autorest.Encode("path", syncGroupName),
}
const APIVersion = "2015-05-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.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// RefreshHubSchemaSender sends the RefreshHubSchema request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) RefreshHubSchemaSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client),
azure.DoPollForAsynchronous(client.PollingDelay))
}
// RefreshHubSchemaResponder handles the response to the RefreshHubSchema request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) RefreshHubSchemaResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
// TriggerSync triggers a sync group synchronization.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted. syncGroupName is the name of the sync group.
func (client SyncGroupsClient) TriggerSync(resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) {
req, err := client.TriggerSyncPreparer(resourceGroupName, serverName, databaseName, syncGroupName)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", nil, "Failure preparing request")
return
}
resp, err := client.TriggerSyncSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", resp, "Failure sending request")
return
}
result, err = client.TriggerSyncResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", resp, "Failure responding to request")
}
return
}
// TriggerSyncPreparer prepares the TriggerSync request.
func (client SyncGroupsClient) TriggerSyncPreparer(resourceGroupName string, serverName string, databaseName string, syncGroupName 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),
"syncGroupName": autorest.Encode("path", syncGroupName),
}
const APIVersion = "2015-05-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.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// TriggerSyncSender sends the TriggerSync request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) TriggerSyncSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client))
}
// TriggerSyncResponder handles the response to the TriggerSync request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) TriggerSyncResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Update updates a sync group. This method may poll for completion. Polling can be canceled by passing the cancel
// channel argument. The channel will be used to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is 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 is the name of the server. databaseName is the name of the
// database on which the sync group is hosted. syncGroupName is the name of the sync group. parameters is the requested
// sync group resource state.
func (client SyncGroupsClient) Update(resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup, cancel <-chan struct{}) (<-chan SyncGroup, <-chan error) {
resultChan := make(chan SyncGroup, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result SyncGroup
defer func() {
if err != nil {
errChan <- err
}
resultChan <- result
close(resultChan)
close(errChan)
}()
req, err := client.UpdatePreparer(resourceGroupName, serverName, databaseName, syncGroupName, parameters, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Update", nil, "Failure preparing request")
return
}
resp, err := client.UpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Update", resp, "Failure sending request")
return
}
result, err = client.UpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Update", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// UpdatePreparer prepares the Update request.
func (client SyncGroupsClient) UpdatePreparer(resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup, cancel <-chan struct{}) (*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),
"syncGroupName": autorest.Encode("path", syncGroupName),
}
const APIVersion = "2015-05-01-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPatch(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// UpdateSender sends the Update request. The method will close the
// http.Response Body if it receives an error.
func (client SyncGroupsClient) UpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoRetryWithRegistration(client.Client),
azure.DoPollForAsynchronous(client.PollingDelay))
}
// UpdateResponder handles the response to the Update request. The method always
// closes the http.Response Body.
func (client SyncGroupsClient) UpdateResponder(resp *http.Response) (result SyncGroup, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}