...

Source file src/github.com/Azure/azure-sdk-for-go/services/storsimple1200series/mgmt/2016-10-01/storsimple/backupschedulegroups.go

Documentation: github.com/Azure/azure-sdk-for-go/services/storsimple1200series/mgmt/2016-10-01/storsimple

     1  package storsimple
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // BackupScheduleGroupsClient is the client for the BackupScheduleGroups methods of the Storsimple service.
    19  type BackupScheduleGroupsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewBackupScheduleGroupsClient creates an instance of the BackupScheduleGroupsClient client.
    24  func NewBackupScheduleGroupsClient(subscriptionID string) BackupScheduleGroupsClient {
    25  	return NewBackupScheduleGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewBackupScheduleGroupsClientWithBaseURI creates an instance of the BackupScheduleGroupsClient client using a custom
    29  // endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
    30  // stack).
    31  func NewBackupScheduleGroupsClientWithBaseURI(baseURI string, subscriptionID string) BackupScheduleGroupsClient {
    32  	return BackupScheduleGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateOrUpdate creates or Updates the backup schedule Group.
    36  // Parameters:
    37  // deviceName - the name of the device.
    38  // scheduleGroupName - the name of the schedule group.
    39  // scheduleGroup - the schedule group to be created
    40  // resourceGroupName - the resource group name
    41  // managerName - the manager name
    42  func (client BackupScheduleGroupsClient) CreateOrUpdate(ctx context.Context, deviceName string, scheduleGroupName string, scheduleGroup BackupScheduleGroup, resourceGroupName string, managerName string) (result BackupScheduleGroupsCreateOrUpdateFuture, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/BackupScheduleGroupsClient.CreateOrUpdate")
    45  		defer func() {
    46  			sc := -1
    47  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    48  				sc = result.FutureAPI.Response().StatusCode
    49  			}
    50  			tracing.EndSpan(ctx, sc, err)
    51  		}()
    52  	}
    53  	if err := validation.Validate([]validation.Validation{
    54  		{TargetValue: scheduleGroup,
    55  			Constraints: []validation.Constraint{{Target: "scheduleGroup.BackupScheduleGroupProperties", Name: validation.Null, Rule: true,
    56  				Chain: []validation.Constraint{{Target: "scheduleGroup.BackupScheduleGroupProperties.StartTime", Name: validation.Null, Rule: true,
    57  					Chain: []validation.Constraint{{Target: "scheduleGroup.BackupScheduleGroupProperties.StartTime.Hour", Name: validation.Null, Rule: true,
    58  						Chain: []validation.Constraint{{Target: "scheduleGroup.BackupScheduleGroupProperties.StartTime.Hour", Name: validation.InclusiveMaximum, Rule: int64(23), Chain: nil},
    59  							{Target: "scheduleGroup.BackupScheduleGroupProperties.StartTime.Hour", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
    60  						}},
    61  						{Target: "scheduleGroup.BackupScheduleGroupProperties.StartTime.Minute", Name: validation.Null, Rule: true,
    62  							Chain: []validation.Constraint{{Target: "scheduleGroup.BackupScheduleGroupProperties.StartTime.Minute", Name: validation.InclusiveMaximum, Rule: int64(59), Chain: nil},
    63  								{Target: "scheduleGroup.BackupScheduleGroupProperties.StartTime.Minute", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
    64  							}},
    65  					}},
    66  				}}}},
    67  		{TargetValue: managerName,
    68  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
    69  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
    70  		return result, validation.NewError("storsimple.BackupScheduleGroupsClient", "CreateOrUpdate", err.Error())
    71  	}
    72  
    73  	req, err := client.CreateOrUpdatePreparer(ctx, deviceName, scheduleGroupName, scheduleGroup, resourceGroupName, managerName)
    74  	if err != nil {
    75  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
    76  		return
    77  	}
    78  
    79  	result, err = client.CreateOrUpdateSender(req)
    80  	if err != nil {
    81  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    82  		return
    83  	}
    84  
    85  	return
    86  }
    87  
    88  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    89  func (client BackupScheduleGroupsClient) CreateOrUpdatePreparer(ctx context.Context, deviceName string, scheduleGroupName string, scheduleGroup BackupScheduleGroup, resourceGroupName string, managerName string) (*http.Request, error) {
    90  	pathParameters := map[string]interface{}{
    91  		"deviceName":        autorest.Encode("path", deviceName),
    92  		"managerName":       autorest.Encode("path", managerName),
    93  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    94  		"scheduleGroupName": autorest.Encode("path", scheduleGroupName),
    95  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    96  	}
    97  
    98  	const APIVersion = "2016-10-01"
    99  	queryParameters := map[string]interface{}{
   100  		"api-version": APIVersion,
   101  	}
   102  
   103  	preparer := autorest.CreatePreparer(
   104  		autorest.AsContentType("application/json; charset=utf-8"),
   105  		autorest.AsPut(),
   106  		autorest.WithBaseURL(client.BaseURI),
   107  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupScheduleGroups/{scheduleGroupName}", pathParameters),
   108  		autorest.WithJSON(scheduleGroup),
   109  		autorest.WithQueryParameters(queryParameters))
   110  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   111  }
   112  
   113  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   114  // http.Response Body if it receives an error.
   115  func (client BackupScheduleGroupsClient) CreateOrUpdateSender(req *http.Request) (future BackupScheduleGroupsCreateOrUpdateFuture, err error) {
   116  	var resp *http.Response
   117  	future.FutureAPI = &azure.Future{}
   118  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   119  	if err != nil {
   120  		return
   121  	}
   122  	var azf azure.Future
   123  	azf, err = azure.NewFutureFromResponse(resp)
   124  	future.FutureAPI = &azf
   125  	future.Result = future.result
   126  	return
   127  }
   128  
   129  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   130  // closes the http.Response Body.
   131  func (client BackupScheduleGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result BackupScheduleGroup, err error) {
   132  	err = autorest.Respond(
   133  		resp,
   134  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   135  		autorest.ByUnmarshallingJSON(&result),
   136  		autorest.ByClosing())
   137  	result.Response = autorest.Response{Response: resp}
   138  	return
   139  }
   140  
   141  // Delete deletes the backup schedule group.
   142  // Parameters:
   143  // deviceName - the name of the device.
   144  // scheduleGroupName - the name of the schedule group.
   145  // resourceGroupName - the resource group name
   146  // managerName - the manager name
   147  func (client BackupScheduleGroupsClient) Delete(ctx context.Context, deviceName string, scheduleGroupName string, resourceGroupName string, managerName string) (result BackupScheduleGroupsDeleteFuture, err error) {
   148  	if tracing.IsEnabled() {
   149  		ctx = tracing.StartSpan(ctx, fqdn+"/BackupScheduleGroupsClient.Delete")
   150  		defer func() {
   151  			sc := -1
   152  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   153  				sc = result.FutureAPI.Response().StatusCode
   154  			}
   155  			tracing.EndSpan(ctx, sc, err)
   156  		}()
   157  	}
   158  	if err := validation.Validate([]validation.Validation{
   159  		{TargetValue: managerName,
   160  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   161  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   162  		return result, validation.NewError("storsimple.BackupScheduleGroupsClient", "Delete", err.Error())
   163  	}
   164  
   165  	req, err := client.DeletePreparer(ctx, deviceName, scheduleGroupName, resourceGroupName, managerName)
   166  	if err != nil {
   167  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "Delete", nil, "Failure preparing request")
   168  		return
   169  	}
   170  
   171  	result, err = client.DeleteSender(req)
   172  	if err != nil {
   173  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "Delete", result.Response(), "Failure sending request")
   174  		return
   175  	}
   176  
   177  	return
   178  }
   179  
   180  // DeletePreparer prepares the Delete request.
   181  func (client BackupScheduleGroupsClient) DeletePreparer(ctx context.Context, deviceName string, scheduleGroupName string, resourceGroupName string, managerName string) (*http.Request, error) {
   182  	pathParameters := map[string]interface{}{
   183  		"deviceName":        autorest.Encode("path", deviceName),
   184  		"managerName":       autorest.Encode("path", managerName),
   185  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   186  		"scheduleGroupName": autorest.Encode("path", scheduleGroupName),
   187  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   188  	}
   189  
   190  	const APIVersion = "2016-10-01"
   191  	queryParameters := map[string]interface{}{
   192  		"api-version": APIVersion,
   193  	}
   194  
   195  	preparer := autorest.CreatePreparer(
   196  		autorest.AsDelete(),
   197  		autorest.WithBaseURL(client.BaseURI),
   198  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupScheduleGroups/{scheduleGroupName}", pathParameters),
   199  		autorest.WithQueryParameters(queryParameters))
   200  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   201  }
   202  
   203  // DeleteSender sends the Delete request. The method will close the
   204  // http.Response Body if it receives an error.
   205  func (client BackupScheduleGroupsClient) DeleteSender(req *http.Request) (future BackupScheduleGroupsDeleteFuture, err error) {
   206  	var resp *http.Response
   207  	future.FutureAPI = &azure.Future{}
   208  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   209  	if err != nil {
   210  		return
   211  	}
   212  	var azf azure.Future
   213  	azf, err = azure.NewFutureFromResponse(resp)
   214  	future.FutureAPI = &azf
   215  	future.Result = future.result
   216  	return
   217  }
   218  
   219  // DeleteResponder handles the response to the Delete request. The method always
   220  // closes the http.Response Body.
   221  func (client BackupScheduleGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   222  	err = autorest.Respond(
   223  		resp,
   224  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   225  		autorest.ByClosing())
   226  	result.Response = resp
   227  	return
   228  }
   229  
   230  // Get returns the properties of the specified backup schedule group name.
   231  // Parameters:
   232  // deviceName - the name of the device.
   233  // scheduleGroupName - the name of the schedule group.
   234  // resourceGroupName - the resource group name
   235  // managerName - the manager name
   236  func (client BackupScheduleGroupsClient) Get(ctx context.Context, deviceName string, scheduleGroupName string, resourceGroupName string, managerName string) (result BackupScheduleGroup, err error) {
   237  	if tracing.IsEnabled() {
   238  		ctx = tracing.StartSpan(ctx, fqdn+"/BackupScheduleGroupsClient.Get")
   239  		defer func() {
   240  			sc := -1
   241  			if result.Response.Response != nil {
   242  				sc = result.Response.Response.StatusCode
   243  			}
   244  			tracing.EndSpan(ctx, sc, err)
   245  		}()
   246  	}
   247  	if err := validation.Validate([]validation.Validation{
   248  		{TargetValue: managerName,
   249  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   250  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   251  		return result, validation.NewError("storsimple.BackupScheduleGroupsClient", "Get", err.Error())
   252  	}
   253  
   254  	req, err := client.GetPreparer(ctx, deviceName, scheduleGroupName, resourceGroupName, managerName)
   255  	if err != nil {
   256  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "Get", nil, "Failure preparing request")
   257  		return
   258  	}
   259  
   260  	resp, err := client.GetSender(req)
   261  	if err != nil {
   262  		result.Response = autorest.Response{Response: resp}
   263  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "Get", resp, "Failure sending request")
   264  		return
   265  	}
   266  
   267  	result, err = client.GetResponder(resp)
   268  	if err != nil {
   269  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "Get", resp, "Failure responding to request")
   270  		return
   271  	}
   272  
   273  	return
   274  }
   275  
   276  // GetPreparer prepares the Get request.
   277  func (client BackupScheduleGroupsClient) GetPreparer(ctx context.Context, deviceName string, scheduleGroupName string, resourceGroupName string, managerName string) (*http.Request, error) {
   278  	pathParameters := map[string]interface{}{
   279  		"deviceName":        autorest.Encode("path", deviceName),
   280  		"managerName":       autorest.Encode("path", managerName),
   281  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   282  		"scheduleGroupName": autorest.Encode("path", scheduleGroupName),
   283  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   284  	}
   285  
   286  	const APIVersion = "2016-10-01"
   287  	queryParameters := map[string]interface{}{
   288  		"api-version": APIVersion,
   289  	}
   290  
   291  	preparer := autorest.CreatePreparer(
   292  		autorest.AsGet(),
   293  		autorest.WithBaseURL(client.BaseURI),
   294  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupScheduleGroups/{scheduleGroupName}", pathParameters),
   295  		autorest.WithQueryParameters(queryParameters))
   296  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   297  }
   298  
   299  // GetSender sends the Get request. The method will close the
   300  // http.Response Body if it receives an error.
   301  func (client BackupScheduleGroupsClient) GetSender(req *http.Request) (*http.Response, error) {
   302  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   303  }
   304  
   305  // GetResponder handles the response to the Get request. The method always
   306  // closes the http.Response Body.
   307  func (client BackupScheduleGroupsClient) GetResponder(resp *http.Response) (result BackupScheduleGroup, err error) {
   308  	err = autorest.Respond(
   309  		resp,
   310  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   311  		autorest.ByUnmarshallingJSON(&result),
   312  		autorest.ByClosing())
   313  	result.Response = autorest.Response{Response: resp}
   314  	return
   315  }
   316  
   317  // ListByDevice retrieves all the backup schedule groups in a device.
   318  // Parameters:
   319  // deviceName - the name of the device.
   320  // resourceGroupName - the resource group name
   321  // managerName - the manager name
   322  func (client BackupScheduleGroupsClient) ListByDevice(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result BackupScheduleGroupList, err error) {
   323  	if tracing.IsEnabled() {
   324  		ctx = tracing.StartSpan(ctx, fqdn+"/BackupScheduleGroupsClient.ListByDevice")
   325  		defer func() {
   326  			sc := -1
   327  			if result.Response.Response != nil {
   328  				sc = result.Response.Response.StatusCode
   329  			}
   330  			tracing.EndSpan(ctx, sc, err)
   331  		}()
   332  	}
   333  	if err := validation.Validate([]validation.Validation{
   334  		{TargetValue: managerName,
   335  			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
   336  				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
   337  		return result, validation.NewError("storsimple.BackupScheduleGroupsClient", "ListByDevice", err.Error())
   338  	}
   339  
   340  	req, err := client.ListByDevicePreparer(ctx, deviceName, resourceGroupName, managerName)
   341  	if err != nil {
   342  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "ListByDevice", nil, "Failure preparing request")
   343  		return
   344  	}
   345  
   346  	resp, err := client.ListByDeviceSender(req)
   347  	if err != nil {
   348  		result.Response = autorest.Response{Response: resp}
   349  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "ListByDevice", resp, "Failure sending request")
   350  		return
   351  	}
   352  
   353  	result, err = client.ListByDeviceResponder(resp)
   354  	if err != nil {
   355  		err = autorest.NewErrorWithError(err, "storsimple.BackupScheduleGroupsClient", "ListByDevice", resp, "Failure responding to request")
   356  		return
   357  	}
   358  
   359  	return
   360  }
   361  
   362  // ListByDevicePreparer prepares the ListByDevice request.
   363  func (client BackupScheduleGroupsClient) ListByDevicePreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
   364  	pathParameters := map[string]interface{}{
   365  		"deviceName":        autorest.Encode("path", deviceName),
   366  		"managerName":       autorest.Encode("path", managerName),
   367  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   368  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   369  	}
   370  
   371  	const APIVersion = "2016-10-01"
   372  	queryParameters := map[string]interface{}{
   373  		"api-version": APIVersion,
   374  	}
   375  
   376  	preparer := autorest.CreatePreparer(
   377  		autorest.AsGet(),
   378  		autorest.WithBaseURL(client.BaseURI),
   379  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupScheduleGroups", pathParameters),
   380  		autorest.WithQueryParameters(queryParameters))
   381  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   382  }
   383  
   384  // ListByDeviceSender sends the ListByDevice request. The method will close the
   385  // http.Response Body if it receives an error.
   386  func (client BackupScheduleGroupsClient) ListByDeviceSender(req *http.Request) (*http.Response, error) {
   387  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   388  }
   389  
   390  // ListByDeviceResponder handles the response to the ListByDevice request. The method always
   391  // closes the http.Response Body.
   392  func (client BackupScheduleGroupsClient) ListByDeviceResponder(resp *http.Response) (result BackupScheduleGroupList, err error) {
   393  	err = autorest.Respond(
   394  		resp,
   395  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   396  		autorest.ByUnmarshallingJSON(&result),
   397  		autorest.ByClosing())
   398  	result.Response = autorest.Response{Response: resp}
   399  	return
   400  }
   401  

View as plain text