1package 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
9import (
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// DeviceSettingsClient is the client for the DeviceSettings methods of the Storsimple service.
19type DeviceSettingsClient struct {
20	BaseClient
21}
22
23// NewDeviceSettingsClient creates an instance of the DeviceSettingsClient client.
24func NewDeviceSettingsClient(subscriptionID string) DeviceSettingsClient {
25	return NewDeviceSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewDeviceSettingsClientWithBaseURI creates an instance of the DeviceSettingsClient client using a custom endpoint.
29// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewDeviceSettingsClientWithBaseURI(baseURI string, subscriptionID string) DeviceSettingsClient {
31	return DeviceSettingsClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CreateOrUpdateAlertSettings creates or updates the alert settings of the specified device.
35// Parameters:
36// deviceName - the device name
37// parameters - the alert settings to be added or updated.
38// resourceGroupName - the resource group name
39// managerName - the manager name
40func (client DeviceSettingsClient) CreateOrUpdateAlertSettings(ctx context.Context, deviceName string, parameters AlertSettings, resourceGroupName string, managerName string) (result DeviceSettingsCreateOrUpdateAlertSettingsFuture, err error) {
41	if tracing.IsEnabled() {
42		ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSettingsClient.CreateOrUpdateAlertSettings")
43		defer func() {
44			sc := -1
45			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
46				sc = result.FutureAPI.Response().StatusCode
47			}
48			tracing.EndSpan(ctx, sc, err)
49		}()
50	}
51	if err := validation.Validate([]validation.Validation{
52		{TargetValue: parameters,
53			Constraints: []validation.Constraint{{Target: "parameters.AlertNotificationProperties", Name: validation.Null, Rule: true, Chain: nil}}},
54		{TargetValue: managerName,
55			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
56				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
57		return result, validation.NewError("storsimple.DeviceSettingsClient", "CreateOrUpdateAlertSettings", err.Error())
58	}
59
60	req, err := client.CreateOrUpdateAlertSettingsPreparer(ctx, deviceName, parameters, resourceGroupName, managerName)
61	if err != nil {
62		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "CreateOrUpdateAlertSettings", nil, "Failure preparing request")
63		return
64	}
65
66	result, err = client.CreateOrUpdateAlertSettingsSender(req)
67	if err != nil {
68		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "CreateOrUpdateAlertSettings", nil, "Failure sending request")
69		return
70	}
71
72	return
73}
74
75// CreateOrUpdateAlertSettingsPreparer prepares the CreateOrUpdateAlertSettings request.
76func (client DeviceSettingsClient) CreateOrUpdateAlertSettingsPreparer(ctx context.Context, deviceName string, parameters AlertSettings, resourceGroupName string, managerName string) (*http.Request, error) {
77	pathParameters := map[string]interface{}{
78		"deviceName":        deviceName,
79		"managerName":       managerName,
80		"resourceGroupName": resourceGroupName,
81		"subscriptionId":    client.SubscriptionID,
82	}
83
84	const APIVersion = "2017-06-01"
85	queryParameters := map[string]interface{}{
86		"api-version": APIVersion,
87	}
88
89	preparer := autorest.CreatePreparer(
90		autorest.AsContentType("application/json; charset=utf-8"),
91		autorest.AsPut(),
92		autorest.WithBaseURL(client.BaseURI),
93		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/alertSettings/default", pathParameters),
94		autorest.WithJSON(parameters),
95		autorest.WithQueryParameters(queryParameters))
96	return preparer.Prepare((&http.Request{}).WithContext(ctx))
97}
98
99// CreateOrUpdateAlertSettingsSender sends the CreateOrUpdateAlertSettings request. The method will close the
100// http.Response Body if it receives an error.
101func (client DeviceSettingsClient) CreateOrUpdateAlertSettingsSender(req *http.Request) (future DeviceSettingsCreateOrUpdateAlertSettingsFuture, err error) {
102	var resp *http.Response
103	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
104	if err != nil {
105		return
106	}
107	var azf azure.Future
108	azf, err = azure.NewFutureFromResponse(resp)
109	future.FutureAPI = &azf
110	future.Result = future.result
111	return
112}
113
114// CreateOrUpdateAlertSettingsResponder handles the response to the CreateOrUpdateAlertSettings request. The method always
115// closes the http.Response Body.
116func (client DeviceSettingsClient) CreateOrUpdateAlertSettingsResponder(resp *http.Response) (result AlertSettings, err error) {
117	err = autorest.Respond(
118		resp,
119		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
120		autorest.ByUnmarshallingJSON(&result),
121		autorest.ByClosing())
122	result.Response = autorest.Response{Response: resp}
123	return
124}
125
126// CreateOrUpdateTimeSettings creates or updates the time settings of the specified device.
127// Parameters:
128// deviceName - the device name
129// parameters - the time settings to be added or updated.
130// resourceGroupName - the resource group name
131// managerName - the manager name
132func (client DeviceSettingsClient) CreateOrUpdateTimeSettings(ctx context.Context, deviceName string, parameters TimeSettings, resourceGroupName string, managerName string) (result DeviceSettingsCreateOrUpdateTimeSettingsFuture, err error) {
133	if tracing.IsEnabled() {
134		ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSettingsClient.CreateOrUpdateTimeSettings")
135		defer func() {
136			sc := -1
137			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
138				sc = result.FutureAPI.Response().StatusCode
139			}
140			tracing.EndSpan(ctx, sc, err)
141		}()
142	}
143	if err := validation.Validate([]validation.Validation{
144		{TargetValue: parameters,
145			Constraints: []validation.Constraint{{Target: "parameters.TimeSettingsProperties", Name: validation.Null, Rule: true,
146				Chain: []validation.Constraint{{Target: "parameters.TimeSettingsProperties.TimeZone", Name: validation.Null, Rule: true, Chain: nil}}}}},
147		{TargetValue: managerName,
148			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
149				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
150		return result, validation.NewError("storsimple.DeviceSettingsClient", "CreateOrUpdateTimeSettings", err.Error())
151	}
152
153	req, err := client.CreateOrUpdateTimeSettingsPreparer(ctx, deviceName, parameters, resourceGroupName, managerName)
154	if err != nil {
155		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "CreateOrUpdateTimeSettings", nil, "Failure preparing request")
156		return
157	}
158
159	result, err = client.CreateOrUpdateTimeSettingsSender(req)
160	if err != nil {
161		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "CreateOrUpdateTimeSettings", nil, "Failure sending request")
162		return
163	}
164
165	return
166}
167
168// CreateOrUpdateTimeSettingsPreparer prepares the CreateOrUpdateTimeSettings request.
169func (client DeviceSettingsClient) CreateOrUpdateTimeSettingsPreparer(ctx context.Context, deviceName string, parameters TimeSettings, resourceGroupName string, managerName string) (*http.Request, error) {
170	pathParameters := map[string]interface{}{
171		"deviceName":        deviceName,
172		"managerName":       managerName,
173		"resourceGroupName": resourceGroupName,
174		"subscriptionId":    client.SubscriptionID,
175	}
176
177	const APIVersion = "2017-06-01"
178	queryParameters := map[string]interface{}{
179		"api-version": APIVersion,
180	}
181
182	preparer := autorest.CreatePreparer(
183		autorest.AsContentType("application/json; charset=utf-8"),
184		autorest.AsPut(),
185		autorest.WithBaseURL(client.BaseURI),
186		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/timeSettings/default", pathParameters),
187		autorest.WithJSON(parameters),
188		autorest.WithQueryParameters(queryParameters))
189	return preparer.Prepare((&http.Request{}).WithContext(ctx))
190}
191
192// CreateOrUpdateTimeSettingsSender sends the CreateOrUpdateTimeSettings request. The method will close the
193// http.Response Body if it receives an error.
194func (client DeviceSettingsClient) CreateOrUpdateTimeSettingsSender(req *http.Request) (future DeviceSettingsCreateOrUpdateTimeSettingsFuture, err error) {
195	var resp *http.Response
196	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
197	if err != nil {
198		return
199	}
200	var azf azure.Future
201	azf, err = azure.NewFutureFromResponse(resp)
202	future.FutureAPI = &azf
203	future.Result = future.result
204	return
205}
206
207// CreateOrUpdateTimeSettingsResponder handles the response to the CreateOrUpdateTimeSettings request. The method always
208// closes the http.Response Body.
209func (client DeviceSettingsClient) CreateOrUpdateTimeSettingsResponder(resp *http.Response) (result TimeSettings, err error) {
210	err = autorest.Respond(
211		resp,
212		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
213		autorest.ByUnmarshallingJSON(&result),
214		autorest.ByClosing())
215	result.Response = autorest.Response{Response: resp}
216	return
217}
218
219// GetAlertSettings gets the alert settings of the specified device.
220// Parameters:
221// deviceName - the device name
222// resourceGroupName - the resource group name
223// managerName - the manager name
224func (client DeviceSettingsClient) GetAlertSettings(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result AlertSettings, err error) {
225	if tracing.IsEnabled() {
226		ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSettingsClient.GetAlertSettings")
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: managerName,
237			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
238				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
239		return result, validation.NewError("storsimple.DeviceSettingsClient", "GetAlertSettings", err.Error())
240	}
241
242	req, err := client.GetAlertSettingsPreparer(ctx, deviceName, resourceGroupName, managerName)
243	if err != nil {
244		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetAlertSettings", nil, "Failure preparing request")
245		return
246	}
247
248	resp, err := client.GetAlertSettingsSender(req)
249	if err != nil {
250		result.Response = autorest.Response{Response: resp}
251		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetAlertSettings", resp, "Failure sending request")
252		return
253	}
254
255	result, err = client.GetAlertSettingsResponder(resp)
256	if err != nil {
257		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetAlertSettings", resp, "Failure responding to request")
258		return
259	}
260
261	return
262}
263
264// GetAlertSettingsPreparer prepares the GetAlertSettings request.
265func (client DeviceSettingsClient) GetAlertSettingsPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
266	pathParameters := map[string]interface{}{
267		"deviceName":        deviceName,
268		"managerName":       managerName,
269		"resourceGroupName": resourceGroupName,
270		"subscriptionId":    client.SubscriptionID,
271	}
272
273	const APIVersion = "2017-06-01"
274	queryParameters := map[string]interface{}{
275		"api-version": APIVersion,
276	}
277
278	preparer := autorest.CreatePreparer(
279		autorest.AsGet(),
280		autorest.WithBaseURL(client.BaseURI),
281		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/alertSettings/default", pathParameters),
282		autorest.WithQueryParameters(queryParameters))
283	return preparer.Prepare((&http.Request{}).WithContext(ctx))
284}
285
286// GetAlertSettingsSender sends the GetAlertSettings request. The method will close the
287// http.Response Body if it receives an error.
288func (client DeviceSettingsClient) GetAlertSettingsSender(req *http.Request) (*http.Response, error) {
289	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
290}
291
292// GetAlertSettingsResponder handles the response to the GetAlertSettings request. The method always
293// closes the http.Response Body.
294func (client DeviceSettingsClient) GetAlertSettingsResponder(resp *http.Response) (result AlertSettings, err error) {
295	err = autorest.Respond(
296		resp,
297		azure.WithErrorUnlessStatusCode(http.StatusOK),
298		autorest.ByUnmarshallingJSON(&result),
299		autorest.ByClosing())
300	result.Response = autorest.Response{Response: resp}
301	return
302}
303
304// GetNetworkSettings gets the network settings of the specified device.
305// Parameters:
306// deviceName - the device name
307// resourceGroupName - the resource group name
308// managerName - the manager name
309func (client DeviceSettingsClient) GetNetworkSettings(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result NetworkSettings, err error) {
310	if tracing.IsEnabled() {
311		ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSettingsClient.GetNetworkSettings")
312		defer func() {
313			sc := -1
314			if result.Response.Response != nil {
315				sc = result.Response.Response.StatusCode
316			}
317			tracing.EndSpan(ctx, sc, err)
318		}()
319	}
320	if err := validation.Validate([]validation.Validation{
321		{TargetValue: managerName,
322			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
323				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
324		return result, validation.NewError("storsimple.DeviceSettingsClient", "GetNetworkSettings", err.Error())
325	}
326
327	req, err := client.GetNetworkSettingsPreparer(ctx, deviceName, resourceGroupName, managerName)
328	if err != nil {
329		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetNetworkSettings", nil, "Failure preparing request")
330		return
331	}
332
333	resp, err := client.GetNetworkSettingsSender(req)
334	if err != nil {
335		result.Response = autorest.Response{Response: resp}
336		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetNetworkSettings", resp, "Failure sending request")
337		return
338	}
339
340	result, err = client.GetNetworkSettingsResponder(resp)
341	if err != nil {
342		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetNetworkSettings", resp, "Failure responding to request")
343		return
344	}
345
346	return
347}
348
349// GetNetworkSettingsPreparer prepares the GetNetworkSettings request.
350func (client DeviceSettingsClient) GetNetworkSettingsPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
351	pathParameters := map[string]interface{}{
352		"deviceName":        deviceName,
353		"managerName":       managerName,
354		"resourceGroupName": resourceGroupName,
355		"subscriptionId":    client.SubscriptionID,
356	}
357
358	const APIVersion = "2017-06-01"
359	queryParameters := map[string]interface{}{
360		"api-version": APIVersion,
361	}
362
363	preparer := autorest.CreatePreparer(
364		autorest.AsGet(),
365		autorest.WithBaseURL(client.BaseURI),
366		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/networkSettings/default", pathParameters),
367		autorest.WithQueryParameters(queryParameters))
368	return preparer.Prepare((&http.Request{}).WithContext(ctx))
369}
370
371// GetNetworkSettingsSender sends the GetNetworkSettings request. The method will close the
372// http.Response Body if it receives an error.
373func (client DeviceSettingsClient) GetNetworkSettingsSender(req *http.Request) (*http.Response, error) {
374	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
375}
376
377// GetNetworkSettingsResponder handles the response to the GetNetworkSettings request. The method always
378// closes the http.Response Body.
379func (client DeviceSettingsClient) GetNetworkSettingsResponder(resp *http.Response) (result NetworkSettings, err error) {
380	err = autorest.Respond(
381		resp,
382		azure.WithErrorUnlessStatusCode(http.StatusOK),
383		autorest.ByUnmarshallingJSON(&result),
384		autorest.ByClosing())
385	result.Response = autorest.Response{Response: resp}
386	return
387}
388
389// GetSecuritySettings returns the Security properties of the specified device name.
390// Parameters:
391// deviceName - the device name
392// resourceGroupName - the resource group name
393// managerName - the manager name
394func (client DeviceSettingsClient) GetSecuritySettings(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result SecuritySettings, err error) {
395	if tracing.IsEnabled() {
396		ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSettingsClient.GetSecuritySettings")
397		defer func() {
398			sc := -1
399			if result.Response.Response != nil {
400				sc = result.Response.Response.StatusCode
401			}
402			tracing.EndSpan(ctx, sc, err)
403		}()
404	}
405	if err := validation.Validate([]validation.Validation{
406		{TargetValue: managerName,
407			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
408				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
409		return result, validation.NewError("storsimple.DeviceSettingsClient", "GetSecuritySettings", err.Error())
410	}
411
412	req, err := client.GetSecuritySettingsPreparer(ctx, deviceName, resourceGroupName, managerName)
413	if err != nil {
414		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetSecuritySettings", nil, "Failure preparing request")
415		return
416	}
417
418	resp, err := client.GetSecuritySettingsSender(req)
419	if err != nil {
420		result.Response = autorest.Response{Response: resp}
421		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetSecuritySettings", resp, "Failure sending request")
422		return
423	}
424
425	result, err = client.GetSecuritySettingsResponder(resp)
426	if err != nil {
427		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetSecuritySettings", resp, "Failure responding to request")
428		return
429	}
430
431	return
432}
433
434// GetSecuritySettingsPreparer prepares the GetSecuritySettings request.
435func (client DeviceSettingsClient) GetSecuritySettingsPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
436	pathParameters := map[string]interface{}{
437		"deviceName":        deviceName,
438		"managerName":       managerName,
439		"resourceGroupName": resourceGroupName,
440		"subscriptionId":    client.SubscriptionID,
441	}
442
443	const APIVersion = "2017-06-01"
444	queryParameters := map[string]interface{}{
445		"api-version": APIVersion,
446	}
447
448	preparer := autorest.CreatePreparer(
449		autorest.AsGet(),
450		autorest.WithBaseURL(client.BaseURI),
451		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default", pathParameters),
452		autorest.WithQueryParameters(queryParameters))
453	return preparer.Prepare((&http.Request{}).WithContext(ctx))
454}
455
456// GetSecuritySettingsSender sends the GetSecuritySettings request. The method will close the
457// http.Response Body if it receives an error.
458func (client DeviceSettingsClient) GetSecuritySettingsSender(req *http.Request) (*http.Response, error) {
459	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
460}
461
462// GetSecuritySettingsResponder handles the response to the GetSecuritySettings request. The method always
463// closes the http.Response Body.
464func (client DeviceSettingsClient) GetSecuritySettingsResponder(resp *http.Response) (result SecuritySettings, err error) {
465	err = autorest.Respond(
466		resp,
467		azure.WithErrorUnlessStatusCode(http.StatusOK),
468		autorest.ByUnmarshallingJSON(&result),
469		autorest.ByClosing())
470	result.Response = autorest.Response{Response: resp}
471	return
472}
473
474// GetTimeSettings gets the time settings of the specified device.
475// Parameters:
476// deviceName - the device name
477// resourceGroupName - the resource group name
478// managerName - the manager name
479func (client DeviceSettingsClient) GetTimeSettings(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result TimeSettings, err error) {
480	if tracing.IsEnabled() {
481		ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSettingsClient.GetTimeSettings")
482		defer func() {
483			sc := -1
484			if result.Response.Response != nil {
485				sc = result.Response.Response.StatusCode
486			}
487			tracing.EndSpan(ctx, sc, err)
488		}()
489	}
490	if err := validation.Validate([]validation.Validation{
491		{TargetValue: managerName,
492			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
493				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
494		return result, validation.NewError("storsimple.DeviceSettingsClient", "GetTimeSettings", err.Error())
495	}
496
497	req, err := client.GetTimeSettingsPreparer(ctx, deviceName, resourceGroupName, managerName)
498	if err != nil {
499		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetTimeSettings", nil, "Failure preparing request")
500		return
501	}
502
503	resp, err := client.GetTimeSettingsSender(req)
504	if err != nil {
505		result.Response = autorest.Response{Response: resp}
506		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetTimeSettings", resp, "Failure sending request")
507		return
508	}
509
510	result, err = client.GetTimeSettingsResponder(resp)
511	if err != nil {
512		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "GetTimeSettings", resp, "Failure responding to request")
513		return
514	}
515
516	return
517}
518
519// GetTimeSettingsPreparer prepares the GetTimeSettings request.
520func (client DeviceSettingsClient) GetTimeSettingsPreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
521	pathParameters := map[string]interface{}{
522		"deviceName":        deviceName,
523		"managerName":       managerName,
524		"resourceGroupName": resourceGroupName,
525		"subscriptionId":    client.SubscriptionID,
526	}
527
528	const APIVersion = "2017-06-01"
529	queryParameters := map[string]interface{}{
530		"api-version": APIVersion,
531	}
532
533	preparer := autorest.CreatePreparer(
534		autorest.AsGet(),
535		autorest.WithBaseURL(client.BaseURI),
536		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/timeSettings/default", pathParameters),
537		autorest.WithQueryParameters(queryParameters))
538	return preparer.Prepare((&http.Request{}).WithContext(ctx))
539}
540
541// GetTimeSettingsSender sends the GetTimeSettings request. The method will close the
542// http.Response Body if it receives an error.
543func (client DeviceSettingsClient) GetTimeSettingsSender(req *http.Request) (*http.Response, error) {
544	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
545}
546
547// GetTimeSettingsResponder handles the response to the GetTimeSettings request. The method always
548// closes the http.Response Body.
549func (client DeviceSettingsClient) GetTimeSettingsResponder(resp *http.Response) (result TimeSettings, err error) {
550	err = autorest.Respond(
551		resp,
552		azure.WithErrorUnlessStatusCode(http.StatusOK),
553		autorest.ByUnmarshallingJSON(&result),
554		autorest.ByClosing())
555	result.Response = autorest.Response{Response: resp}
556	return
557}
558
559// SyncRemotemanagementCertificate sync Remote management Certificate between appliance and Service
560// Parameters:
561// deviceName - the device name
562// resourceGroupName - the resource group name
563// managerName - the manager name
564func (client DeviceSettingsClient) SyncRemotemanagementCertificate(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (result DeviceSettingsSyncRemotemanagementCertificateFuture, err error) {
565	if tracing.IsEnabled() {
566		ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSettingsClient.SyncRemotemanagementCertificate")
567		defer func() {
568			sc := -1
569			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
570				sc = result.FutureAPI.Response().StatusCode
571			}
572			tracing.EndSpan(ctx, sc, err)
573		}()
574	}
575	if err := validation.Validate([]validation.Validation{
576		{TargetValue: managerName,
577			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
578				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
579		return result, validation.NewError("storsimple.DeviceSettingsClient", "SyncRemotemanagementCertificate", err.Error())
580	}
581
582	req, err := client.SyncRemotemanagementCertificatePreparer(ctx, deviceName, resourceGroupName, managerName)
583	if err != nil {
584		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "SyncRemotemanagementCertificate", nil, "Failure preparing request")
585		return
586	}
587
588	result, err = client.SyncRemotemanagementCertificateSender(req)
589	if err != nil {
590		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "SyncRemotemanagementCertificate", nil, "Failure sending request")
591		return
592	}
593
594	return
595}
596
597// SyncRemotemanagementCertificatePreparer prepares the SyncRemotemanagementCertificate request.
598func (client DeviceSettingsClient) SyncRemotemanagementCertificatePreparer(ctx context.Context, deviceName string, resourceGroupName string, managerName string) (*http.Request, error) {
599	pathParameters := map[string]interface{}{
600		"deviceName":        deviceName,
601		"managerName":       managerName,
602		"resourceGroupName": resourceGroupName,
603		"subscriptionId":    client.SubscriptionID,
604	}
605
606	const APIVersion = "2017-06-01"
607	queryParameters := map[string]interface{}{
608		"api-version": APIVersion,
609	}
610
611	preparer := autorest.CreatePreparer(
612		autorest.AsPost(),
613		autorest.WithBaseURL(client.BaseURI),
614		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default/syncRemoteManagementCertificate", pathParameters),
615		autorest.WithQueryParameters(queryParameters))
616	return preparer.Prepare((&http.Request{}).WithContext(ctx))
617}
618
619// SyncRemotemanagementCertificateSender sends the SyncRemotemanagementCertificate request. The method will close the
620// http.Response Body if it receives an error.
621func (client DeviceSettingsClient) SyncRemotemanagementCertificateSender(req *http.Request) (future DeviceSettingsSyncRemotemanagementCertificateFuture, err error) {
622	var resp *http.Response
623	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
624	if err != nil {
625		return
626	}
627	var azf azure.Future
628	azf, err = azure.NewFutureFromResponse(resp)
629	future.FutureAPI = &azf
630	future.Result = future.result
631	return
632}
633
634// SyncRemotemanagementCertificateResponder handles the response to the SyncRemotemanagementCertificate request. The method always
635// closes the http.Response Body.
636func (client DeviceSettingsClient) SyncRemotemanagementCertificateResponder(resp *http.Response) (result autorest.Response, err error) {
637	err = autorest.Respond(
638		resp,
639		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
640		autorest.ByClosing())
641	result.Response = resp
642	return
643}
644
645// UpdateNetworkSettings updates the network settings on the specified device.
646// Parameters:
647// deviceName - the device name
648// parameters - the network settings to be updated.
649// resourceGroupName - the resource group name
650// managerName - the manager name
651func (client DeviceSettingsClient) UpdateNetworkSettings(ctx context.Context, deviceName string, parameters NetworkSettingsPatch, resourceGroupName string, managerName string) (result DeviceSettingsUpdateNetworkSettingsFuture, err error) {
652	if tracing.IsEnabled() {
653		ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSettingsClient.UpdateNetworkSettings")
654		defer func() {
655			sc := -1
656			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
657				sc = result.FutureAPI.Response().StatusCode
658			}
659			tracing.EndSpan(ctx, sc, err)
660		}()
661	}
662	if err := validation.Validate([]validation.Validation{
663		{TargetValue: managerName,
664			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
665				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
666		return result, validation.NewError("storsimple.DeviceSettingsClient", "UpdateNetworkSettings", err.Error())
667	}
668
669	req, err := client.UpdateNetworkSettingsPreparer(ctx, deviceName, parameters, resourceGroupName, managerName)
670	if err != nil {
671		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "UpdateNetworkSettings", nil, "Failure preparing request")
672		return
673	}
674
675	result, err = client.UpdateNetworkSettingsSender(req)
676	if err != nil {
677		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "UpdateNetworkSettings", nil, "Failure sending request")
678		return
679	}
680
681	return
682}
683
684// UpdateNetworkSettingsPreparer prepares the UpdateNetworkSettings request.
685func (client DeviceSettingsClient) UpdateNetworkSettingsPreparer(ctx context.Context, deviceName string, parameters NetworkSettingsPatch, resourceGroupName string, managerName string) (*http.Request, error) {
686	pathParameters := map[string]interface{}{
687		"deviceName":        deviceName,
688		"managerName":       managerName,
689		"resourceGroupName": resourceGroupName,
690		"subscriptionId":    client.SubscriptionID,
691	}
692
693	const APIVersion = "2017-06-01"
694	queryParameters := map[string]interface{}{
695		"api-version": APIVersion,
696	}
697
698	preparer := autorest.CreatePreparer(
699		autorest.AsContentType("application/json; charset=utf-8"),
700		autorest.AsPatch(),
701		autorest.WithBaseURL(client.BaseURI),
702		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/networkSettings/default", pathParameters),
703		autorest.WithJSON(parameters),
704		autorest.WithQueryParameters(queryParameters))
705	return preparer.Prepare((&http.Request{}).WithContext(ctx))
706}
707
708// UpdateNetworkSettingsSender sends the UpdateNetworkSettings request. The method will close the
709// http.Response Body if it receives an error.
710func (client DeviceSettingsClient) UpdateNetworkSettingsSender(req *http.Request) (future DeviceSettingsUpdateNetworkSettingsFuture, err error) {
711	var resp *http.Response
712	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
713	if err != nil {
714		return
715	}
716	var azf azure.Future
717	azf, err = azure.NewFutureFromResponse(resp)
718	future.FutureAPI = &azf
719	future.Result = future.result
720	return
721}
722
723// UpdateNetworkSettingsResponder handles the response to the UpdateNetworkSettings request. The method always
724// closes the http.Response Body.
725func (client DeviceSettingsClient) UpdateNetworkSettingsResponder(resp *http.Response) (result NetworkSettings, err error) {
726	err = autorest.Respond(
727		resp,
728		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
729		autorest.ByUnmarshallingJSON(&result),
730		autorest.ByClosing())
731	result.Response = autorest.Response{Response: resp}
732	return
733}
734
735// UpdateSecuritySettings patch Security properties of the specified device name.
736// Parameters:
737// deviceName - the device name
738// parameters - the security settings properties to be patched.
739// resourceGroupName - the resource group name
740// managerName - the manager name
741func (client DeviceSettingsClient) UpdateSecuritySettings(ctx context.Context, deviceName string, parameters SecuritySettingsPatch, resourceGroupName string, managerName string) (result DeviceSettingsUpdateSecuritySettingsFuture, err error) {
742	if tracing.IsEnabled() {
743		ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSettingsClient.UpdateSecuritySettings")
744		defer func() {
745			sc := -1
746			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
747				sc = result.FutureAPI.Response().StatusCode
748			}
749			tracing.EndSpan(ctx, sc, err)
750		}()
751	}
752	if err := validation.Validate([]validation.Validation{
753		{TargetValue: managerName,
754			Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil},
755				{Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil {
756		return result, validation.NewError("storsimple.DeviceSettingsClient", "UpdateSecuritySettings", err.Error())
757	}
758
759	req, err := client.UpdateSecuritySettingsPreparer(ctx, deviceName, parameters, resourceGroupName, managerName)
760	if err != nil {
761		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "UpdateSecuritySettings", nil, "Failure preparing request")
762		return
763	}
764
765	result, err = client.UpdateSecuritySettingsSender(req)
766	if err != nil {
767		err = autorest.NewErrorWithError(err, "storsimple.DeviceSettingsClient", "UpdateSecuritySettings", nil, "Failure sending request")
768		return
769	}
770
771	return
772}
773
774// UpdateSecuritySettingsPreparer prepares the UpdateSecuritySettings request.
775func (client DeviceSettingsClient) UpdateSecuritySettingsPreparer(ctx context.Context, deviceName string, parameters SecuritySettingsPatch, resourceGroupName string, managerName string) (*http.Request, error) {
776	pathParameters := map[string]interface{}{
777		"deviceName":        deviceName,
778		"managerName":       managerName,
779		"resourceGroupName": resourceGroupName,
780		"subscriptionId":    client.SubscriptionID,
781	}
782
783	const APIVersion = "2017-06-01"
784	queryParameters := map[string]interface{}{
785		"api-version": APIVersion,
786	}
787
788	preparer := autorest.CreatePreparer(
789		autorest.AsContentType("application/json; charset=utf-8"),
790		autorest.AsPatch(),
791		autorest.WithBaseURL(client.BaseURI),
792		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default", pathParameters),
793		autorest.WithJSON(parameters),
794		autorest.WithQueryParameters(queryParameters))
795	return preparer.Prepare((&http.Request{}).WithContext(ctx))
796}
797
798// UpdateSecuritySettingsSender sends the UpdateSecuritySettings request. The method will close the
799// http.Response Body if it receives an error.
800func (client DeviceSettingsClient) UpdateSecuritySettingsSender(req *http.Request) (future DeviceSettingsUpdateSecuritySettingsFuture, err error) {
801	var resp *http.Response
802	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
803	if err != nil {
804		return
805	}
806	var azf azure.Future
807	azf, err = azure.NewFutureFromResponse(resp)
808	future.FutureAPI = &azf
809	future.Result = future.result
810	return
811}
812
813// UpdateSecuritySettingsResponder handles the response to the UpdateSecuritySettings request. The method always
814// closes the http.Response Body.
815func (client DeviceSettingsClient) UpdateSecuritySettingsResponder(resp *http.Response) (result SecuritySettings, err error) {
816	err = autorest.Respond(
817		resp,
818		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
819		autorest.ByUnmarshallingJSON(&result),
820		autorest.ByClosing())
821	result.Response = autorest.Response{Response: resp}
822	return
823}
824