1package storagesync 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/validation" 25 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// WorkflowsClient is the microsoft Storage Sync Service API 30type WorkflowsClient struct { 31 BaseClient 32} 33 34// NewWorkflowsClient creates an instance of the WorkflowsClient client. 35func NewWorkflowsClient(subscriptionID string) WorkflowsClient { 36 return NewWorkflowsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewWorkflowsClientWithBaseURI creates an instance of the WorkflowsClient client using a custom endpoint. Use this 40// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 41func NewWorkflowsClientWithBaseURI(baseURI string, subscriptionID string) WorkflowsClient { 42 return WorkflowsClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// Abort abort the given workflow. 46// Parameters: 47// resourceGroupName - the name of the resource group. The name is case insensitive. 48// storageSyncServiceName - name of Storage Sync Service resource. 49// workflowID - workflow Id 50func (client WorkflowsClient) Abort(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (result autorest.Response, err error) { 51 if tracing.IsEnabled() { 52 ctx = tracing.StartSpan(ctx, fqdn+"/WorkflowsClient.Abort") 53 defer func() { 54 sc := -1 55 if result.Response != nil { 56 sc = result.Response.StatusCode 57 } 58 tracing.EndSpan(ctx, sc, err) 59 }() 60 } 61 if err := validation.Validate([]validation.Validation{ 62 {TargetValue: client.SubscriptionID, 63 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 64 {TargetValue: resourceGroupName, 65 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 66 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 67 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 68 return result, validation.NewError("storagesync.WorkflowsClient", "Abort", err.Error()) 69 } 70 71 req, err := client.AbortPreparer(ctx, resourceGroupName, storageSyncServiceName, workflowID) 72 if err != nil { 73 err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Abort", nil, "Failure preparing request") 74 return 75 } 76 77 resp, err := client.AbortSender(req) 78 if err != nil { 79 result.Response = resp 80 err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Abort", resp, "Failure sending request") 81 return 82 } 83 84 result, err = client.AbortResponder(resp) 85 if err != nil { 86 err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Abort", resp, "Failure responding to request") 87 } 88 89 return 90} 91 92// AbortPreparer prepares the Abort request. 93func (client WorkflowsClient) AbortPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (*http.Request, error) { 94 pathParameters := map[string]interface{}{ 95 "resourceGroupName": autorest.Encode("path", resourceGroupName), 96 "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), 97 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 98 "workflowId": autorest.Encode("path", workflowID), 99 } 100 101 const APIVersion = "2018-07-01" 102 queryParameters := map[string]interface{}{ 103 "api-version": APIVersion, 104 } 105 106 preparer := autorest.CreatePreparer( 107 autorest.AsPost(), 108 autorest.WithBaseURL(client.BaseURI), 109 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}/abort", pathParameters), 110 autorest.WithQueryParameters(queryParameters)) 111 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 112} 113 114// AbortSender sends the Abort request. The method will close the 115// http.Response Body if it receives an error. 116func (client WorkflowsClient) AbortSender(req *http.Request) (*http.Response, error) { 117 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 118} 119 120// AbortResponder handles the response to the Abort request. The method always 121// closes the http.Response Body. 122func (client WorkflowsClient) AbortResponder(resp *http.Response) (result autorest.Response, err error) { 123 err = autorest.Respond( 124 resp, 125 client.ByInspecting(), 126 azure.WithErrorUnlessStatusCode(http.StatusOK), 127 autorest.ByClosing()) 128 result.Response = resp 129 return 130} 131 132// Get get Workflows resource 133// Parameters: 134// resourceGroupName - the name of the resource group. The name is case insensitive. 135// storageSyncServiceName - name of Storage Sync Service resource. 136// workflowID - workflow Id 137func (client WorkflowsClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (result Workflow, err error) { 138 if tracing.IsEnabled() { 139 ctx = tracing.StartSpan(ctx, fqdn+"/WorkflowsClient.Get") 140 defer func() { 141 sc := -1 142 if result.Response.Response != nil { 143 sc = result.Response.Response.StatusCode 144 } 145 tracing.EndSpan(ctx, sc, err) 146 }() 147 } 148 if err := validation.Validate([]validation.Validation{ 149 {TargetValue: client.SubscriptionID, 150 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 151 {TargetValue: resourceGroupName, 152 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 153 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 154 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 155 return result, validation.NewError("storagesync.WorkflowsClient", "Get", err.Error()) 156 } 157 158 req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName, workflowID) 159 if err != nil { 160 err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Get", nil, "Failure preparing request") 161 return 162 } 163 164 resp, err := client.GetSender(req) 165 if err != nil { 166 result.Response = autorest.Response{Response: resp} 167 err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Get", resp, "Failure sending request") 168 return 169 } 170 171 result, err = client.GetResponder(resp) 172 if err != nil { 173 err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "Get", resp, "Failure responding to request") 174 } 175 176 return 177} 178 179// GetPreparer prepares the Get request. 180func (client WorkflowsClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, workflowID string) (*http.Request, error) { 181 pathParameters := map[string]interface{}{ 182 "resourceGroupName": autorest.Encode("path", resourceGroupName), 183 "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), 184 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 185 "workflowId": autorest.Encode("path", workflowID), 186 } 187 188 const APIVersion = "2018-07-01" 189 queryParameters := map[string]interface{}{ 190 "api-version": APIVersion, 191 } 192 193 preparer := autorest.CreatePreparer( 194 autorest.AsGet(), 195 autorest.WithBaseURL(client.BaseURI), 196 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows/{workflowId}", pathParameters), 197 autorest.WithQueryParameters(queryParameters)) 198 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 199} 200 201// GetSender sends the Get request. The method will close the 202// http.Response Body if it receives an error. 203func (client WorkflowsClient) GetSender(req *http.Request) (*http.Response, error) { 204 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 205} 206 207// GetResponder handles the response to the Get request. The method always 208// closes the http.Response Body. 209func (client WorkflowsClient) GetResponder(resp *http.Response) (result Workflow, err error) { 210 err = autorest.Respond( 211 resp, 212 client.ByInspecting(), 213 azure.WithErrorUnlessStatusCode(http.StatusOK), 214 autorest.ByUnmarshallingJSON(&result), 215 autorest.ByClosing()) 216 result.Response = autorest.Response{Response: resp} 217 return 218} 219 220// ListByStorageSyncService get a Workflow List 221// Parameters: 222// resourceGroupName - the name of the resource group. The name is case insensitive. 223// storageSyncServiceName - name of Storage Sync Service resource. 224func (client WorkflowsClient) ListByStorageSyncService(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result WorkflowArray, err error) { 225 if tracing.IsEnabled() { 226 ctx = tracing.StartSpan(ctx, fqdn+"/WorkflowsClient.ListByStorageSyncService") 227 defer func() { 228 sc := -1 229 if result.Response.Response != nil { 230 sc = result.Response.Response.StatusCode 231 } 232 tracing.EndSpan(ctx, sc, err) 233 }() 234 } 235 if err := validation.Validate([]validation.Validation{ 236 {TargetValue: client.SubscriptionID, 237 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 238 {TargetValue: resourceGroupName, 239 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 240 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 241 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 242 return result, validation.NewError("storagesync.WorkflowsClient", "ListByStorageSyncService", err.Error()) 243 } 244 245 req, err := client.ListByStorageSyncServicePreparer(ctx, resourceGroupName, storageSyncServiceName) 246 if err != nil { 247 err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "ListByStorageSyncService", nil, "Failure preparing request") 248 return 249 } 250 251 resp, err := client.ListByStorageSyncServiceSender(req) 252 if err != nil { 253 result.Response = autorest.Response{Response: resp} 254 err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "ListByStorageSyncService", resp, "Failure sending request") 255 return 256 } 257 258 result, err = client.ListByStorageSyncServiceResponder(resp) 259 if err != nil { 260 err = autorest.NewErrorWithError(err, "storagesync.WorkflowsClient", "ListByStorageSyncService", resp, "Failure responding to request") 261 } 262 263 return 264} 265 266// ListByStorageSyncServicePreparer prepares the ListByStorageSyncService request. 267func (client WorkflowsClient) ListByStorageSyncServicePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (*http.Request, error) { 268 pathParameters := map[string]interface{}{ 269 "resourceGroupName": autorest.Encode("path", resourceGroupName), 270 "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), 271 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 272 } 273 274 const APIVersion = "2018-07-01" 275 queryParameters := map[string]interface{}{ 276 "api-version": APIVersion, 277 } 278 279 preparer := autorest.CreatePreparer( 280 autorest.AsGet(), 281 autorest.WithBaseURL(client.BaseURI), 282 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}/workflows", pathParameters), 283 autorest.WithQueryParameters(queryParameters)) 284 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 285} 286 287// ListByStorageSyncServiceSender sends the ListByStorageSyncService request. The method will close the 288// http.Response Body if it receives an error. 289func (client WorkflowsClient) ListByStorageSyncServiceSender(req *http.Request) (*http.Response, error) { 290 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 291} 292 293// ListByStorageSyncServiceResponder handles the response to the ListByStorageSyncService request. The method always 294// closes the http.Response Body. 295func (client WorkflowsClient) ListByStorageSyncServiceResponder(resp *http.Response) (result WorkflowArray, err error) { 296 err = autorest.Respond( 297 resp, 298 client.ByInspecting(), 299 azure.WithErrorUnlessStatusCode(http.StatusOK), 300 autorest.ByUnmarshallingJSON(&result), 301 autorest.ByClosing()) 302 result.Response = autorest.Response{Response: resp} 303 return 304} 305