From 0e8ed17a79fdf232e54026603a0fba8dfbca11f8 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Sun, 12 Jan 2020 12:29:11 +0000 Subject: [PATCH] Generated from 30ec96c398eaa29469e127fdd84e9484a6d76d4c Add a new api-version for storage sync --- .../mgmt/2019-06-01/storagesync/client.go | 52 + .../2019-06-01/storagesync/cloudendpoints.go | 964 +++++++ .../mgmt/2019-06-01/storagesync/models.go | 2242 +++++++++++++++++ .../mgmt/2019-06-01/storagesync/operations.go | 148 ++ .../2019-06-01/storagesync/operationstatus.go | 134 + .../storagesync/registeredservers.go | 491 ++++ .../2019-06-01/storagesync/serverendpoints.go | 608 +++++ .../mgmt/2019-06-01/storagesync/services.go | 651 +++++ .../storagesync/storagesyncapi/interfaces.go | 110 + .../mgmt/2019-06-01/storagesync/syncgroups.go | 399 +++ .../mgmt/2019-06-01/storagesync/version.go | 30 + .../mgmt/2019-06-01/storagesync/workflows.go | 307 +++ 12 files changed, 6136 insertions(+) create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/client.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/cloudendpoints.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/models.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/operations.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/operationstatus.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/registeredservers.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/serverendpoints.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/services.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/storagesyncapi/interfaces.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/syncgroups.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/version.go create mode 100644 services/storagesync/mgmt/2019-06-01/storagesync/workflows.go diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/client.go b/services/storagesync/mgmt/2019-06-01/storagesync/client.go new file mode 100644 index 000000000000..337a34ff3888 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/client.go @@ -0,0 +1,52 @@ +// Package storagesync implements the Azure ARM Storagesync service API version 2019-06-01. +// +// Microsoft Storage Sync Service API +package storagesync + +// 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" +) + +const ( + // DefaultBaseURI is the default URI used for the service Storagesync + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Storagesync. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/cloudendpoints.go b/services/storagesync/mgmt/2019-06-01/storagesync/cloudendpoints.go new file mode 100644 index 000000000000..f1249a710825 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/cloudendpoints.go @@ -0,0 +1,964 @@ +package storagesync + +// 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" +) + +// CloudEndpointsClient is the microsoft Storage Sync Service API +type CloudEndpointsClient struct { + BaseClient +} + +// NewCloudEndpointsClient creates an instance of the CloudEndpointsClient client. +func NewCloudEndpointsClient(subscriptionID string) CloudEndpointsClient { + return NewCloudEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCloudEndpointsClientWithBaseURI creates an instance of the CloudEndpointsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCloudEndpointsClientWithBaseURI(baseURI string, subscriptionID string) CloudEndpointsClient { + return CloudEndpointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a new CloudEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// cloudEndpointName - name of Cloud Endpoint object. +// parameters - body of Cloud Endpoint resource. +func (client CloudEndpointsClient) Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters CloudEndpointCreateParameters) (result CloudEndpointsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client CloudEndpointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters CloudEndpointCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudEndpointName": autorest.Encode("path", cloudEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client CloudEndpointsClient) CreateSender(req *http.Request) (future CloudEndpointsCreateFuture, 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 +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client CloudEndpointsClient) CreateResponder(resp *http.Response) (result CloudEndpoint, 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 +} + +// Delete delete a given CloudEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// cloudEndpointName - name of Cloud Endpoint object. +func (client CloudEndpointsClient) Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (result CloudEndpointsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CloudEndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudEndpointName": autorest.Encode("path", cloudEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}", 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 CloudEndpointsClient) DeleteSender(req *http.Request) (future CloudEndpointsDeleteFuture, 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 CloudEndpointsClient) 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 get a given CloudEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// cloudEndpointName - name of Cloud Endpoint object. +func (client CloudEndpointsClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (result CloudEndpoint, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CloudEndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudEndpointName": autorest.Encode("path", cloudEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}", 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 CloudEndpointsClient) 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 CloudEndpointsClient) GetResponder(resp *http.Response) (result CloudEndpoint, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySyncGroup get a CloudEndpoint List. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +func (client CloudEndpointsClient) ListBySyncGroup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result CloudEndpointArray, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.ListBySyncGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "ListBySyncGroup", err.Error()) + } + + req, err := client.ListBySyncGroupPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "ListBySyncGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySyncGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "ListBySyncGroup", resp, "Failure sending request") + return + } + + result, err = client.ListBySyncGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "ListBySyncGroup", resp, "Failure responding to request") + } + + return +} + +// ListBySyncGroupPreparer prepares the ListBySyncGroup request. +func (client CloudEndpointsClient) ListBySyncGroupPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySyncGroupSender sends the ListBySyncGroup request. The method will close the +// http.Response Body if it receives an error. +func (client CloudEndpointsClient) ListBySyncGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListBySyncGroupResponder handles the response to the ListBySyncGroup request. The method always +// closes the http.Response Body. +func (client CloudEndpointsClient) ListBySyncGroupResponder(resp *http.Response) (result CloudEndpointArray, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// PostBackup post Backup a given CloudEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// cloudEndpointName - name of Cloud Endpoint object. +// parameters - body of Backup request. +func (client CloudEndpointsClient) PostBackup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters BackupRequest) (result CloudEndpointsPostBackupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.PostBackup") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "PostBackup", err.Error()) + } + + req, err := client.PostBackupPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PostBackup", nil, "Failure preparing request") + return + } + + result, err = client.PostBackupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PostBackup", result.Response(), "Failure sending request") + return + } + + return +} + +// PostBackupPreparer prepares the PostBackup request. +func (client CloudEndpointsClient) PostBackupPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters BackupRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudEndpointName": autorest.Encode("path", cloudEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postbackup", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PostBackupSender sends the PostBackup request. The method will close the +// http.Response Body if it receives an error. +func (client CloudEndpointsClient) PostBackupSender(req *http.Request) (future CloudEndpointsPostBackupFuture, 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 +} + +// PostBackupResponder handles the response to the PostBackup request. The method always +// closes the http.Response Body. +func (client CloudEndpointsClient) PostBackupResponder(resp *http.Response) (result PostBackupResponse, 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 +} + +// PostRestore post Restore a given CloudEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// cloudEndpointName - name of Cloud Endpoint object. +// parameters - body of Cloud Endpoint object. +func (client CloudEndpointsClient) PostRestore(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters PostRestoreRequest) (result CloudEndpointsPostRestoreFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.PostRestore") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "PostRestore", err.Error()) + } + + req, err := client.PostRestorePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PostRestore", nil, "Failure preparing request") + return + } + + result, err = client.PostRestoreSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PostRestore", result.Response(), "Failure sending request") + return + } + + return +} + +// PostRestorePreparer prepares the PostRestore request. +func (client CloudEndpointsClient) PostRestorePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters PostRestoreRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudEndpointName": autorest.Encode("path", cloudEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/postrestore", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PostRestoreSender sends the PostRestore request. The method will close the +// http.Response Body if it receives an error. +func (client CloudEndpointsClient) PostRestoreSender(req *http.Request) (future CloudEndpointsPostRestoreFuture, 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 +} + +// PostRestoreResponder handles the response to the PostRestore request. The method always +// closes the http.Response Body. +func (client CloudEndpointsClient) PostRestoreResponder(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 +} + +// PreBackup pre Backup a given CloudEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// cloudEndpointName - name of Cloud Endpoint object. +// parameters - body of Backup request. +func (client CloudEndpointsClient) PreBackup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters BackupRequest) (result CloudEndpointsPreBackupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.PreBackup") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "PreBackup", err.Error()) + } + + req, err := client.PreBackupPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PreBackup", nil, "Failure preparing request") + return + } + + result, err = client.PreBackupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PreBackup", result.Response(), "Failure sending request") + return + } + + return +} + +// PreBackupPreparer prepares the PreBackup request. +func (client CloudEndpointsClient) PreBackupPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters BackupRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudEndpointName": autorest.Encode("path", cloudEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prebackup", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PreBackupSender sends the PreBackup request. The method will close the +// http.Response Body if it receives an error. +func (client CloudEndpointsClient) PreBackupSender(req *http.Request) (future CloudEndpointsPreBackupFuture, 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 +} + +// PreBackupResponder handles the response to the PreBackup request. The method always +// closes the http.Response Body. +func (client CloudEndpointsClient) PreBackupResponder(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 +} + +// PreRestore pre Restore a given CloudEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// cloudEndpointName - name of Cloud Endpoint object. +// parameters - body of Cloud Endpoint object. +func (client CloudEndpointsClient) PreRestore(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters PreRestoreRequest) (result CloudEndpointsPreRestoreFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.PreRestore") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "PreRestore", err.Error()) + } + + req, err := client.PreRestorePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PreRestore", nil, "Failure preparing request") + return + } + + result, err = client.PreRestoreSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "PreRestore", result.Response(), "Failure sending request") + return + } + + return +} + +// PreRestorePreparer prepares the PreRestore request. +func (client CloudEndpointsClient) PreRestorePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters PreRestoreRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudEndpointName": autorest.Encode("path", cloudEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/prerestore", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PreRestoreSender sends the PreRestore request. The method will close the +// http.Response Body if it receives an error. +func (client CloudEndpointsClient) PreRestoreSender(req *http.Request) (future CloudEndpointsPreRestoreFuture, 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 +} + +// PreRestoreResponder handles the response to the PreRestore request. The method always +// closes the http.Response Body. +func (client CloudEndpointsClient) PreRestoreResponder(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 +} + +// Restoreheartbeat restore Heartbeat a given CloudEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// cloudEndpointName - name of Cloud Endpoint object. +func (client CloudEndpointsClient) Restoreheartbeat(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.Restoreheartbeat") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "Restoreheartbeat", err.Error()) + } + + req, err := client.RestoreheartbeatPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Restoreheartbeat", nil, "Failure preparing request") + return + } + + resp, err := client.RestoreheartbeatSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Restoreheartbeat", resp, "Failure sending request") + return + } + + result, err = client.RestoreheartbeatResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "Restoreheartbeat", resp, "Failure responding to request") + } + + return +} + +// RestoreheartbeatPreparer prepares the Restoreheartbeat request. +func (client CloudEndpointsClient) RestoreheartbeatPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudEndpointName": autorest.Encode("path", cloudEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/restoreheartbeat", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RestoreheartbeatSender sends the Restoreheartbeat request. The method will close the +// http.Response Body if it receives an error. +func (client CloudEndpointsClient) RestoreheartbeatSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// RestoreheartbeatResponder handles the response to the Restoreheartbeat request. The method always +// closes the http.Response Body. +func (client CloudEndpointsClient) RestoreheartbeatResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// TriggerChangeDetection triggers detection of changes performed on Azure File share connected to the specified Azure +// File Sync Cloud Endpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// cloudEndpointName - name of Cloud Endpoint object. +// parameters - trigger Change Detection Action parameters. +func (client CloudEndpointsClient) TriggerChangeDetection(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters TriggerChangeDetectionParameters) (result CloudEndpointsTriggerChangeDetectionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CloudEndpointsClient.TriggerChangeDetection") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.CloudEndpointsClient", "TriggerChangeDetection", err.Error()) + } + + req, err := client.TriggerChangeDetectionPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, cloudEndpointName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "TriggerChangeDetection", nil, "Failure preparing request") + return + } + + result, err = client.TriggerChangeDetectionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsClient", "TriggerChangeDetection", result.Response(), "Failure sending request") + return + } + + return +} + +// TriggerChangeDetectionPreparer prepares the TriggerChangeDetection request. +func (client CloudEndpointsClient) TriggerChangeDetectionPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters TriggerChangeDetectionParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cloudEndpointName": autorest.Encode("path", cloudEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/cloudEndpoints/{cloudEndpointName}/triggerChangeDetection", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TriggerChangeDetectionSender sends the TriggerChangeDetection request. The method will close the +// http.Response Body if it receives an error. +func (client CloudEndpointsClient) TriggerChangeDetectionSender(req *http.Request) (future CloudEndpointsTriggerChangeDetectionFuture, 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 +} + +// TriggerChangeDetectionResponder handles the response to the TriggerChangeDetection request. The method always +// closes the http.Response Body. +func (client CloudEndpointsClient) TriggerChangeDetectionResponder(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 +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/models.go b/services/storagesync/mgmt/2019-06-01/storagesync/models.go new file mode 100644 index 000000000000..b548bb6edc7c --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/models.go @@ -0,0 +1,2242 @@ +package storagesync + +// 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" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/storagesync/mgmt/2019-06-01/storagesync" + +// ChangeDetectionMode enumerates the values for change detection mode. +type ChangeDetectionMode string + +const ( + // Default ... + Default ChangeDetectionMode = "Default" + // Recursive ... + Recursive ChangeDetectionMode = "Recursive" +) + +// PossibleChangeDetectionModeValues returns an array of possible values for the ChangeDetectionMode const type. +func PossibleChangeDetectionModeValues() []ChangeDetectionMode { + return []ChangeDetectionMode{Default, Recursive} +} + +// CloudTiering enumerates the values for cloud tiering. +type CloudTiering string + +const ( + // Off ... + Off CloudTiering = "off" + // On ... + On CloudTiering = "on" +) + +// PossibleCloudTieringValues returns an array of possible values for the CloudTiering const type. +func PossibleCloudTieringValues() []CloudTiering { + return []CloudTiering{Off, On} +} + +// CloudTiering1 enumerates the values for cloud tiering 1. +type CloudTiering1 string + +const ( + // CloudTiering1Off ... + CloudTiering1Off CloudTiering1 = "off" + // CloudTiering1On ... + CloudTiering1On CloudTiering1 = "on" +) + +// PossibleCloudTiering1Values returns an array of possible values for the CloudTiering1 const type. +func PossibleCloudTiering1Values() []CloudTiering1 { + return []CloudTiering1{CloudTiering1Off, CloudTiering1On} +} + +// CloudTiering2 enumerates the values for cloud tiering 2. +type CloudTiering2 string + +const ( + // CloudTiering2Off ... + CloudTiering2Off CloudTiering2 = "off" + // CloudTiering2On ... + CloudTiering2On CloudTiering2 = "on" +) + +// PossibleCloudTiering2Values returns an array of possible values for the CloudTiering2 const type. +func PossibleCloudTiering2Values() []CloudTiering2 { + return []CloudTiering2{CloudTiering2Off, CloudTiering2On} +} + +// CombinedHealth enumerates the values for combined health. +type CombinedHealth string + +const ( + // CombinedHealthError ... + CombinedHealthError CombinedHealth = "Error" + // CombinedHealthHealthy ... + CombinedHealthHealthy CombinedHealth = "Healthy" + // CombinedHealthNoActivity ... + CombinedHealthNoActivity CombinedHealth = "NoActivity" + // CombinedHealthSyncBlockedForChangeDetectionPostRestore ... + CombinedHealthSyncBlockedForChangeDetectionPostRestore CombinedHealth = "SyncBlockedForChangeDetectionPostRestore" + // CombinedHealthSyncBlockedForRestore ... + CombinedHealthSyncBlockedForRestore CombinedHealth = "SyncBlockedForRestore" +) + +// PossibleCombinedHealthValues returns an array of possible values for the CombinedHealth const type. +func PossibleCombinedHealthValues() []CombinedHealth { + return []CombinedHealth{CombinedHealthError, CombinedHealthHealthy, CombinedHealthNoActivity, CombinedHealthSyncBlockedForChangeDetectionPostRestore, CombinedHealthSyncBlockedForRestore} +} + +// DownloadHealth enumerates the values for download health. +type DownloadHealth string + +const ( + // DownloadHealthError ... + DownloadHealthError DownloadHealth = "Error" + // DownloadHealthHealthy ... + DownloadHealthHealthy DownloadHealth = "Healthy" + // DownloadHealthNoActivity ... + DownloadHealthNoActivity DownloadHealth = "NoActivity" + // DownloadHealthSyncBlockedForChangeDetectionPostRestore ... + DownloadHealthSyncBlockedForChangeDetectionPostRestore DownloadHealth = "SyncBlockedForChangeDetectionPostRestore" + // DownloadHealthSyncBlockedForRestore ... + DownloadHealthSyncBlockedForRestore DownloadHealth = "SyncBlockedForRestore" +) + +// PossibleDownloadHealthValues returns an array of possible values for the DownloadHealth const type. +func PossibleDownloadHealthValues() []DownloadHealth { + return []DownloadHealth{DownloadHealthError, DownloadHealthHealthy, DownloadHealthNoActivity, DownloadHealthSyncBlockedForChangeDetectionPostRestore, DownloadHealthSyncBlockedForRestore} +} + +// Health enumerates the values for health. +type Health string + +const ( + // HealthError ... + HealthError Health = "Error" + // HealthHealthy ... + HealthHealthy Health = "Healthy" +) + +// PossibleHealthValues returns an array of possible values for the Health const type. +func PossibleHealthValues() []Health { + return []Health{HealthError, HealthHealthy} +} + +// NameAvailabilityReason enumerates the values for name availability reason. +type NameAvailabilityReason string + +const ( + // AlreadyExists ... + AlreadyExists NameAvailabilityReason = "AlreadyExists" + // Invalid ... + Invalid NameAvailabilityReason = "Invalid" +) + +// PossibleNameAvailabilityReasonValues returns an array of possible values for the NameAvailabilityReason const type. +func PossibleNameAvailabilityReasonValues() []NameAvailabilityReason { + return []NameAvailabilityReason{AlreadyExists, Invalid} +} + +// OfflineDataTransfer enumerates the values for offline data transfer. +type OfflineDataTransfer string + +const ( + // OfflineDataTransferOff ... + OfflineDataTransferOff OfflineDataTransfer = "off" + // OfflineDataTransferOn ... + OfflineDataTransferOn OfflineDataTransfer = "on" +) + +// PossibleOfflineDataTransferValues returns an array of possible values for the OfflineDataTransfer const type. +func PossibleOfflineDataTransferValues() []OfflineDataTransfer { + return []OfflineDataTransfer{OfflineDataTransferOff, OfflineDataTransferOn} +} + +// OfflineDataTransfer1 enumerates the values for offline data transfer 1. +type OfflineDataTransfer1 string + +const ( + // OfflineDataTransfer1Off ... + OfflineDataTransfer1Off OfflineDataTransfer1 = "off" + // OfflineDataTransfer1On ... + OfflineDataTransfer1On OfflineDataTransfer1 = "on" +) + +// PossibleOfflineDataTransfer1Values returns an array of possible values for the OfflineDataTransfer1 const type. +func PossibleOfflineDataTransfer1Values() []OfflineDataTransfer1 { + return []OfflineDataTransfer1{OfflineDataTransfer1Off, OfflineDataTransfer1On} +} + +// OfflineDataTransfer2 enumerates the values for offline data transfer 2. +type OfflineDataTransfer2 string + +const ( + // OfflineDataTransfer2Off ... + OfflineDataTransfer2Off OfflineDataTransfer2 = "off" + // OfflineDataTransfer2On ... + OfflineDataTransfer2On OfflineDataTransfer2 = "on" +) + +// PossibleOfflineDataTransfer2Values returns an array of possible values for the OfflineDataTransfer2 const type. +func PossibleOfflineDataTransfer2Values() []OfflineDataTransfer2 { + return []OfflineDataTransfer2{OfflineDataTransfer2Off, OfflineDataTransfer2On} +} + +// OfflineDataTransferStatus enumerates the values for offline data transfer status. +type OfflineDataTransferStatus string + +const ( + // Complete ... + Complete OfflineDataTransferStatus = "Complete" + // InProgress ... + InProgress OfflineDataTransferStatus = "InProgress" + // NotRunning ... + NotRunning OfflineDataTransferStatus = "NotRunning" + // Stopping ... + Stopping OfflineDataTransferStatus = "Stopping" +) + +// PossibleOfflineDataTransferStatusValues returns an array of possible values for the OfflineDataTransferStatus const type. +func PossibleOfflineDataTransferStatusValues() []OfflineDataTransferStatus { + return []OfflineDataTransferStatus{Complete, InProgress, NotRunning, Stopping} +} + +// Operation enumerates the values for operation. +type Operation string + +const ( + // Cancel ... + Cancel Operation = "cancel" + // Do ... + Do Operation = "do" + // Undo ... + Undo Operation = "undo" +) + +// PossibleOperationValues returns an array of possible values for the Operation const type. +func PossibleOperationValues() []Operation { + return []Operation{Cancel, Do, Undo} +} + +// Reason enumerates the values for reason. +type Reason string + +const ( + // Deleted ... + Deleted Reason = "Deleted" + // Registered ... + Registered Reason = "Registered" + // Suspended ... + Suspended Reason = "Suspended" + // Unregistered ... + Unregistered Reason = "Unregistered" + // Warned ... + Warned Reason = "Warned" +) + +// PossibleReasonValues returns an array of possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{Deleted, Registered, Suspended, Unregistered, Warned} +} + +// Status enumerates the values for status. +type Status string + +const ( + // Aborted ... + Aborted Status = "aborted" + // Active ... + Active Status = "active" + // Expired ... + Expired Status = "expired" + // Failed ... + Failed Status = "failed" + // Succeeded ... + Succeeded Status = "succeeded" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{Aborted, Active, Expired, Failed, Succeeded} +} + +// SyncActivity enumerates the values for sync activity. +type SyncActivity string + +const ( + // Download ... + Download SyncActivity = "Download" + // Upload ... + Upload SyncActivity = "Upload" + // UploadAndDownload ... + UploadAndDownload SyncActivity = "UploadAndDownload" +) + +// PossibleSyncActivityValues returns an array of possible values for the SyncActivity const type. +func PossibleSyncActivityValues() []SyncActivity { + return []SyncActivity{Download, Upload, UploadAndDownload} +} + +// UploadHealth enumerates the values for upload health. +type UploadHealth string + +const ( + // UploadHealthError ... + UploadHealthError UploadHealth = "Error" + // UploadHealthHealthy ... + UploadHealthHealthy UploadHealth = "Healthy" + // UploadHealthNoActivity ... + UploadHealthNoActivity UploadHealth = "NoActivity" + // UploadHealthSyncBlockedForChangeDetectionPostRestore ... + UploadHealthSyncBlockedForChangeDetectionPostRestore UploadHealth = "SyncBlockedForChangeDetectionPostRestore" + // UploadHealthSyncBlockedForRestore ... + UploadHealthSyncBlockedForRestore UploadHealth = "SyncBlockedForRestore" +) + +// PossibleUploadHealthValues returns an array of possible values for the UploadHealth const type. +func PossibleUploadHealthValues() []UploadHealth { + return []UploadHealth{UploadHealthError, UploadHealthHealthy, UploadHealthNoActivity, UploadHealthSyncBlockedForChangeDetectionPostRestore, UploadHealthSyncBlockedForRestore} +} + +// APIError error type +type APIError struct { + // Code - Error code of the given entry. + Code *string `json:"code,omitempty"` + // Message - Error message of the given entry. + Message *string `json:"message,omitempty"` + // Target - Target of the given error entry. + Target *string `json:"target,omitempty"` + // Details - Error details of the given entry. + Details *ErrorDetails `json:"details,omitempty"` +} + +// AzureEntityResource the resource model definition for a Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// BackupRequest backup request +type BackupRequest struct { + // AzureFileShare - Azure File Share. + AzureFileShare *string `json:"azureFileShare,omitempty"` +} + +// CheckNameAvailabilityParameters parameters for a check name availability request. +type CheckNameAvailabilityParameters struct { + // Name - The name to check for availability + Name *string `json:"name,omitempty"` + // Type - The resource type. Must be set to Microsoft.StorageSync/storageSyncServices + Type *string `json:"type,omitempty"` +} + +// CheckNameAvailabilityResult the CheckNameAvailability operation response. +type CheckNameAvailabilityResult struct { + autorest.Response `json:"-"` + // NameAvailable - READ-ONLY; Gets a boolean value that indicates whether the name is available for you to use. If true, the name is available. If false, the name has already been taken or invalid and cannot be used. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - READ-ONLY; Gets the reason that a Storage Sync Service name could not be used. The Reason element is only returned if NameAvailable is false. Possible values include: 'Invalid', 'AlreadyExists' + Reason NameAvailabilityReason `json:"reason,omitempty"` + // Message - READ-ONLY; Gets an error message explaining the Reason value in more detail. + Message *string `json:"message,omitempty"` +} + +// CloudEndpoint cloud Endpoint object. +type CloudEndpoint struct { + autorest.Response `json:"-"` + // CloudEndpointProperties - Cloud Endpoint properties. + *CloudEndpointProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CloudEndpoint. +func (ce CloudEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ce.CloudEndpointProperties != nil { + objectMap["properties"] = ce.CloudEndpointProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CloudEndpoint struct. +func (ce *CloudEndpoint) 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 cloudEndpointProperties CloudEndpointProperties + err = json.Unmarshal(*v, &cloudEndpointProperties) + if err != nil { + return err + } + ce.CloudEndpointProperties = &cloudEndpointProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ce.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ce.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ce.Type = &typeVar + } + } + } + + return nil +} + +// CloudEndpointArray array of CloudEndpoint +type CloudEndpointArray struct { + autorest.Response `json:"-"` + // Value - Collection of CloudEndpoint. + Value *[]CloudEndpoint `json:"value,omitempty"` +} + +// CloudEndpointCreateParameters the parameters used when creating a cloud endpoint. +type CloudEndpointCreateParameters struct { + // CloudEndpointCreateParametersProperties - The parameters used to create the cloud endpoint. + *CloudEndpointCreateParametersProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CloudEndpointCreateParameters. +func (cecp CloudEndpointCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cecp.CloudEndpointCreateParametersProperties != nil { + objectMap["properties"] = cecp.CloudEndpointCreateParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CloudEndpointCreateParameters struct. +func (cecp *CloudEndpointCreateParameters) 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 cloudEndpointCreateParametersProperties CloudEndpointCreateParametersProperties + err = json.Unmarshal(*v, &cloudEndpointCreateParametersProperties) + if err != nil { + return err + } + cecp.CloudEndpointCreateParametersProperties = &cloudEndpointCreateParametersProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cecp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cecp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cecp.Type = &typeVar + } + } + } + + return nil +} + +// CloudEndpointCreateParametersProperties cloudEndpoint Properties object. +type CloudEndpointCreateParametersProperties struct { + // StorageAccountResourceID - Storage Account Resource Id + StorageAccountResourceID *string `json:"storageAccountResourceId,omitempty"` + // AzureFileShareName - Azure file share name + AzureFileShareName *string `json:"azureFileShareName,omitempty"` + // StorageAccountTenantID - Storage Account Tenant Id + StorageAccountTenantID *string `json:"storageAccountTenantId,omitempty"` + // FriendlyName - Friendly Name + FriendlyName *string `json:"friendlyName,omitempty"` +} + +// CloudEndpointProperties cloudEndpoint Properties object. +type CloudEndpointProperties struct { + // StorageAccountResourceID - Storage Account Resource Id + StorageAccountResourceID *string `json:"storageAccountResourceId,omitempty"` + // AzureFileShareName - Azure file share name + AzureFileShareName *string `json:"azureFileShareName,omitempty"` + // StorageAccountTenantID - Storage Account Tenant Id + StorageAccountTenantID *string `json:"storageAccountTenantId,omitempty"` + // PartnershipID - Partnership Id + PartnershipID *string `json:"partnershipId,omitempty"` + // FriendlyName - Friendly Name + FriendlyName *string `json:"friendlyName,omitempty"` + // BackupEnabled - READ-ONLY; Backup Enabled + BackupEnabled *string `json:"backupEnabled,omitempty"` + // ProvisioningState - CloudEndpoint Provisioning State + ProvisioningState *string `json:"provisioningState,omitempty"` + // LastWorkflowID - CloudEndpoint lastWorkflowId + LastWorkflowID *string `json:"lastWorkflowId,omitempty"` + // LastOperationName - Resource Last Operation Name + LastOperationName *string `json:"lastOperationName,omitempty"` +} + +// CloudEndpointsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CloudEndpointsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CloudEndpointsCreateFuture) Result(client CloudEndpointsClient) (ce CloudEndpoint, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.CloudEndpointsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ce.Response.Response, err = future.GetResult(sender); err == nil && ce.Response.Response.StatusCode != http.StatusNoContent { + ce, err = client.CreateResponder(ce.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsCreateFuture", "Result", ce.Response.Response, "Failure responding to request") + } + } + return +} + +// CloudEndpointsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CloudEndpointsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CloudEndpointsDeleteFuture) Result(client CloudEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.CloudEndpointsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// CloudEndpointsPostBackupFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CloudEndpointsPostBackupFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CloudEndpointsPostBackupFuture) Result(client CloudEndpointsClient) (pbr PostBackupResponse, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsPostBackupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.CloudEndpointsPostBackupFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pbr.Response.Response, err = future.GetResult(sender); err == nil && pbr.Response.Response.StatusCode != http.StatusNoContent { + pbr, err = client.PostBackupResponder(pbr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsPostBackupFuture", "Result", pbr.Response.Response, "Failure responding to request") + } + } + return +} + +// CloudEndpointsPostRestoreFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CloudEndpointsPostRestoreFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CloudEndpointsPostRestoreFuture) Result(client CloudEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsPostRestoreFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.CloudEndpointsPostRestoreFuture") + return + } + ar.Response = future.Response() + return +} + +// CloudEndpointsPreBackupFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CloudEndpointsPreBackupFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CloudEndpointsPreBackupFuture) Result(client CloudEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsPreBackupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.CloudEndpointsPreBackupFuture") + return + } + ar.Response = future.Response() + return +} + +// CloudEndpointsPreRestoreFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CloudEndpointsPreRestoreFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CloudEndpointsPreRestoreFuture) Result(client CloudEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsPreRestoreFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.CloudEndpointsPreRestoreFuture") + return + } + ar.Response = future.Response() + return +} + +// CloudEndpointsTriggerChangeDetectionFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CloudEndpointsTriggerChangeDetectionFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CloudEndpointsTriggerChangeDetectionFuture) Result(client CloudEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.CloudEndpointsTriggerChangeDetectionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.CloudEndpointsTriggerChangeDetectionFuture") + return + } + ar.Response = future.Response() + return +} + +// Error error type +type Error struct { + // Error - Error details of the given entry. + Error *APIError `json:"error,omitempty"` + // Innererror - Error details of the given entry. + Innererror *APIError `json:"innererror,omitempty"` +} + +// ErrorDetails error Details object. +type ErrorDetails struct { + // Code - Error code of the given entry. + Code *string `json:"code,omitempty"` + // Message - Error message of the given entry. + Message *string `json:"message,omitempty"` + // Target - Target of the given entry. + Target *string `json:"target,omitempty"` +} + +// OperationDisplayInfo the operation supported by storage sync. +type OperationDisplayInfo struct { + // Description - The description of the operation. + Description *string `json:"description,omitempty"` + // Operation - The action that users can perform, based on their permission level. + Operation *string `json:"operation,omitempty"` + // Provider - Service provider: Microsoft StorageSync. + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationDisplayResource operation Display Resource object. +type OperationDisplayResource struct { + // Provider - Operation Display Resource Provider. + Provider *string `json:"provider,omitempty"` + // Resource - Operation Display Resource. + Resource *string `json:"resource,omitempty"` + // Operation - Operation Display Resource Operation. + Operation *string `json:"operation,omitempty"` + // Description - Operation Display Resource Description. + Description *string `json:"description,omitempty"` +} + +// OperationEntity the operation supported by storage sync. +type OperationEntity struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The operation supported by storage sync. + Display *OperationDisplayInfo `json:"display,omitempty"` + // Origin - The origin. + Origin *string `json:"origin,omitempty"` +} + +// OperationEntityListResult the list of storage sync operations. +type OperationEntityListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of operations. + Value *[]OperationEntity `json:"value,omitempty"` +} + +// OperationEntityListResultIterator provides access to a complete listing of OperationEntity values. +type OperationEntityListResultIterator struct { + i int + page OperationEntityListResultPage +} + +// 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 *OperationEntityListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationEntityListResultIterator.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 *OperationEntityListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationEntityListResultIterator) 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 OperationEntityListResultIterator) Response() OperationEntityListResult { + 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 OperationEntityListResultIterator) Value() OperationEntity { + if !iter.page.NotDone() { + return OperationEntity{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationEntityListResultIterator type. +func NewOperationEntityListResultIterator(page OperationEntityListResultPage) OperationEntityListResultIterator { + return OperationEntityListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (oelr OperationEntityListResult) IsEmpty() bool { + return oelr.Value == nil || len(*oelr.Value) == 0 +} + +// operationEntityListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (oelr OperationEntityListResult) operationEntityListResultPreparer(ctx context.Context) (*http.Request, error) { + if oelr.NextLink == nil || len(to.String(oelr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(oelr.NextLink))) +} + +// OperationEntityListResultPage contains a page of OperationEntity values. +type OperationEntityListResultPage struct { + fn func(context.Context, OperationEntityListResult) (OperationEntityListResult, error) + oelr OperationEntityListResult +} + +// 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 *OperationEntityListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationEntityListResultPage.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.oelr) + if err != nil { + return err + } + page.oelr = 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 *OperationEntityListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationEntityListResultPage) NotDone() bool { + return !page.oelr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationEntityListResultPage) Response() OperationEntityListResult { + return page.oelr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationEntityListResultPage) Values() []OperationEntity { + if page.oelr.IsEmpty() { + return nil + } + return *page.oelr.Value +} + +// Creates a new instance of the OperationEntityListResultPage type. +func NewOperationEntityListResultPage(getNextPage func(context.Context, OperationEntityListResult) (OperationEntityListResult, error)) OperationEntityListResultPage { + return OperationEntityListResultPage{fn: getNextPage} +} + +// OperationStatus operation status object +type OperationStatus struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; Operation Id + Name *string `json:"name,omitempty"` + // Status - READ-ONLY; Operation status + Status *string `json:"status,omitempty"` + // StartTime - READ-ONLY; Start time of the operation + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; End time of the operation + EndTime *date.Time `json:"endTime,omitempty"` + // Error - READ-ONLY; Error details. + Error *APIError `json:"error,omitempty"` +} + +// PostBackupResponse post Backup Response +type PostBackupResponse struct { + autorest.Response `json:"-"` + // PostBackupResponseProperties - Post Backup Response Properties + *PostBackupResponseProperties `json:"backupMetadata,omitempty"` +} + +// MarshalJSON is the custom marshaler for PostBackupResponse. +func (pbr PostBackupResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pbr.PostBackupResponseProperties != nil { + objectMap["backupMetadata"] = pbr.PostBackupResponseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PostBackupResponse struct. +func (pbr *PostBackupResponse) 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 "backupMetadata": + if v != nil { + var postBackupResponseProperties PostBackupResponseProperties + err = json.Unmarshal(*v, &postBackupResponseProperties) + if err != nil { + return err + } + pbr.PostBackupResponseProperties = &postBackupResponseProperties + } + } + } + + return nil +} + +// PostBackupResponseProperties post Backup Response Properties object. +type PostBackupResponseProperties struct { + // CloudEndpointName - READ-ONLY; cloud endpoint Name. + CloudEndpointName *string `json:"cloudEndpointName,omitempty"` +} + +// PostRestoreRequest post Restore Request +type PostRestoreRequest struct { + // Partition - Post Restore partition. + Partition *string `json:"partition,omitempty"` + // ReplicaGroup - Post Restore replica group. + ReplicaGroup *string `json:"replicaGroup,omitempty"` + // RequestID - Post Restore request id. + RequestID *string `json:"requestId,omitempty"` + // AzureFileShareURI - Post Restore Azure file share uri. + AzureFileShareURI *string `json:"azureFileShareUri,omitempty"` + // Status - Post Restore Azure status. + Status *string `json:"status,omitempty"` + // SourceAzureFileShareURI - Post Restore Azure source azure file share uri. + SourceAzureFileShareURI *string `json:"sourceAzureFileShareUri,omitempty"` + // FailedFileList - Post Restore Azure failed file list. + FailedFileList *string `json:"failedFileList,omitempty"` + // RestoreFileSpec - Post Restore restore file spec array. + RestoreFileSpec *[]RestoreFileSpec `json:"restoreFileSpec,omitempty"` +} + +// PreRestoreRequest pre Restore request object. +type PreRestoreRequest struct { + // Partition - Pre Restore partition. + Partition *string `json:"partition,omitempty"` + // ReplicaGroup - Pre Restore replica group. + ReplicaGroup *string `json:"replicaGroup,omitempty"` + // RequestID - Pre Restore request id. + RequestID *string `json:"requestId,omitempty"` + // AzureFileShareURI - Pre Restore Azure file share uri. + AzureFileShareURI *string `json:"azureFileShareUri,omitempty"` + // Status - Pre Restore Azure status. + Status *string `json:"status,omitempty"` + // SourceAzureFileShareURI - Pre Restore Azure source azure file share uri. + SourceAzureFileShareURI *string `json:"sourceAzureFileShareUri,omitempty"` + // BackupMetadataPropertyBag - Pre Restore backup metadata property bag. + BackupMetadataPropertyBag *string `json:"backupMetadataPropertyBag,omitempty"` + // RestoreFileSpec - Pre Restore restore file spec array. + RestoreFileSpec *[]RestoreFileSpec `json:"restoreFileSpec,omitempty"` + // PauseWaitForSyncDrainTimePeriodInSeconds - Pre Restore pause wait for sync drain time period in seconds. + PauseWaitForSyncDrainTimePeriodInSeconds *int32 `json:"pauseWaitForSyncDrainTimePeriodInSeconds,omitempty"` +} + +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// RecallActionParameters the parameters used when calling recall action on server endpoint. +type RecallActionParameters struct { + // Pattern - Pattern of the files. + Pattern *string `json:"pattern,omitempty"` + // RecallPath - Recall path. + RecallPath *string `json:"recallPath,omitempty"` +} + +// RegisteredServer registered Server resource. +type RegisteredServer struct { + autorest.Response `json:"-"` + // RegisteredServerProperties - RegisteredServer properties. + *RegisteredServerProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegisteredServer. +func (rs RegisteredServer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rs.RegisteredServerProperties != nil { + objectMap["properties"] = rs.RegisteredServerProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegisteredServer struct. +func (rs *RegisteredServer) 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 registeredServerProperties RegisteredServerProperties + err = json.Unmarshal(*v, ®isteredServerProperties) + if err != nil { + return err + } + rs.RegisteredServerProperties = ®isteredServerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rs.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rs.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rs.Type = &typeVar + } + } + } + + return nil +} + +// RegisteredServerArray array of RegisteredServer +type RegisteredServerArray struct { + autorest.Response `json:"-"` + // Value - Collection of Registered Server. + Value *[]RegisteredServer `json:"value,omitempty"` +} + +// RegisteredServerCreateParameters the parameters used when creating a registered server. +type RegisteredServerCreateParameters struct { + // RegisteredServerCreateParametersProperties - The parameters used to create the registered server. + *RegisteredServerCreateParametersProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegisteredServerCreateParameters. +func (rscp RegisteredServerCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rscp.RegisteredServerCreateParametersProperties != nil { + objectMap["properties"] = rscp.RegisteredServerCreateParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegisteredServerCreateParameters struct. +func (rscp *RegisteredServerCreateParameters) 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 registeredServerCreateParametersProperties RegisteredServerCreateParametersProperties + err = json.Unmarshal(*v, ®isteredServerCreateParametersProperties) + if err != nil { + return err + } + rscp.RegisteredServerCreateParametersProperties = ®isteredServerCreateParametersProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rscp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rscp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rscp.Type = &typeVar + } + } + } + + return nil +} + +// RegisteredServerCreateParametersProperties ... +type RegisteredServerCreateParametersProperties struct { + // ServerCertificate - Registered Server Certificate + ServerCertificate *string `json:"serverCertificate,omitempty"` + // AgentVersion - Registered Server Agent Version + AgentVersion *string `json:"agentVersion,omitempty"` + // ServerOSVersion - Registered Server OS Version + ServerOSVersion *string `json:"serverOSVersion,omitempty"` + // LastHeartBeat - Registered Server last heart beat + LastHeartBeat *string `json:"lastHeartBeat,omitempty"` + // ServerRole - Registered Server serverRole + ServerRole *string `json:"serverRole,omitempty"` + // ClusterID - Registered Server clusterId + ClusterID *string `json:"clusterId,omitempty"` + // ClusterName - Registered Server clusterName + ClusterName *string `json:"clusterName,omitempty"` + // ServerID - Registered Server serverId + ServerID *string `json:"serverId,omitempty"` + // FriendlyName - Friendly Name + FriendlyName *string `json:"friendlyName,omitempty"` +} + +// RegisteredServerProperties registeredServer Properties object. +type RegisteredServerProperties struct { + // ServerCertificate - Registered Server Certificate + ServerCertificate *string `json:"serverCertificate,omitempty"` + // AgentVersion - Registered Server Agent Version + AgentVersion *string `json:"agentVersion,omitempty"` + // ServerOSVersion - Registered Server OS Version + ServerOSVersion *string `json:"serverOSVersion,omitempty"` + // ServerManagementErrorCode - Registered Server Management Error Code + ServerManagementErrorCode *int32 `json:"serverManagementErrorCode,omitempty"` + // LastHeartBeat - Registered Server last heart beat + LastHeartBeat *string `json:"lastHeartBeat,omitempty"` + // ProvisioningState - Registered Server Provisioning State + ProvisioningState *string `json:"provisioningState,omitempty"` + // ServerRole - Registered Server serverRole + ServerRole *string `json:"serverRole,omitempty"` + // ClusterID - Registered Server clusterId + ClusterID *string `json:"clusterId,omitempty"` + // ClusterName - Registered Server clusterName + ClusterName *string `json:"clusterName,omitempty"` + // ServerID - Registered Server serverId + ServerID *string `json:"serverId,omitempty"` + // StorageSyncServiceUID - Registered Server storageSyncServiceUid + StorageSyncServiceUID *string `json:"storageSyncServiceUid,omitempty"` + // LastWorkflowID - Registered Server lastWorkflowId + LastWorkflowID *string `json:"lastWorkflowId,omitempty"` + // LastOperationName - Resource Last Operation Name + LastOperationName *string `json:"lastOperationName,omitempty"` + // DiscoveryEndpointURI - Resource discoveryEndpointUri + DiscoveryEndpointURI *string `json:"discoveryEndpointUri,omitempty"` + // ResourceLocation - Resource Location + ResourceLocation *string `json:"resourceLocation,omitempty"` + // ServiceLocation - Service Location + ServiceLocation *string `json:"serviceLocation,omitempty"` + // FriendlyName - Friendly Name + FriendlyName *string `json:"friendlyName,omitempty"` + // ManagementEndpointURI - Management Endpoint Uri + ManagementEndpointURI *string `json:"managementEndpointUri,omitempty"` + // MonitoringConfiguration - Monitoring Configuration + MonitoringConfiguration *string `json:"monitoringConfiguration,omitempty"` +} + +// RegisteredServersCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type RegisteredServersCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *RegisteredServersCreateFuture) Result(client RegisteredServersClient) (rs RegisteredServer, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.RegisteredServersCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rs.Response.Response, err = future.GetResult(sender); err == nil && rs.Response.Response.StatusCode != http.StatusNoContent { + rs, err = client.CreateResponder(rs.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersCreateFuture", "Result", rs.Response.Response, "Failure responding to request") + } + } + return +} + +// RegisteredServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type RegisteredServersDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *RegisteredServersDeleteFuture) Result(client RegisteredServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.RegisteredServersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// RegisteredServersTriggerRolloverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type RegisteredServersTriggerRolloverFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *RegisteredServersTriggerRolloverFuture) Result(client RegisteredServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersTriggerRolloverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.RegisteredServersTriggerRolloverFuture") + return + } + ar.Response = future.Response() + return +} + +// Resource ... +type Resource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// ResourcesMoveInfo resource Move Info. +type ResourcesMoveInfo struct { + // TargetResourceGroup - Target resource group. + TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` + // Resources - Collection of Resources. + Resources *[]string `json:"resources,omitempty"` +} + +// RestoreFileSpec restore file spec. +type RestoreFileSpec struct { + // Path - Restore file spec path + Path *string `json:"path,omitempty"` + // Isdir - Restore file spec isdir + Isdir *bool `json:"isdir,omitempty"` +} + +// ServerEndpoint server Endpoint object. +type ServerEndpoint struct { + autorest.Response `json:"-"` + // ServerEndpointProperties - Server Endpoint properties. + *ServerEndpointProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerEndpoint. +func (se ServerEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if se.ServerEndpointProperties != nil { + objectMap["properties"] = se.ServerEndpointProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerEndpoint struct. +func (se *ServerEndpoint) 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 serverEndpointProperties ServerEndpointProperties + err = json.Unmarshal(*v, &serverEndpointProperties) + if err != nil { + return err + } + se.ServerEndpointProperties = &serverEndpointProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + se.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + se.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + se.Type = &typeVar + } + } + } + + return nil +} + +// ServerEndpointArray array of ServerEndpoint +type ServerEndpointArray struct { + autorest.Response `json:"-"` + // Value - Collection of ServerEndpoint. + Value *[]ServerEndpoint `json:"value,omitempty"` +} + +// ServerEndpointCloudTieringStatus server endpoint cloud tiering status object. +type ServerEndpointCloudTieringStatus struct { + // Health - READ-ONLY; Cloud tiering health state. Possible values include: 'HealthHealthy', 'HealthError' + Health Health `json:"health,omitempty"` + // LastUpdatedTimestamp - READ-ONLY; Last updated timestamp + LastUpdatedTimestamp *date.Time `json:"lastUpdatedTimestamp,omitempty"` + // LastCloudTieringResult - READ-ONLY; Last cloud tiering result (HResult) + LastCloudTieringResult *int32 `json:"lastCloudTieringResult,omitempty"` + // LastSuccessTimestamp - READ-ONLY; Last cloud tiering success timestamp + LastSuccessTimestamp *date.Time `json:"lastSuccessTimestamp,omitempty"` +} + +// ServerEndpointCreateParameters the parameters used when creating a server endpoint. +type ServerEndpointCreateParameters struct { + // ServerEndpointCreateParametersProperties - The parameters used to create the server endpoint. + *ServerEndpointCreateParametersProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerEndpointCreateParameters. +func (secp ServerEndpointCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if secp.ServerEndpointCreateParametersProperties != nil { + objectMap["properties"] = secp.ServerEndpointCreateParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerEndpointCreateParameters struct. +func (secp *ServerEndpointCreateParameters) 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 serverEndpointCreateParametersProperties ServerEndpointCreateParametersProperties + err = json.Unmarshal(*v, &serverEndpointCreateParametersProperties) + if err != nil { + return err + } + secp.ServerEndpointCreateParametersProperties = &serverEndpointCreateParametersProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + secp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + secp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + secp.Type = &typeVar + } + } + } + + return nil +} + +// ServerEndpointCreateParametersProperties serverEndpoint Properties object. +type ServerEndpointCreateParametersProperties struct { + // ServerLocalPath - Server Local path. + ServerLocalPath *string `json:"serverLocalPath,omitempty"` + // CloudTiering - Cloud Tiering. Possible values include: 'On', 'Off' + CloudTiering CloudTiering `json:"cloudTiering,omitempty"` + // VolumeFreeSpacePercent - Level of free space to be maintained by Cloud Tiering if it is enabled. + VolumeFreeSpacePercent *int32 `json:"volumeFreeSpacePercent,omitempty"` + // TierFilesOlderThanDays - Tier files older than days. + TierFilesOlderThanDays *int32 `json:"tierFilesOlderThanDays,omitempty"` + // FriendlyName - Friendly Name + FriendlyName *string `json:"friendlyName,omitempty"` + // ServerResourceID - Server Resource Id. + ServerResourceID *string `json:"serverResourceId,omitempty"` + // OfflineDataTransfer - Offline data transfer. Possible values include: 'OfflineDataTransferOn', 'OfflineDataTransferOff' + OfflineDataTransfer OfflineDataTransfer `json:"offlineDataTransfer,omitempty"` + // OfflineDataTransferShareName - Offline data transfer share name + OfflineDataTransferShareName *string `json:"offlineDataTransferShareName,omitempty"` +} + +// ServerEndpointFilesNotSyncingError files not syncing error object +type ServerEndpointFilesNotSyncingError struct { + // ErrorCode - READ-ONLY; Error code (HResult) + ErrorCode *int32 `json:"errorCode,omitempty"` + // PersistentCount - READ-ONLY; Count of persistent files not syncing with the specified error code + PersistentCount *int64 `json:"persistentCount,omitempty"` + // TransientCount - READ-ONLY; Count of transient files not syncing with the specified error code + TransientCount *int64 `json:"transientCount,omitempty"` +} + +// ServerEndpointProperties serverEndpoint Properties object. +type ServerEndpointProperties struct { + // ServerLocalPath - Server Local path. + ServerLocalPath *string `json:"serverLocalPath,omitempty"` + // CloudTiering - Cloud Tiering. Possible values include: 'CloudTiering2On', 'CloudTiering2Off' + CloudTiering CloudTiering2 `json:"cloudTiering,omitempty"` + // VolumeFreeSpacePercent - Level of free space to be maintained by Cloud Tiering if it is enabled. + VolumeFreeSpacePercent *int32 `json:"volumeFreeSpacePercent,omitempty"` + // TierFilesOlderThanDays - Tier files older than days. + TierFilesOlderThanDays *int32 `json:"tierFilesOlderThanDays,omitempty"` + // FriendlyName - Friendly Name + FriendlyName *string `json:"friendlyName,omitempty"` + // ServerResourceID - Server Resource Id. + ServerResourceID *string `json:"serverResourceId,omitempty"` + // ProvisioningState - READ-ONLY; ServerEndpoint Provisioning State + ProvisioningState *string `json:"provisioningState,omitempty"` + // LastWorkflowID - READ-ONLY; ServerEndpoint lastWorkflowId + LastWorkflowID *string `json:"lastWorkflowId,omitempty"` + // LastOperationName - READ-ONLY; Resource Last Operation Name + LastOperationName *string `json:"lastOperationName,omitempty"` + // SyncStatus - READ-ONLY; Server Endpoint sync status + SyncStatus *ServerEndpointSyncStatus `json:"syncStatus,omitempty"` + // OfflineDataTransfer - Offline data transfer. Possible values include: 'OfflineDataTransfer2On', 'OfflineDataTransfer2Off' + OfflineDataTransfer OfflineDataTransfer2 `json:"offlineDataTransfer,omitempty"` + // OfflineDataTransferStorageAccountResourceID - READ-ONLY; Offline data transfer storage account resource ID + OfflineDataTransferStorageAccountResourceID *string `json:"offlineDataTransferStorageAccountResourceId,omitempty"` + // OfflineDataTransferStorageAccountTenantID - READ-ONLY; Offline data transfer storage account tenant ID + OfflineDataTransferStorageAccountTenantID *string `json:"offlineDataTransferStorageAccountTenantId,omitempty"` + // OfflineDataTransferShareName - Offline data transfer share name + OfflineDataTransferShareName *string `json:"offlineDataTransferShareName,omitempty"` + // CloudTieringStatus - READ-ONLY; Cloud tiering status. Only populated if cloud tiering is enabled. + CloudTieringStatus *ServerEndpointCloudTieringStatus `json:"cloudTieringStatus,omitempty"` + // RecallStatus - READ-ONLY; Recall status. Only populated if cloud tiering is enabled. + RecallStatus *ServerEndpointRecallStatus `json:"recallStatus,omitempty"` +} + +// ServerEndpointRecallError server endpoint recall error object +type ServerEndpointRecallError struct { + // ErrorCode - READ-ONLY; Error code (HResult) + ErrorCode *int32 `json:"errorCode,omitempty"` + // Count - READ-ONLY; Count of occurences of the error + Count *int64 `json:"count,omitempty"` +} + +// ServerEndpointRecallStatus server endpoint recall status object. +type ServerEndpointRecallStatus struct { + // LastUpdatedTimestamp - READ-ONLY; Last updated timestamp + LastUpdatedTimestamp *date.Time `json:"lastUpdatedTimestamp,omitempty"` + // TotalRecallErrorsCount - READ-ONLY; Total count of recall errors. + TotalRecallErrorsCount *int64 `json:"totalRecallErrorsCount,omitempty"` + // RecallErrors - READ-ONLY; Array of recall errors + RecallErrors *[]ServerEndpointRecallError `json:"recallErrors,omitempty"` +} + +// ServerEndpointsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerEndpointsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServerEndpointsCreateFuture) Result(client ServerEndpointsClient) (se ServerEndpoint, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.ServerEndpointsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if se.Response.Response, err = future.GetResult(sender); err == nil && se.Response.Response.StatusCode != http.StatusNoContent { + se, err = client.CreateResponder(se.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsCreateFuture", "Result", se.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerEndpointsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerEndpointsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServerEndpointsDeleteFuture) Result(client ServerEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.ServerEndpointsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerEndpointsRecallActionFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerEndpointsRecallActionFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServerEndpointsRecallActionFuture) Result(client ServerEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsRecallActionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.ServerEndpointsRecallActionFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerEndpointsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerEndpointsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServerEndpointsUpdateFuture) Result(client ServerEndpointsClient) (se ServerEndpoint, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagesync.ServerEndpointsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if se.Response.Response, err = future.GetResult(sender); err == nil && se.Response.Response.StatusCode != http.StatusNoContent { + se, err = client.UpdateResponder(se.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsUpdateFuture", "Result", se.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerEndpointSyncActivityStatus sync Session status object. +type ServerEndpointSyncActivityStatus struct { + // Timestamp - READ-ONLY; Timestamp when properties were updated + Timestamp *date.Time `json:"timestamp,omitempty"` + // PerItemErrorCount - READ-ONLY; Per item error count + PerItemErrorCount *int64 `json:"perItemErrorCount,omitempty"` + // AppliedItemCount - READ-ONLY; Applied item count. + AppliedItemCount *int64 `json:"appliedItemCount,omitempty"` + // TotalItemCount - READ-ONLY; Total item count (if available) + TotalItemCount *int64 `json:"totalItemCount,omitempty"` + // AppliedBytes - READ-ONLY; Applied bytes + AppliedBytes *int64 `json:"appliedBytes,omitempty"` + // TotalBytes - READ-ONLY; Total bytes (if available) + TotalBytes *int64 `json:"totalBytes,omitempty"` +} + +// ServerEndpointSyncSessionStatus sync Session status object. +type ServerEndpointSyncSessionStatus struct { + // LastSyncResult - READ-ONLY; Last sync result (HResult) + LastSyncResult *int32 `json:"lastSyncResult,omitempty"` + // LastSyncTimestamp - READ-ONLY; Last sync timestamp + LastSyncTimestamp *date.Time `json:"lastSyncTimestamp,omitempty"` + // LastSyncSuccessTimestamp - READ-ONLY; Last sync success timestamp + LastSyncSuccessTimestamp *date.Time `json:"lastSyncSuccessTimestamp,omitempty"` + // LastSyncPerItemErrorCount - READ-ONLY; Last sync per item error count. + LastSyncPerItemErrorCount *int64 `json:"lastSyncPerItemErrorCount,omitempty"` + // PersistentFilesNotSyncingCount - READ-ONLY; Count of persistent files not syncing. + PersistentFilesNotSyncingCount *int64 `json:"persistentFilesNotSyncingCount,omitempty"` + // TransientFilesNotSyncingCount - READ-ONLY; Count of transient files not syncing. + TransientFilesNotSyncingCount *int64 `json:"transientFilesNotSyncingCount,omitempty"` + // FilesNotSyncingErrors - READ-ONLY; Array of per-item errors coming from the last sync session. + FilesNotSyncingErrors *[]ServerEndpointFilesNotSyncingError `json:"filesNotSyncingErrors,omitempty"` +} + +// ServerEndpointSyncStatus server Endpoint sync status +type ServerEndpointSyncStatus struct { + // DownloadHealth - READ-ONLY; Download Health Status. Possible values include: 'DownloadHealthHealthy', 'DownloadHealthError', 'DownloadHealthSyncBlockedForRestore', 'DownloadHealthSyncBlockedForChangeDetectionPostRestore', 'DownloadHealthNoActivity' + DownloadHealth DownloadHealth `json:"downloadHealth,omitempty"` + // UploadHealth - READ-ONLY; Upload Health Status. Possible values include: 'UploadHealthHealthy', 'UploadHealthError', 'UploadHealthSyncBlockedForRestore', 'UploadHealthSyncBlockedForChangeDetectionPostRestore', 'UploadHealthNoActivity' + UploadHealth UploadHealth `json:"uploadHealth,omitempty"` + // CombinedHealth - READ-ONLY; Combined Health Status. Possible values include: 'CombinedHealthHealthy', 'CombinedHealthError', 'CombinedHealthSyncBlockedForRestore', 'CombinedHealthSyncBlockedForChangeDetectionPostRestore', 'CombinedHealthNoActivity' + CombinedHealth CombinedHealth `json:"combinedHealth,omitempty"` + // SyncActivity - READ-ONLY; Sync activity. Possible values include: 'Upload', 'Download', 'UploadAndDownload' + SyncActivity SyncActivity `json:"syncActivity,omitempty"` + // TotalPersistentFilesNotSyncingCount - READ-ONLY; Total count of persistent files not syncing (combined upload + download). + TotalPersistentFilesNotSyncingCount *int64 `json:"totalPersistentFilesNotSyncingCount,omitempty"` + // LastUpdatedTimestamp - READ-ONLY; Last Updated Timestamp + LastUpdatedTimestamp *date.Time `json:"lastUpdatedTimestamp,omitempty"` + // UploadStatus - READ-ONLY; Upload Status + UploadStatus *ServerEndpointSyncSessionStatus `json:"uploadStatus,omitempty"` + // DownloadStatus - READ-ONLY; Download Status + DownloadStatus *ServerEndpointSyncSessionStatus `json:"downloadStatus,omitempty"` + // UploadActivity - READ-ONLY; Upload sync activity + UploadActivity *ServerEndpointSyncActivityStatus `json:"uploadActivity,omitempty"` + // DownloadActivity - READ-ONLY; Download sync activity + DownloadActivity *ServerEndpointSyncActivityStatus `json:"downloadActivity,omitempty"` + // OfflineDataTransferStatus - READ-ONLY; Offline Data Transfer State. Possible values include: 'InProgress', 'Stopping', 'NotRunning', 'Complete' + OfflineDataTransferStatus OfflineDataTransferStatus `json:"offlineDataTransferStatus,omitempty"` +} + +// ServerEndpointUpdateParameters parameters for updating an Server Endpoint. +type ServerEndpointUpdateParameters struct { + // ServerEndpointUpdateProperties - The properties of the server endpoint. + *ServerEndpointUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerEndpointUpdateParameters. +func (seup ServerEndpointUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if seup.ServerEndpointUpdateProperties != nil { + objectMap["properties"] = seup.ServerEndpointUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerEndpointUpdateParameters struct. +func (seup *ServerEndpointUpdateParameters) 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 serverEndpointUpdateProperties ServerEndpointUpdateProperties + err = json.Unmarshal(*v, &serverEndpointUpdateProperties) + if err != nil { + return err + } + seup.ServerEndpointUpdateProperties = &serverEndpointUpdateProperties + } + } + } + + return nil +} + +// ServerEndpointUpdateProperties serverEndpoint Update Properties object. +type ServerEndpointUpdateProperties struct { + // CloudTiering - Cloud Tiering. Possible values include: 'CloudTiering1On', 'CloudTiering1Off' + CloudTiering CloudTiering1 `json:"cloudTiering,omitempty"` + // VolumeFreeSpacePercent - Level of free space to be maintained by Cloud Tiering if it is enabled. + VolumeFreeSpacePercent *int32 `json:"volumeFreeSpacePercent,omitempty"` + // TierFilesOlderThanDays - Tier files older than days. + TierFilesOlderThanDays *int32 `json:"tierFilesOlderThanDays,omitempty"` + // OfflineDataTransfer - Offline data transfer. Possible values include: 'OfflineDataTransfer1On', 'OfflineDataTransfer1Off' + OfflineDataTransfer OfflineDataTransfer1 `json:"offlineDataTransfer,omitempty"` + // OfflineDataTransferShareName - Offline data transfer share name + OfflineDataTransferShareName *string `json:"offlineDataTransferShareName,omitempty"` +} + +// Service storage Sync Service object. +type Service struct { + autorest.Response `json:"-"` + // ServiceProperties - Storage Sync Service properties. + *ServiceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Service. +func (s Service) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.ServiceProperties != nil { + objectMap["properties"] = s.ServiceProperties + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + if s.Location != nil { + objectMap["location"] = s.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Service struct. +func (s *Service) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serviceProperties ServiceProperties + err = json.Unmarshal(*v, &serviceProperties) + if err != nil { + return err + } + s.ServiceProperties = &serviceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ServiceArray array of StorageSyncServices +type ServiceArray struct { + autorest.Response `json:"-"` + // Value - Collection of StorageSyncServices. + Value *[]Service `json:"value,omitempty"` +} + +// ServiceCreateParameters the parameters used when creating a storage sync service. +type ServiceCreateParameters struct { + // Location - Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource cannot be changed once it is created, but if an identical geo region is specified on update, the request will succeed. + Location *string `json:"location,omitempty"` + // Tags - Gets or sets a list of key value pairs that describe the resource. These tags can be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no greater than 128 characters and a value with a length no greater than 256 characters. + Tags map[string]*string `json:"tags"` + Properties interface{} `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceCreateParameters. +func (scp ServiceCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scp.Location != nil { + objectMap["location"] = scp.Location + } + if scp.Tags != nil { + objectMap["tags"] = scp.Tags + } + if scp.Properties != nil { + objectMap["properties"] = scp.Properties + } + return json.Marshal(objectMap) +} + +// ServiceProperties storage Sync Service Properties object. +type ServiceProperties struct { + // StorageSyncServiceStatus - READ-ONLY; Storage Sync service status. + StorageSyncServiceStatus *int32 `json:"storageSyncServiceStatus,omitempty"` + // StorageSyncServiceUID - READ-ONLY; Storage Sync service Uid + StorageSyncServiceUID *string `json:"storageSyncServiceUid,omitempty"` +} + +// ServiceUpdateParameters parameters for updating an Storage sync service. +type ServiceUpdateParameters struct { + // Tags - The user-specified tags associated with the storage sync service. + Tags map[string]*string `json:"tags"` + // Properties - The properties of the storage sync service. + Properties interface{} `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceUpdateParameters. +func (sup ServiceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sup.Tags != nil { + objectMap["tags"] = sup.Tags + } + if sup.Properties != nil { + objectMap["properties"] = sup.Properties + } + return json.Marshal(objectMap) +} + +// SubscriptionState subscription State object. +type SubscriptionState struct { + // State - State of Azure Subscription. Possible values include: 'Registered', 'Unregistered', 'Warned', 'Suspended', 'Deleted' + State Reason `json:"state,omitempty"` + // Istransitioning - READ-ONLY; Is Transitioning + Istransitioning *bool `json:"istransitioning,omitempty"` + // Properties - Subscription state properties. + Properties interface{} `json:"properties,omitempty"` +} + +// SyncGroup sync Group object. +type SyncGroup struct { + autorest.Response `json:"-"` + // SyncGroupProperties - SyncGroup properties. + *SyncGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroup. +func (sg SyncGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sg.SyncGroupProperties != nil { + objectMap["properties"] = sg.SyncGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncGroup struct. +func (sg *SyncGroup) 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 syncGroupProperties SyncGroupProperties + err = json.Unmarshal(*v, &syncGroupProperties) + if err != nil { + return err + } + sg.SyncGroupProperties = &syncGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sg.Type = &typeVar + } + } + } + + return nil +} + +// SyncGroupArray array of SyncGroup +type SyncGroupArray struct { + autorest.Response `json:"-"` + // Value - Collection of SyncGroup. + Value *[]SyncGroup `json:"value,omitempty"` +} + +// SyncGroupCreateParameters the parameters used when creating a sync group. +type SyncGroupCreateParameters struct { + // Properties - The parameters used to create the sync group + Properties interface{} `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// SyncGroupProperties syncGroup Properties object. +type SyncGroupProperties struct { + // UniqueID - READ-ONLY; Unique Id + UniqueID *string `json:"uniqueId,omitempty"` + // SyncGroupStatus - READ-ONLY; Sync group status + SyncGroupStatus *string `json:"syncGroupStatus,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// TriggerChangeDetectionParameters the parameters used when calling trigger change detection action on +// cloud endpoint. +type TriggerChangeDetectionParameters struct { + // DirectoryPath - Relative path to a directory Azure File share for which change detection is to be performed. + DirectoryPath *string `json:"directoryPath,omitempty"` + // ChangeDetectionMode - Change Detection Mode. Applies to a directory specified in directoryPath parameter. Possible values include: 'Default', 'Recursive' + ChangeDetectionMode ChangeDetectionMode `json:"changeDetectionMode,omitempty"` + // Paths - Array of relative paths on the Azure File share to be included in the change detection. Can be files and directories. + Paths *[]string `json:"paths,omitempty"` +} + +// TriggerRolloverRequest trigger Rollover Request. +type TriggerRolloverRequest struct { + // ServerCertificate - Certificate Data + ServerCertificate *string `json:"serverCertificate,omitempty"` +} + +// Workflow workflow resource. +type Workflow struct { + autorest.Response `json:"-"` + // WorkflowProperties - Workflow properties. + *WorkflowProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Workflow. +func (w Workflow) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if w.WorkflowProperties != nil { + objectMap["properties"] = w.WorkflowProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Workflow struct. +func (w *Workflow) 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 workflowProperties WorkflowProperties + err = json.Unmarshal(*v, &workflowProperties) + if err != nil { + return err + } + w.WorkflowProperties = &workflowProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + w.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + w.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + w.Type = &typeVar + } + } + } + + return nil +} + +// WorkflowArray array of Workflow +type WorkflowArray struct { + autorest.Response `json:"-"` + // Value - Collection of workflow items. + Value *[]Workflow `json:"value,omitempty"` +} + +// WorkflowProperties workflow Properties object. +type WorkflowProperties struct { + // LastStepName - last step name + LastStepName *string `json:"lastStepName,omitempty"` + // Status - workflow status. Possible values include: 'Active', 'Expired', 'Succeeded', 'Aborted', 'Failed' + Status Status `json:"status,omitempty"` + // Operation - operation direction. Possible values include: 'Do', 'Undo', 'Cancel' + Operation Operation `json:"operation,omitempty"` + // Steps - workflow steps + Steps *string `json:"steps,omitempty"` + // LastOperationID - workflow last operation identifier. + LastOperationID *string `json:"lastOperationId,omitempty"` +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/operations.go b/services/storagesync/mgmt/2019-06-01/storagesync/operations.go new file mode 100644 index 000000000000..7f640aaa0cc4 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/operations.go @@ -0,0 +1,148 @@ +package storagesync + +// 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/tracing" + "net/http" +) + +// OperationsClient is the microsoft Storage Sync Service API +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Storage Sync Rest API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationEntityListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.oelr.Response.Response != nil { + sc = result.oelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.oelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.oelr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.StorageSync/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationEntityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationEntityListResult) (result OperationEntityListResult, err error) { + req, err := lastResults.operationEntityListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagesync.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "storagesync.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationEntityListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/operationstatus.go b/services/storagesync/mgmt/2019-06-01/storagesync/operationstatus.go new file mode 100644 index 000000000000..545f2466f478 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/operationstatus.go @@ -0,0 +1,134 @@ +package storagesync + +// 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" +) + +// OperationStatusClient is the microsoft Storage Sync Service API +type OperationStatusClient struct { + BaseClient +} + +// NewOperationStatusClient creates an instance of the OperationStatusClient client. +func NewOperationStatusClient(subscriptionID string) OperationStatusClient { + return NewOperationStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationStatusClientWithBaseURI creates an instance of the OperationStatusClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationStatusClientWithBaseURI(baseURI string, subscriptionID string) OperationStatusClient { + return OperationStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get Operation status +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// locationName - the desired region to obtain information from. +// workflowID - workflow Id +// operationID - operation Id +func (client OperationStatusClient) Get(ctx context.Context, resourceGroupName string, locationName string, workflowID string, operationID string) (result OperationStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationStatusClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.OperationStatusClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, locationName, workflowID, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.OperationStatusClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.OperationStatusClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.OperationStatusClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client OperationStatusClient) GetPreparer(ctx context.Context, resourceGroupName string, locationName string, workflowID string, operationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workflowId": autorest.Encode("path", workflowID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/locations/{locationName}/workflows/{workflowId}/operations/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OperationStatusClient) 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 OperationStatusClient) GetResponder(resp *http.Response) (result OperationStatus, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/registeredservers.go b/services/storagesync/mgmt/2019-06-01/storagesync/registeredservers.go new file mode 100644 index 000000000000..ecf8de4d3c18 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/registeredservers.go @@ -0,0 +1,491 @@ +package storagesync + +// 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" +) + +// RegisteredServersClient is the microsoft Storage Sync Service API +type RegisteredServersClient struct { + BaseClient +} + +// NewRegisteredServersClient creates an instance of the RegisteredServersClient client. +func NewRegisteredServersClient(subscriptionID string) RegisteredServersClient { + return NewRegisteredServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRegisteredServersClientWithBaseURI creates an instance of the RegisteredServersClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewRegisteredServersClientWithBaseURI(baseURI string, subscriptionID string) RegisteredServersClient { + return RegisteredServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create add a new registered server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// serverID - GUID identifying the on-premises server. +// parameters - body of Registered Server object. +func (client RegisteredServersClient) Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string, parameters RegisteredServerCreateParameters) (result RegisteredServersCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredServersClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.RegisteredServersClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, storageSyncServiceName, serverID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client RegisteredServersClient) CreatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string, parameters RegisteredServerCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverId": autorest.Encode("path", serverID), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client RegisteredServersClient) CreateSender(req *http.Request) (future RegisteredServersCreateFuture, 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 +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client RegisteredServersClient) CreateResponder(resp *http.Response) (result RegisteredServer, 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 +} + +// Delete delete the given registered server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// serverID - GUID identifying the on-premises server. +func (client RegisteredServersClient) Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string) (result RegisteredServersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredServersClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.RegisteredServersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, storageSyncServiceName, serverID) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RegisteredServersClient) DeletePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverId": autorest.Encode("path", serverID), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}", 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 RegisteredServersClient) DeleteSender(req *http.Request) (future RegisteredServersDeleteFuture, 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 RegisteredServersClient) 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 get a given registered server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// serverID - GUID identifying the on-premises server. +func (client RegisteredServersClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string) (result RegisteredServer, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredServersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.RegisteredServersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName, serverID) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegisteredServersClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverId": autorest.Encode("path", serverID), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}", 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 RegisteredServersClient) 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 RegisteredServersClient) GetResponder(resp *http.Response) (result RegisteredServer, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByStorageSyncService get a given registered server list. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +func (client RegisteredServersClient) ListByStorageSyncService(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result RegisteredServerArray, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredServersClient.ListByStorageSyncService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.RegisteredServersClient", "ListByStorageSyncService", err.Error()) + } + + req, err := client.ListByStorageSyncServicePreparer(ctx, resourceGroupName, storageSyncServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "ListByStorageSyncService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByStorageSyncServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "ListByStorageSyncService", resp, "Failure sending request") + return + } + + result, err = client.ListByStorageSyncServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "ListByStorageSyncService", resp, "Failure responding to request") + } + + return +} + +// ListByStorageSyncServicePreparer prepares the ListByStorageSyncService request. +func (client RegisteredServersClient) ListByStorageSyncServicePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByStorageSyncServiceSender sends the ListByStorageSyncService request. The method will close the +// http.Response Body if it receives an error. +func (client RegisteredServersClient) ListByStorageSyncServiceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByStorageSyncServiceResponder handles the response to the ListByStorageSyncService request. The method always +// closes the http.Response Body. +func (client RegisteredServersClient) ListByStorageSyncServiceResponder(resp *http.Response) (result RegisteredServerArray, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// TriggerRollover triggers Server certificate rollover. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// serverID - server Id +// parameters - body of Trigger Rollover request. +func (client RegisteredServersClient) TriggerRollover(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string, parameters TriggerRolloverRequest) (result RegisteredServersTriggerRolloverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegisteredServersClient.TriggerRollover") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.RegisteredServersClient", "TriggerRollover", err.Error()) + } + + req, err := client.TriggerRolloverPreparer(ctx, resourceGroupName, storageSyncServiceName, serverID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "TriggerRollover", nil, "Failure preparing request") + return + } + + result, err = client.TriggerRolloverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.RegisteredServersClient", "TriggerRollover", result.Response(), "Failure sending request") + return + } + + return +} + +// TriggerRolloverPreparer prepares the TriggerRollover request. +func (client RegisteredServersClient) TriggerRolloverPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string, parameters TriggerRolloverRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverId": autorest.Encode("path", serverID), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/registeredServers/{serverId}/triggerRollover", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TriggerRolloverSender sends the TriggerRollover request. The method will close the +// http.Response Body if it receives an error. +func (client RegisteredServersClient) TriggerRolloverSender(req *http.Request) (future RegisteredServersTriggerRolloverFuture, 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 +} + +// TriggerRolloverResponder handles the response to the TriggerRollover request. The method always +// closes the http.Response Body. +func (client RegisteredServersClient) TriggerRolloverResponder(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 +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/serverendpoints.go b/services/storagesync/mgmt/2019-06-01/storagesync/serverendpoints.go new file mode 100644 index 000000000000..a4637c727dfa --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/serverendpoints.go @@ -0,0 +1,608 @@ +package storagesync + +// 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" +) + +// ServerEndpointsClient is the microsoft Storage Sync Service API +type ServerEndpointsClient struct { + BaseClient +} + +// NewServerEndpointsClient creates an instance of the ServerEndpointsClient client. +func NewServerEndpointsClient(subscriptionID string) ServerEndpointsClient { + return NewServerEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerEndpointsClientWithBaseURI creates an instance of the ServerEndpointsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerEndpointsClientWithBaseURI(baseURI string, subscriptionID string) ServerEndpointsClient { + return ServerEndpointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a new ServerEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// serverEndpointName - name of Server Endpoint object. +// parameters - body of Server Endpoint object. +func (client ServerEndpointsClient) Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters ServerEndpointCreateParameters) (result ServerEndpointsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServerEndpointCreateParametersProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerEndpointCreateParametersProperties.VolumeFreeSpacePercent", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerEndpointCreateParametersProperties.VolumeFreeSpacePercent", Name: validation.InclusiveMaximum, Rule: int64(100), Chain: nil}, + {Target: "parameters.ServerEndpointCreateParametersProperties.VolumeFreeSpacePercent", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + {Target: "parameters.ServerEndpointCreateParametersProperties.TierFilesOlderThanDays", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerEndpointCreateParametersProperties.TierFilesOlderThanDays", Name: validation.InclusiveMaximum, Rule: int64(2147483647), Chain: nil}, + {Target: "parameters.ServerEndpointCreateParametersProperties.TierFilesOlderThanDays", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("storagesync.ServerEndpointsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ServerEndpointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters ServerEndpointCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverEndpointName": autorest.Encode("path", serverEndpointName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ServerEndpointsClient) CreateSender(req *http.Request) (future ServerEndpointsCreateFuture, 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 +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ServerEndpointsClient) CreateResponder(resp *http.Response) (result ServerEndpoint, 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 +} + +// Delete delete a given ServerEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// serverEndpointName - name of Server Endpoint object. +func (client ServerEndpointsClient) Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (result ServerEndpointsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServerEndpointsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerEndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverEndpointName": autorest.Encode("path", serverEndpointName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}", 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 ServerEndpointsClient) DeleteSender(req *http.Request) (future ServerEndpointsDeleteFuture, 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 ServerEndpointsClient) DeleteResponder(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 +} + +// Get get a ServerEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// serverEndpointName - name of Server Endpoint object. +func (client ServerEndpointsClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (result ServerEndpoint, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServerEndpointsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerEndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverEndpointName": autorest.Encode("path", serverEndpointName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}", 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 ServerEndpointsClient) 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 ServerEndpointsClient) GetResponder(resp *http.Response) (result ServerEndpoint, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySyncGroup get a ServerEndpoint list. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +func (client ServerEndpointsClient) ListBySyncGroup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result ServerEndpointArray, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.ListBySyncGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServerEndpointsClient", "ListBySyncGroup", err.Error()) + } + + req, err := client.ListBySyncGroupPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "ListBySyncGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySyncGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "ListBySyncGroup", resp, "Failure sending request") + return + } + + result, err = client.ListBySyncGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "ListBySyncGroup", resp, "Failure responding to request") + } + + return +} + +// ListBySyncGroupPreparer prepares the ListBySyncGroup request. +func (client ServerEndpointsClient) ListBySyncGroupPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySyncGroupSender sends the ListBySyncGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServerEndpointsClient) ListBySyncGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListBySyncGroupResponder handles the response to the ListBySyncGroup request. The method always +// closes the http.Response Body. +func (client ServerEndpointsClient) ListBySyncGroupResponder(resp *http.Response) (result ServerEndpointArray, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RecallAction recall a server endpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// serverEndpointName - name of Server Endpoint object. +// parameters - body of Recall Action object. +func (client ServerEndpointsClient) RecallAction(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters RecallActionParameters) (result ServerEndpointsRecallActionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.RecallAction") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServerEndpointsClient", "RecallAction", err.Error()) + } + + req, err := client.RecallActionPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "RecallAction", nil, "Failure preparing request") + return + } + + result, err = client.RecallActionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "RecallAction", result.Response(), "Failure sending request") + return + } + + return +} + +// RecallActionPreparer prepares the RecallAction request. +func (client ServerEndpointsClient) RecallActionPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters RecallActionParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverEndpointName": autorest.Encode("path", serverEndpointName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}/recallAction", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RecallActionSender sends the RecallAction request. The method will close the +// http.Response Body if it receives an error. +func (client ServerEndpointsClient) RecallActionSender(req *http.Request) (future ServerEndpointsRecallActionFuture, 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 +} + +// RecallActionResponder handles the response to the RecallAction request. The method always +// closes the http.Response Body. +func (client ServerEndpointsClient) RecallActionResponder(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 +} + +// Update patch a given ServerEndpoint. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// serverEndpointName - name of Server Endpoint object. +// parameters - any of the properties applicable in PUT request. +func (client ServerEndpointsClient) Update(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters *ServerEndpointUpdateParameters) (result ServerEndpointsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerEndpointsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServerEndpointsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, serverEndpointName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServerEndpointsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServerEndpointsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters *ServerEndpointUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverEndpointName": autorest.Encode("path", serverEndpointName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}/serverEndpoints/{serverEndpointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServerEndpointsClient) UpdateSender(req *http.Request) (future ServerEndpointsUpdateFuture, 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 +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServerEndpointsClient) UpdateResponder(resp *http.Response) (result ServerEndpoint, 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 +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/services.go b/services/storagesync/mgmt/2019-06-01/storagesync/services.go new file mode 100644 index 000000000000..738c7599e845 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/services.go @@ -0,0 +1,651 @@ +package storagesync + +// 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" +) + +// ServicesClient is the microsoft Storage Sync Service API +type ServicesClient struct { + BaseClient +} + +// NewServicesClient creates an instance of the ServicesClient client. +func NewServicesClient(subscriptionID string) ServicesClient { + return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServicesClientWithBaseURI creates an instance of the ServicesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { + return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability check the give namespace name availability. +// Parameters: +// locationName - the desired region for the name check. +// parameters - parameters to check availability of the given namespace name +func (client ServicesClient) CheckNameAvailability(ctx context.Context, locationName string, parameters CheckNameAvailabilityParameters) (result CheckNameAvailabilityResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServicesClient", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, locationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "CheckNameAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client ServicesClient) CheckNameAvailabilityPreparer(ctx context.Context, locationName string, parameters CheckNameAvailabilityParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/checkNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client ServicesClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Create create a new StorageSyncService. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// parameters - storage Sync Service resource name. +func (client ServicesClient) Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters ServiceCreateParameters) (result Service, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServicesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, storageSyncServiceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ServicesClient) CreatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters ServiceCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) CreateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ServicesClient) CreateResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a given StorageSyncService. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServicesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, storageSyncServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}", 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 ServicesClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a given StorageSyncService. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +func (client ServicesClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result Service, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServicesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}", 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 ServicesClient) 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 ServicesClient) GetResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get a StorageSyncService list by Resource group name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServiceArray, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServicesClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ServiceArray, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription get a StorageSyncService list by subscription. +func (client ServicesClient) ListBySubscription(ctx context.Context) (result ServiceArray, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServicesClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ServicesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/storageSyncServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ServicesClient) ListBySubscriptionResponder(resp *http.Response) (result ServiceArray, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update patch a given StorageSyncService. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// parameters - storage Sync Service resource. +func (client ServicesClient) Update(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters *ServiceUpdateParameters) (result Service, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.ServicesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, storageSyncServiceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters *ServiceUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) UpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServicesClient) UpdateResponder(resp *http.Response) (result Service, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/storagesyncapi/interfaces.go b/services/storagesync/mgmt/2019-06-01/storagesync/storagesyncapi/interfaces.go new file mode 100644 index 000000000000..fc336c54ac10 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/storagesyncapi/interfaces.go @@ -0,0 +1,110 @@ +package storagesyncapi + +// 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/azure-sdk-for-go/services/storagesync/mgmt/2019-06-01/storagesync" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result storagesync.OperationEntityListResultPage, err error) + ListComplete(ctx context.Context) (result storagesync.OperationEntityListResultIterator, err error) +} + +var _ OperationsClientAPI = (*storagesync.OperationsClient)(nil) + +// ServicesClientAPI contains the set of methods on the ServicesClient type. +type ServicesClientAPI interface { + CheckNameAvailability(ctx context.Context, locationName string, parameters storagesync.CheckNameAvailabilityParameters) (result storagesync.CheckNameAvailabilityResult, err error) + Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters storagesync.ServiceCreateParameters) (result storagesync.Service, err error) + Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result storagesync.Service, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result storagesync.ServiceArray, err error) + ListBySubscription(ctx context.Context) (result storagesync.ServiceArray, err error) + Update(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters *storagesync.ServiceUpdateParameters) (result storagesync.Service, err error) +} + +var _ ServicesClientAPI = (*storagesync.ServicesClient)(nil) + +// SyncGroupsClientAPI contains the set of methods on the SyncGroupsClient type. +type SyncGroupsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, parameters storagesync.SyncGroupCreateParameters) (result storagesync.SyncGroup, err error) + Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result storagesync.SyncGroup, err error) + ListByStorageSyncService(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result storagesync.SyncGroupArray, err error) +} + +var _ SyncGroupsClientAPI = (*storagesync.SyncGroupsClient)(nil) + +// CloudEndpointsClientAPI contains the set of methods on the CloudEndpointsClient type. +type CloudEndpointsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters storagesync.CloudEndpointCreateParameters) (result storagesync.CloudEndpointsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (result storagesync.CloudEndpointsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (result storagesync.CloudEndpoint, err error) + ListBySyncGroup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result storagesync.CloudEndpointArray, err error) + PostBackup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters storagesync.BackupRequest) (result storagesync.CloudEndpointsPostBackupFuture, err error) + PostRestore(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters storagesync.PostRestoreRequest) (result storagesync.CloudEndpointsPostRestoreFuture, err error) + PreBackup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters storagesync.BackupRequest) (result storagesync.CloudEndpointsPreBackupFuture, err error) + PreRestore(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters storagesync.PreRestoreRequest) (result storagesync.CloudEndpointsPreRestoreFuture, err error) + Restoreheartbeat(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string) (result autorest.Response, err error) + TriggerChangeDetection(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, cloudEndpointName string, parameters storagesync.TriggerChangeDetectionParameters) (result storagesync.CloudEndpointsTriggerChangeDetectionFuture, err error) +} + +var _ CloudEndpointsClientAPI = (*storagesync.CloudEndpointsClient)(nil) + +// ServerEndpointsClientAPI contains the set of methods on the ServerEndpointsClient type. +type ServerEndpointsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters storagesync.ServerEndpointCreateParameters) (result storagesync.ServerEndpointsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (result storagesync.ServerEndpointsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string) (result storagesync.ServerEndpoint, err error) + ListBySyncGroup(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result storagesync.ServerEndpointArray, err error) + RecallAction(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters storagesync.RecallActionParameters) (result storagesync.ServerEndpointsRecallActionFuture, err error) + Update(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, serverEndpointName string, parameters *storagesync.ServerEndpointUpdateParameters) (result storagesync.ServerEndpointsUpdateFuture, err error) +} + +var _ ServerEndpointsClientAPI = (*storagesync.ServerEndpointsClient)(nil) + +// RegisteredServersClientAPI contains the set of methods on the RegisteredServersClient type. +type RegisteredServersClientAPI interface { + Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string, parameters storagesync.RegisteredServerCreateParameters) (result storagesync.RegisteredServersCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string) (result storagesync.RegisteredServersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string) (result storagesync.RegisteredServer, err error) + ListByStorageSyncService(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result storagesync.RegisteredServerArray, err error) + TriggerRollover(ctx context.Context, resourceGroupName string, storageSyncServiceName string, serverID string, parameters storagesync.TriggerRolloverRequest) (result storagesync.RegisteredServersTriggerRolloverFuture, err error) +} + +var _ RegisteredServersClientAPI = (*storagesync.RegisteredServersClient)(nil) + +// WorkflowsClientAPI contains the set of methods on the WorkflowsClient type. +type WorkflowsClientAPI interface { + Abort(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (result storagesync.Workflow, err error) + ListByStorageSyncService(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result storagesync.WorkflowArray, err error) +} + +var _ WorkflowsClientAPI = (*storagesync.WorkflowsClient)(nil) + +// OperationStatusClientAPI contains the set of methods on the OperationStatusClient type. +type OperationStatusClientAPI interface { + Get(ctx context.Context, resourceGroupName string, locationName string, workflowID string, operationID string) (result storagesync.OperationStatus, err error) +} + +var _ OperationStatusClientAPI = (*storagesync.OperationStatusClient)(nil) diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/syncgroups.go b/services/storagesync/mgmt/2019-06-01/storagesync/syncgroups.go new file mode 100644 index 000000000000..fdc9ea6c4d54 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/syncgroups.go @@ -0,0 +1,399 @@ +package storagesync + +// 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" +) + +// SyncGroupsClient is the microsoft Storage Sync Service API +type SyncGroupsClient struct { + BaseClient +} + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncGroupsClientWithBaseURI(baseURI string, subscriptionID string) SyncGroupsClient { + return SyncGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create a new SyncGroup. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +// parameters - sync Group Body +func (client SyncGroupsClient) Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, parameters SyncGroupCreateParameters) (result SyncGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.SyncGroupsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SyncGroupsClient) CreatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string, parameters SyncGroupCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) CreateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) CreateResponder(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 +} + +// Delete delete a given SyncGroup. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +func (client SyncGroupsClient) Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.SyncGroupsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SyncGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// 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.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a given SyncGroup. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// syncGroupName - name of Sync Group resource. +func (client SyncGroupsClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (result SyncGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.SyncGroupsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.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, "storagesync.SyncGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, syncGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups/{syncGroupName}", 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 SyncGroupsClient) 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 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 +} + +// ListByStorageSyncService get a SyncGroup List. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +func (client SyncGroupsClient) ListByStorageSyncService(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result SyncGroupArray, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListByStorageSyncService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.SyncGroupsClient", "ListByStorageSyncService", err.Error()) + } + + req, err := client.ListByStorageSyncServicePreparer(ctx, resourceGroupName, storageSyncServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "ListByStorageSyncService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByStorageSyncServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "ListByStorageSyncService", resp, "Failure sending request") + return + } + + result, err = client.ListByStorageSyncServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.SyncGroupsClient", "ListByStorageSyncService", resp, "Failure responding to request") + } + + return +} + +// ListByStorageSyncServicePreparer prepares the ListByStorageSyncService request. +func (client SyncGroupsClient) ListByStorageSyncServicePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/syncGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByStorageSyncServiceSender sends the ListByStorageSyncService request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListByStorageSyncServiceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByStorageSyncServiceResponder handles the response to the ListByStorageSyncService request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListByStorageSyncServiceResponder(resp *http.Response) (result SyncGroupArray, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/version.go b/services/storagesync/mgmt/2019-06-01/storagesync/version.go new file mode 100644 index 000000000000..ce1ea9628d39 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/version.go @@ -0,0 +1,30 @@ +package storagesync + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " storagesync/2019-06-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/storagesync/mgmt/2019-06-01/storagesync/workflows.go b/services/storagesync/mgmt/2019-06-01/storagesync/workflows.go new file mode 100644 index 000000000000..5890aaffc718 --- /dev/null +++ b/services/storagesync/mgmt/2019-06-01/storagesync/workflows.go @@ -0,0 +1,307 @@ +package storagesync + +// 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" +) + +// WorkflowsClient is the microsoft Storage Sync Service API +type WorkflowsClient struct { + BaseClient +} + +// NewWorkflowsClient creates an instance of the WorkflowsClient client. +func NewWorkflowsClient(subscriptionID string) WorkflowsClient { + return NewWorkflowsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkflowsClientWithBaseURI creates an instance of the WorkflowsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWorkflowsClientWithBaseURI(baseURI string, subscriptionID string) WorkflowsClient { + return WorkflowsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Abort abort the given workflow. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// workflowID - workflow Id +func (client WorkflowsClient) Abort(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkflowsClient.Abort") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.WorkflowsClient", "Abort", err.Error()) + } + + req, err := client.AbortPreparer(ctx, resourceGroupName, storageSyncServiceName, workflowID) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Abort", nil, "Failure preparing request") + return + } + + resp, err := client.AbortSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Abort", resp, "Failure sending request") + return + } + + result, err = client.AbortResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Abort", resp, "Failure responding to request") + } + + return +} + +// AbortPreparer prepares the Abort request. +func (client WorkflowsClient) AbortPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workflowId": autorest.Encode("path", workflowID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}/abort", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AbortSender sends the Abort request. The method will close the +// http.Response Body if it receives an error. +func (client WorkflowsClient) AbortSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// AbortResponder handles the response to the Abort request. The method always +// closes the http.Response Body. +func (client WorkflowsClient) AbortResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get Workflows resource +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +// workflowID - workflow Id +func (client WorkflowsClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (result Workflow, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkflowsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.WorkflowsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName, workflowID) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkflowsClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workflowId": autorest.Encode("path", workflowID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}", 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 WorkflowsClient) 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 WorkflowsClient) GetResponder(resp *http.Response) (result Workflow, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByStorageSyncService get a Workflow List +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// storageSyncServiceName - name of Storage Sync Service resource. +func (client WorkflowsClient) ListByStorageSyncService(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result WorkflowArray, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkflowsClient.ListByStorageSyncService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagesync.WorkflowsClient", "ListByStorageSyncService", err.Error()) + } + + req, err := client.ListByStorageSyncServicePreparer(ctx, resourceGroupName, storageSyncServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "ListByStorageSyncService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByStorageSyncServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "ListByStorageSyncService", resp, "Failure sending request") + return + } + + result, err = client.ListByStorageSyncServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "ListByStorageSyncService", resp, "Failure responding to request") + } + + return +} + +// ListByStorageSyncServicePreparer prepares the ListByStorageSyncService request. +func (client WorkflowsClient) ListByStorageSyncServicePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByStorageSyncServiceSender sends the ListByStorageSyncService request. The method will close the +// http.Response Body if it receives an error. +func (client WorkflowsClient) ListByStorageSyncServiceSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByStorageSyncServiceResponder handles the response to the ListByStorageSyncService request. The method always +// closes the http.Response Body. +func (client WorkflowsClient) ListByStorageSyncServiceResponder(resp *http.Response) (result WorkflowArray, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}