1package mysql
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	"encoding/json"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"github.com/Azure/go-autorest/autorest/date"
25	"net/http"
26)
27
28// CreateMode enumerates the values for create mode.
29type CreateMode string
30
31const (
32	// CreateModeDefault ...
33	CreateModeDefault CreateMode = "Default"
34	// CreateModePointInTimeRestore ...
35	CreateModePointInTimeRestore CreateMode = "PointInTimeRestore"
36	// CreateModeServerPropertiesForCreate ...
37	CreateModeServerPropertiesForCreate CreateMode = "ServerPropertiesForCreate"
38)
39
40// PossibleCreateModeValues returns an array of possible values for the CreateMode const type.
41func PossibleCreateModeValues() []CreateMode {
42	return []CreateMode{CreateModeDefault, CreateModePointInTimeRestore, CreateModeServerPropertiesForCreate}
43}
44
45// OperationOrigin enumerates the values for operation origin.
46type OperationOrigin string
47
48const (
49	// NotSpecified ...
50	NotSpecified OperationOrigin = "NotSpecified"
51	// System ...
52	System OperationOrigin = "system"
53	// User ...
54	User OperationOrigin = "user"
55)
56
57// PossibleOperationOriginValues returns an array of possible values for the OperationOrigin const type.
58func PossibleOperationOriginValues() []OperationOrigin {
59	return []OperationOrigin{NotSpecified, System, User}
60}
61
62// ServerState enumerates the values for server state.
63type ServerState string
64
65const (
66	// Disabled ...
67	Disabled ServerState = "Disabled"
68	// Dropping ...
69	Dropping ServerState = "Dropping"
70	// Ready ...
71	Ready ServerState = "Ready"
72)
73
74// PossibleServerStateValues returns an array of possible values for the ServerState const type.
75func PossibleServerStateValues() []ServerState {
76	return []ServerState{Disabled, Dropping, Ready}
77}
78
79// ServerVersion enumerates the values for server version.
80type ServerVersion string
81
82const (
83	// FiveFullStopSeven ...
84	FiveFullStopSeven ServerVersion = "5.7"
85	// FiveFullStopSix ...
86	FiveFullStopSix ServerVersion = "5.6"
87)
88
89// PossibleServerVersionValues returns an array of possible values for the ServerVersion const type.
90func PossibleServerVersionValues() []ServerVersion {
91	return []ServerVersion{FiveFullStopSeven, FiveFullStopSix}
92}
93
94// SkuTier enumerates the values for sku tier.
95type SkuTier string
96
97const (
98	// Basic ...
99	Basic SkuTier = "Basic"
100	// Standard ...
101	Standard SkuTier = "Standard"
102)
103
104// PossibleSkuTierValues returns an array of possible values for the SkuTier const type.
105func PossibleSkuTierValues() []SkuTier {
106	return []SkuTier{Basic, Standard}
107}
108
109// SslEnforcementEnum enumerates the values for ssl enforcement enum.
110type SslEnforcementEnum string
111
112const (
113	// SslEnforcementEnumDisabled ...
114	SslEnforcementEnumDisabled SslEnforcementEnum = "Disabled"
115	// SslEnforcementEnumEnabled ...
116	SslEnforcementEnumEnabled SslEnforcementEnum = "Enabled"
117)
118
119// PossibleSslEnforcementEnumValues returns an array of possible values for the SslEnforcementEnum const type.
120func PossibleSslEnforcementEnumValues() []SslEnforcementEnum {
121	return []SslEnforcementEnum{SslEnforcementEnumDisabled, SslEnforcementEnumEnabled}
122}
123
124// Configuration represents a Configuration.
125type Configuration struct {
126	autorest.Response `json:"-"`
127	// ConfigurationProperties - The properties of a configuration.
128	*ConfigurationProperties `json:"properties,omitempty"`
129	// ID - Resource ID
130	ID *string `json:"id,omitempty"`
131	// Name - Resource name.
132	Name *string `json:"name,omitempty"`
133	// Type - Resource type.
134	Type *string `json:"type,omitempty"`
135}
136
137// MarshalJSON is the custom marshaler for Configuration.
138func (c Configuration) MarshalJSON() ([]byte, error) {
139	objectMap := make(map[string]interface{})
140	if c.ConfigurationProperties != nil {
141		objectMap["properties"] = c.ConfigurationProperties
142	}
143	if c.ID != nil {
144		objectMap["id"] = c.ID
145	}
146	if c.Name != nil {
147		objectMap["name"] = c.Name
148	}
149	if c.Type != nil {
150		objectMap["type"] = c.Type
151	}
152	return json.Marshal(objectMap)
153}
154
155// UnmarshalJSON is the custom unmarshaler for Configuration struct.
156func (c *Configuration) UnmarshalJSON(body []byte) error {
157	var m map[string]*json.RawMessage
158	err := json.Unmarshal(body, &m)
159	if err != nil {
160		return err
161	}
162	for k, v := range m {
163		switch k {
164		case "properties":
165			if v != nil {
166				var configurationProperties ConfigurationProperties
167				err = json.Unmarshal(*v, &configurationProperties)
168				if err != nil {
169					return err
170				}
171				c.ConfigurationProperties = &configurationProperties
172			}
173		case "id":
174			if v != nil {
175				var ID string
176				err = json.Unmarshal(*v, &ID)
177				if err != nil {
178					return err
179				}
180				c.ID = &ID
181			}
182		case "name":
183			if v != nil {
184				var name string
185				err = json.Unmarshal(*v, &name)
186				if err != nil {
187					return err
188				}
189				c.Name = &name
190			}
191		case "type":
192			if v != nil {
193				var typeVar string
194				err = json.Unmarshal(*v, &typeVar)
195				if err != nil {
196					return err
197				}
198				c.Type = &typeVar
199			}
200		}
201	}
202
203	return nil
204}
205
206// ConfigurationListResult a list of server configurations.
207type ConfigurationListResult struct {
208	autorest.Response `json:"-"`
209	// Value - The list of server configurations.
210	Value *[]Configuration `json:"value,omitempty"`
211}
212
213// ConfigurationProperties the properties of a configuration.
214type ConfigurationProperties struct {
215	// Value - Value of the configuration.
216	Value *string `json:"value,omitempty"`
217	// Description - Description of the configuration.
218	Description *string `json:"description,omitempty"`
219	// DefaultValue - Default value of the configuration.
220	DefaultValue *string `json:"defaultValue,omitempty"`
221	// DataType - Data type of the configuration.
222	DataType *string `json:"dataType,omitempty"`
223	// AllowedValues - Allowed values of the configuration.
224	AllowedValues *string `json:"allowedValues,omitempty"`
225	// Source - Source of the configuration.
226	Source *string `json:"source,omitempty"`
227}
228
229// ConfigurationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
230// operation.
231type ConfigurationsCreateOrUpdateFuture struct {
232	azure.Future
233	req *http.Request
234}
235
236// Result returns the result of the asynchronous operation.
237// If the operation has not completed it will return an error.
238func (future ConfigurationsCreateOrUpdateFuture) Result(client ConfigurationsClient) (c Configuration, err error) {
239	var done bool
240	done, err = future.Done(client)
241	if err != nil {
242		err = autorest.NewErrorWithError(err, "mysql.ConfigurationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
243		return
244	}
245	if !done {
246		return c, azure.NewAsyncOpIncompleteError("mysql.ConfigurationsCreateOrUpdateFuture")
247	}
248	if future.PollingMethod() == azure.PollingLocation {
249		c, err = client.CreateOrUpdateResponder(future.Response())
250		if err != nil {
251			err = autorest.NewErrorWithError(err, "mysql.ConfigurationsCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request")
252		}
253		return
254	}
255	var req *http.Request
256	var resp *http.Response
257	if future.PollingURL() != "" {
258		req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil)
259		if err != nil {
260			return
261		}
262	} else {
263		req = autorest.ChangeToGet(future.req)
264	}
265	resp, err = autorest.SendWithSender(client, req,
266		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
267	if err != nil {
268		err = autorest.NewErrorWithError(err, "mysql.ConfigurationsCreateOrUpdateFuture", "Result", resp, "Failure sending request")
269		return
270	}
271	c, err = client.CreateOrUpdateResponder(resp)
272	if err != nil {
273		err = autorest.NewErrorWithError(err, "mysql.ConfigurationsCreateOrUpdateFuture", "Result", resp, "Failure responding to request")
274	}
275	return
276}
277
278// Database represents a Database.
279type Database struct {
280	autorest.Response `json:"-"`
281	// DatabaseProperties - The properties of a database.
282	*DatabaseProperties `json:"properties,omitempty"`
283	// ID - Resource ID
284	ID *string `json:"id,omitempty"`
285	// Name - Resource name.
286	Name *string `json:"name,omitempty"`
287	// Type - Resource type.
288	Type *string `json:"type,omitempty"`
289}
290
291// MarshalJSON is the custom marshaler for Database.
292func (d Database) MarshalJSON() ([]byte, error) {
293	objectMap := make(map[string]interface{})
294	if d.DatabaseProperties != nil {
295		objectMap["properties"] = d.DatabaseProperties
296	}
297	if d.ID != nil {
298		objectMap["id"] = d.ID
299	}
300	if d.Name != nil {
301		objectMap["name"] = d.Name
302	}
303	if d.Type != nil {
304		objectMap["type"] = d.Type
305	}
306	return json.Marshal(objectMap)
307}
308
309// UnmarshalJSON is the custom unmarshaler for Database struct.
310func (d *Database) UnmarshalJSON(body []byte) error {
311	var m map[string]*json.RawMessage
312	err := json.Unmarshal(body, &m)
313	if err != nil {
314		return err
315	}
316	for k, v := range m {
317		switch k {
318		case "properties":
319			if v != nil {
320				var databaseProperties DatabaseProperties
321				err = json.Unmarshal(*v, &databaseProperties)
322				if err != nil {
323					return err
324				}
325				d.DatabaseProperties = &databaseProperties
326			}
327		case "id":
328			if v != nil {
329				var ID string
330				err = json.Unmarshal(*v, &ID)
331				if err != nil {
332					return err
333				}
334				d.ID = &ID
335			}
336		case "name":
337			if v != nil {
338				var name string
339				err = json.Unmarshal(*v, &name)
340				if err != nil {
341					return err
342				}
343				d.Name = &name
344			}
345		case "type":
346			if v != nil {
347				var typeVar string
348				err = json.Unmarshal(*v, &typeVar)
349				if err != nil {
350					return err
351				}
352				d.Type = &typeVar
353			}
354		}
355	}
356
357	return nil
358}
359
360// DatabaseListResult a List of databases.
361type DatabaseListResult struct {
362	autorest.Response `json:"-"`
363	// Value - The list of databases housed in a server
364	Value *[]Database `json:"value,omitempty"`
365}
366
367// DatabaseProperties the properties of a database.
368type DatabaseProperties struct {
369	// Charset - The charset of the database.
370	Charset *string `json:"charset,omitempty"`
371	// Collation - The collation of the database.
372	Collation *string `json:"collation,omitempty"`
373}
374
375// DatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
376// operation.
377type DatabasesCreateOrUpdateFuture struct {
378	azure.Future
379	req *http.Request
380}
381
382// Result returns the result of the asynchronous operation.
383// If the operation has not completed it will return an error.
384func (future DatabasesCreateOrUpdateFuture) Result(client DatabasesClient) (d Database, err error) {
385	var done bool
386	done, err = future.Done(client)
387	if err != nil {
388		err = autorest.NewErrorWithError(err, "mysql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
389		return
390	}
391	if !done {
392		return d, azure.NewAsyncOpIncompleteError("mysql.DatabasesCreateOrUpdateFuture")
393	}
394	if future.PollingMethod() == azure.PollingLocation {
395		d, err = client.CreateOrUpdateResponder(future.Response())
396		if err != nil {
397			err = autorest.NewErrorWithError(err, "mysql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request")
398		}
399		return
400	}
401	var req *http.Request
402	var resp *http.Response
403	if future.PollingURL() != "" {
404		req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil)
405		if err != nil {
406			return
407		}
408	} else {
409		req = autorest.ChangeToGet(future.req)
410	}
411	resp, err = autorest.SendWithSender(client, req,
412		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
413	if err != nil {
414		err = autorest.NewErrorWithError(err, "mysql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure sending request")
415		return
416	}
417	d, err = client.CreateOrUpdateResponder(resp)
418	if err != nil {
419		err = autorest.NewErrorWithError(err, "mysql.DatabasesCreateOrUpdateFuture", "Result", resp, "Failure responding to request")
420	}
421	return
422}
423
424// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation.
425type DatabasesDeleteFuture struct {
426	azure.Future
427	req *http.Request
428}
429
430// Result returns the result of the asynchronous operation.
431// If the operation has not completed it will return an error.
432func (future DatabasesDeleteFuture) Result(client DatabasesClient) (ar autorest.Response, err error) {
433	var done bool
434	done, err = future.Done(client)
435	if err != nil {
436		err = autorest.NewErrorWithError(err, "mysql.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure")
437		return
438	}
439	if !done {
440		return ar, azure.NewAsyncOpIncompleteError("mysql.DatabasesDeleteFuture")
441	}
442	if future.PollingMethod() == azure.PollingLocation {
443		ar, err = client.DeleteResponder(future.Response())
444		if err != nil {
445			err = autorest.NewErrorWithError(err, "mysql.DatabasesDeleteFuture", "Result", future.Response(), "Failure responding to request")
446		}
447		return
448	}
449	var req *http.Request
450	var resp *http.Response
451	if future.PollingURL() != "" {
452		req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil)
453		if err != nil {
454			return
455		}
456	} else {
457		req = autorest.ChangeToGet(future.req)
458	}
459	resp, err = autorest.SendWithSender(client, req,
460		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
461	if err != nil {
462		err = autorest.NewErrorWithError(err, "mysql.DatabasesDeleteFuture", "Result", resp, "Failure sending request")
463		return
464	}
465	ar, err = client.DeleteResponder(resp)
466	if err != nil {
467		err = autorest.NewErrorWithError(err, "mysql.DatabasesDeleteFuture", "Result", resp, "Failure responding to request")
468	}
469	return
470}
471
472// FirewallRule represents a server firewall rule.
473type FirewallRule struct {
474	autorest.Response `json:"-"`
475	// FirewallRuleProperties - The properties of a firewall rule.
476	*FirewallRuleProperties `json:"properties,omitempty"`
477	// ID - Resource ID
478	ID *string `json:"id,omitempty"`
479	// Name - Resource name.
480	Name *string `json:"name,omitempty"`
481	// Type - Resource type.
482	Type *string `json:"type,omitempty"`
483}
484
485// MarshalJSON is the custom marshaler for FirewallRule.
486func (fr FirewallRule) MarshalJSON() ([]byte, error) {
487	objectMap := make(map[string]interface{})
488	if fr.FirewallRuleProperties != nil {
489		objectMap["properties"] = fr.FirewallRuleProperties
490	}
491	if fr.ID != nil {
492		objectMap["id"] = fr.ID
493	}
494	if fr.Name != nil {
495		objectMap["name"] = fr.Name
496	}
497	if fr.Type != nil {
498		objectMap["type"] = fr.Type
499	}
500	return json.Marshal(objectMap)
501}
502
503// UnmarshalJSON is the custom unmarshaler for FirewallRule struct.
504func (fr *FirewallRule) UnmarshalJSON(body []byte) error {
505	var m map[string]*json.RawMessage
506	err := json.Unmarshal(body, &m)
507	if err != nil {
508		return err
509	}
510	for k, v := range m {
511		switch k {
512		case "properties":
513			if v != nil {
514				var firewallRuleProperties FirewallRuleProperties
515				err = json.Unmarshal(*v, &firewallRuleProperties)
516				if err != nil {
517					return err
518				}
519				fr.FirewallRuleProperties = &firewallRuleProperties
520			}
521		case "id":
522			if v != nil {
523				var ID string
524				err = json.Unmarshal(*v, &ID)
525				if err != nil {
526					return err
527				}
528				fr.ID = &ID
529			}
530		case "name":
531			if v != nil {
532				var name string
533				err = json.Unmarshal(*v, &name)
534				if err != nil {
535					return err
536				}
537				fr.Name = &name
538			}
539		case "type":
540			if v != nil {
541				var typeVar string
542				err = json.Unmarshal(*v, &typeVar)
543				if err != nil {
544					return err
545				}
546				fr.Type = &typeVar
547			}
548		}
549	}
550
551	return nil
552}
553
554// FirewallRuleListResult a list of firewall rules.
555type FirewallRuleListResult struct {
556	autorest.Response `json:"-"`
557	// Value - The list of firewall rules in a server.
558	Value *[]FirewallRule `json:"value,omitempty"`
559}
560
561// FirewallRuleProperties the properties of a server firewall rule.
562type FirewallRuleProperties struct {
563	// StartIPAddress - The start IP address of the server firewall rule. Must be IPv4 format.
564	StartIPAddress *string `json:"startIpAddress,omitempty"`
565	// EndIPAddress - The end IP address of the server firewall rule. Must be IPv4 format.
566	EndIPAddress *string `json:"endIpAddress,omitempty"`
567}
568
569// FirewallRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
570// operation.
571type FirewallRulesCreateOrUpdateFuture struct {
572	azure.Future
573	req *http.Request
574}
575
576// Result returns the result of the asynchronous operation.
577// If the operation has not completed it will return an error.
578func (future FirewallRulesCreateOrUpdateFuture) Result(client FirewallRulesClient) (fr FirewallRule, err error) {
579	var done bool
580	done, err = future.Done(client)
581	if err != nil {
582		err = autorest.NewErrorWithError(err, "mysql.FirewallRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
583		return
584	}
585	if !done {
586		return fr, azure.NewAsyncOpIncompleteError("mysql.FirewallRulesCreateOrUpdateFuture")
587	}
588	if future.PollingMethod() == azure.PollingLocation {
589		fr, err = client.CreateOrUpdateResponder(future.Response())
590		if err != nil {
591			err = autorest.NewErrorWithError(err, "mysql.FirewallRulesCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request")
592		}
593		return
594	}
595	var req *http.Request
596	var resp *http.Response
597	if future.PollingURL() != "" {
598		req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil)
599		if err != nil {
600			return
601		}
602	} else {
603		req = autorest.ChangeToGet(future.req)
604	}
605	resp, err = autorest.SendWithSender(client, req,
606		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
607	if err != nil {
608		err = autorest.NewErrorWithError(err, "mysql.FirewallRulesCreateOrUpdateFuture", "Result", resp, "Failure sending request")
609		return
610	}
611	fr, err = client.CreateOrUpdateResponder(resp)
612	if err != nil {
613		err = autorest.NewErrorWithError(err, "mysql.FirewallRulesCreateOrUpdateFuture", "Result", resp, "Failure responding to request")
614	}
615	return
616}
617
618// FirewallRulesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation.
619type FirewallRulesDeleteFuture struct {
620	azure.Future
621	req *http.Request
622}
623
624// Result returns the result of the asynchronous operation.
625// If the operation has not completed it will return an error.
626func (future FirewallRulesDeleteFuture) Result(client FirewallRulesClient) (ar autorest.Response, err error) {
627	var done bool
628	done, err = future.Done(client)
629	if err != nil {
630		err = autorest.NewErrorWithError(err, "mysql.FirewallRulesDeleteFuture", "Result", future.Response(), "Polling failure")
631		return
632	}
633	if !done {
634		return ar, azure.NewAsyncOpIncompleteError("mysql.FirewallRulesDeleteFuture")
635	}
636	if future.PollingMethod() == azure.PollingLocation {
637		ar, err = client.DeleteResponder(future.Response())
638		if err != nil {
639			err = autorest.NewErrorWithError(err, "mysql.FirewallRulesDeleteFuture", "Result", future.Response(), "Failure responding to request")
640		}
641		return
642	}
643	var req *http.Request
644	var resp *http.Response
645	if future.PollingURL() != "" {
646		req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil)
647		if err != nil {
648			return
649		}
650	} else {
651		req = autorest.ChangeToGet(future.req)
652	}
653	resp, err = autorest.SendWithSender(client, req,
654		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
655	if err != nil {
656		err = autorest.NewErrorWithError(err, "mysql.FirewallRulesDeleteFuture", "Result", resp, "Failure sending request")
657		return
658	}
659	ar, err = client.DeleteResponder(resp)
660	if err != nil {
661		err = autorest.NewErrorWithError(err, "mysql.FirewallRulesDeleteFuture", "Result", resp, "Failure responding to request")
662	}
663	return
664}
665
666// LogFile represents a log file.
667type LogFile struct {
668	// LogFileProperties - The properties of the log file.
669	*LogFileProperties `json:"properties,omitempty"`
670	// ID - Resource ID
671	ID *string `json:"id,omitempty"`
672	// Name - Resource name.
673	Name *string `json:"name,omitempty"`
674	// Type - Resource type.
675	Type *string `json:"type,omitempty"`
676}
677
678// MarshalJSON is the custom marshaler for LogFile.
679func (lf LogFile) MarshalJSON() ([]byte, error) {
680	objectMap := make(map[string]interface{})
681	if lf.LogFileProperties != nil {
682		objectMap["properties"] = lf.LogFileProperties
683	}
684	if lf.ID != nil {
685		objectMap["id"] = lf.ID
686	}
687	if lf.Name != nil {
688		objectMap["name"] = lf.Name
689	}
690	if lf.Type != nil {
691		objectMap["type"] = lf.Type
692	}
693	return json.Marshal(objectMap)
694}
695
696// UnmarshalJSON is the custom unmarshaler for LogFile struct.
697func (lf *LogFile) UnmarshalJSON(body []byte) error {
698	var m map[string]*json.RawMessage
699	err := json.Unmarshal(body, &m)
700	if err != nil {
701		return err
702	}
703	for k, v := range m {
704		switch k {
705		case "properties":
706			if v != nil {
707				var logFileProperties LogFileProperties
708				err = json.Unmarshal(*v, &logFileProperties)
709				if err != nil {
710					return err
711				}
712				lf.LogFileProperties = &logFileProperties
713			}
714		case "id":
715			if v != nil {
716				var ID string
717				err = json.Unmarshal(*v, &ID)
718				if err != nil {
719					return err
720				}
721				lf.ID = &ID
722			}
723		case "name":
724			if v != nil {
725				var name string
726				err = json.Unmarshal(*v, &name)
727				if err != nil {
728					return err
729				}
730				lf.Name = &name
731			}
732		case "type":
733			if v != nil {
734				var typeVar string
735				err = json.Unmarshal(*v, &typeVar)
736				if err != nil {
737					return err
738				}
739				lf.Type = &typeVar
740			}
741		}
742	}
743
744	return nil
745}
746
747// LogFileListResult a list of log files.
748type LogFileListResult struct {
749	autorest.Response `json:"-"`
750	// Value - The list of log files.
751	Value *[]LogFile `json:"value,omitempty"`
752}
753
754// LogFileProperties the properties of a log file.
755type LogFileProperties struct {
756	// Name - Log file name.
757	Name *string `json:"name,omitempty"`
758	// SizeInKB - Size of the log file.
759	SizeInKB *int64 `json:"sizeInKB,omitempty"`
760	// CreatedTime - Creation timestamp of the log file.
761	CreatedTime *date.Time `json:"createdTime,omitempty"`
762	// LastModifiedTime - Last modified timestamp of the log file.
763	LastModifiedTime *date.Time `json:"lastModifiedTime,omitempty"`
764	// Type - Type of the log file.
765	Type *string `json:"type,omitempty"`
766	// URL - The url to download the log file from.
767	URL *string `json:"url,omitempty"`
768}
769
770// NameAvailability represents a resource name availability.
771type NameAvailability struct {
772	autorest.Response `json:"-"`
773	// Message - Error Message.
774	Message *string `json:"message,omitempty"`
775	// NameAvailable - Indicates whether the resource name is available.
776	NameAvailable *bool `json:"nameAvailable,omitempty"`
777	// Reason - Reason for name being unavailable.
778	Reason *string `json:"reason,omitempty"`
779}
780
781// NameAvailabilityRequest request from client to check resource name availability.
782type NameAvailabilityRequest struct {
783	// Name - Resource name to verify.
784	Name *string `json:"name,omitempty"`
785	// Type - Resource type used for verification.
786	Type *string `json:"type,omitempty"`
787}
788
789// Operation REST API operation definition.
790type Operation struct {
791	// Name - The name of the operation being performed on this particular object.
792	Name *string `json:"name,omitempty"`
793	// Display - The localized display information for this particular operation or action.
794	Display *OperationDisplay `json:"display,omitempty"`
795	// Origin - The intended executor of the operation. Possible values include: 'NotSpecified', 'User', 'System'
796	Origin OperationOrigin `json:"origin,omitempty"`
797	// Properties - Additional descriptions for the operation.
798	Properties map[string]interface{} `json:"properties"`
799}
800
801// MarshalJSON is the custom marshaler for Operation.
802func (o Operation) MarshalJSON() ([]byte, error) {
803	objectMap := make(map[string]interface{})
804	if o.Name != nil {
805		objectMap["name"] = o.Name
806	}
807	if o.Display != nil {
808		objectMap["display"] = o.Display
809	}
810	if o.Origin != "" {
811		objectMap["origin"] = o.Origin
812	}
813	if o.Properties != nil {
814		objectMap["properties"] = o.Properties
815	}
816	return json.Marshal(objectMap)
817}
818
819// OperationDisplay display metadata associated with the operation.
820type OperationDisplay struct {
821	// Provider - Operation resource provider name.
822	Provider *string `json:"provider,omitempty"`
823	// Resource - Resource on which the operation is performed.
824	Resource *string `json:"resource,omitempty"`
825	// Operation - Localized friendly name for the operation.
826	Operation *string `json:"operation,omitempty"`
827	// Description - Operation description.
828	Description *string `json:"description,omitempty"`
829}
830
831// OperationListResult a list of resource provider operations.
832type OperationListResult struct {
833	autorest.Response `json:"-"`
834	// Value - The list of resource provider operations.
835	Value *[]Operation `json:"value,omitempty"`
836}
837
838// PerformanceTierListResult a list of performance tiers.
839type PerformanceTierListResult struct {
840	autorest.Response `json:"-"`
841	// Value - The list of performance tiers
842	Value *[]PerformanceTierProperties `json:"value,omitempty"`
843}
844
845// PerformanceTierProperties performance tier properties
846type PerformanceTierProperties struct {
847	// ID - ID of the performance tier.
848	ID *string `json:"id,omitempty"`
849	// BackupRetentionDays - Backup retention in days for the performance tier edition
850	BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"`
851	// ServiceLevelObjectives - Service level objectives associated with the performance tier
852	ServiceLevelObjectives *[]PerformanceTierServiceLevelObjectives `json:"serviceLevelObjectives,omitempty"`
853}
854
855// PerformanceTierServiceLevelObjectives service level objectives for performance tier.
856type PerformanceTierServiceLevelObjectives struct {
857	// ID - ID for the service level objective.
858	ID *string `json:"id,omitempty"`
859	// Edition - Edition of the performance tier.
860	Edition *string `json:"edition,omitempty"`
861	// Dtu - Database throughput unit associated with the service level objective
862	Dtu *int32 `json:"dtu,omitempty"`
863	// StorageMB - Maximum storage in MB associated with the service level objective
864	StorageMB *int32 `json:"storageMB,omitempty"`
865}
866
867// ProxyResource resource properties.
868type ProxyResource struct {
869	// ID - Resource ID
870	ID *string `json:"id,omitempty"`
871	// Name - Resource name.
872	Name *string `json:"name,omitempty"`
873	// Type - Resource type.
874	Type *string `json:"type,omitempty"`
875}
876
877// Server represents a server.
878type Server struct {
879	autorest.Response `json:"-"`
880	// Sku - The SKU (pricing tier) of the server.
881	Sku *Sku `json:"sku,omitempty"`
882	// ServerProperties - Properties of the server.
883	*ServerProperties `json:"properties,omitempty"`
884	// Location - The location the resource resides in.
885	Location *string `json:"location,omitempty"`
886	// Tags - Application-specific metadata in the form of key-value pairs.
887	Tags map[string]*string `json:"tags"`
888	// ID - Resource ID
889	ID *string `json:"id,omitempty"`
890	// Name - Resource name.
891	Name *string `json:"name,omitempty"`
892	// Type - Resource type.
893	Type *string `json:"type,omitempty"`
894}
895
896// MarshalJSON is the custom marshaler for Server.
897func (s Server) MarshalJSON() ([]byte, error) {
898	objectMap := make(map[string]interface{})
899	if s.Sku != nil {
900		objectMap["sku"] = s.Sku
901	}
902	if s.ServerProperties != nil {
903		objectMap["properties"] = s.ServerProperties
904	}
905	if s.Location != nil {
906		objectMap["location"] = s.Location
907	}
908	if s.Tags != nil {
909		objectMap["tags"] = s.Tags
910	}
911	if s.ID != nil {
912		objectMap["id"] = s.ID
913	}
914	if s.Name != nil {
915		objectMap["name"] = s.Name
916	}
917	if s.Type != nil {
918		objectMap["type"] = s.Type
919	}
920	return json.Marshal(objectMap)
921}
922
923// UnmarshalJSON is the custom unmarshaler for Server struct.
924func (s *Server) UnmarshalJSON(body []byte) error {
925	var m map[string]*json.RawMessage
926	err := json.Unmarshal(body, &m)
927	if err != nil {
928		return err
929	}
930	for k, v := range m {
931		switch k {
932		case "sku":
933			if v != nil {
934				var sku Sku
935				err = json.Unmarshal(*v, &sku)
936				if err != nil {
937					return err
938				}
939				s.Sku = &sku
940			}
941		case "properties":
942			if v != nil {
943				var serverProperties ServerProperties
944				err = json.Unmarshal(*v, &serverProperties)
945				if err != nil {
946					return err
947				}
948				s.ServerProperties = &serverProperties
949			}
950		case "location":
951			if v != nil {
952				var location string
953				err = json.Unmarshal(*v, &location)
954				if err != nil {
955					return err
956				}
957				s.Location = &location
958			}
959		case "tags":
960			if v != nil {
961				var tags map[string]*string
962				err = json.Unmarshal(*v, &tags)
963				if err != nil {
964					return err
965				}
966				s.Tags = tags
967			}
968		case "id":
969			if v != nil {
970				var ID string
971				err = json.Unmarshal(*v, &ID)
972				if err != nil {
973					return err
974				}
975				s.ID = &ID
976			}
977		case "name":
978			if v != nil {
979				var name string
980				err = json.Unmarshal(*v, &name)
981				if err != nil {
982					return err
983				}
984				s.Name = &name
985			}
986		case "type":
987			if v != nil {
988				var typeVar string
989				err = json.Unmarshal(*v, &typeVar)
990				if err != nil {
991					return err
992				}
993				s.Type = &typeVar
994			}
995		}
996	}
997
998	return nil
999}
1000
1001// ServerForCreate represents a server to be created.
1002type ServerForCreate struct {
1003	// Sku - The SKU (pricing tier) of the server.
1004	Sku *Sku `json:"sku,omitempty"`
1005	// Properties - Properties of the server.
1006	Properties BasicServerPropertiesForCreate `json:"properties,omitempty"`
1007	// Location - The location the resource resides in.
1008	Location *string `json:"location,omitempty"`
1009	// Tags - Application-specific metadata in the form of key-value pairs.
1010	Tags map[string]*string `json:"tags"`
1011}
1012
1013// MarshalJSON is the custom marshaler for ServerForCreate.
1014func (sfc ServerForCreate) MarshalJSON() ([]byte, error) {
1015	objectMap := make(map[string]interface{})
1016	if sfc.Sku != nil {
1017		objectMap["sku"] = sfc.Sku
1018	}
1019	objectMap["properties"] = sfc.Properties
1020	if sfc.Location != nil {
1021		objectMap["location"] = sfc.Location
1022	}
1023	if sfc.Tags != nil {
1024		objectMap["tags"] = sfc.Tags
1025	}
1026	return json.Marshal(objectMap)
1027}
1028
1029// UnmarshalJSON is the custom unmarshaler for ServerForCreate struct.
1030func (sfc *ServerForCreate) UnmarshalJSON(body []byte) error {
1031	var m map[string]*json.RawMessage
1032	err := json.Unmarshal(body, &m)
1033	if err != nil {
1034		return err
1035	}
1036	for k, v := range m {
1037		switch k {
1038		case "sku":
1039			if v != nil {
1040				var sku Sku
1041				err = json.Unmarshal(*v, &sku)
1042				if err != nil {
1043					return err
1044				}
1045				sfc.Sku = &sku
1046			}
1047		case "properties":
1048			if v != nil {
1049				properties, err := unmarshalBasicServerPropertiesForCreate(*v)
1050				if err != nil {
1051					return err
1052				}
1053				sfc.Properties = properties
1054			}
1055		case "location":
1056			if v != nil {
1057				var location string
1058				err = json.Unmarshal(*v, &location)
1059				if err != nil {
1060					return err
1061				}
1062				sfc.Location = &location
1063			}
1064		case "tags":
1065			if v != nil {
1066				var tags map[string]*string
1067				err = json.Unmarshal(*v, &tags)
1068				if err != nil {
1069					return err
1070				}
1071				sfc.Tags = tags
1072			}
1073		}
1074	}
1075
1076	return nil
1077}
1078
1079// ServerListResult a list of servers.
1080type ServerListResult struct {
1081	autorest.Response `json:"-"`
1082	// Value - The list of servers
1083	Value *[]Server `json:"value,omitempty"`
1084}
1085
1086// ServerProperties the properties of a server.
1087type ServerProperties struct {
1088	// AdministratorLogin - The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation).
1089	AdministratorLogin *string `json:"administratorLogin,omitempty"`
1090	// StorageMB - The maximum storage allowed for a server.
1091	StorageMB *int64 `json:"storageMB,omitempty"`
1092	// Version - Server version. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven'
1093	Version ServerVersion `json:"version,omitempty"`
1094	// SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled'
1095	SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"`
1096	// UserVisibleState - A state of a server that is visible to user. Possible values include: 'Ready', 'Dropping', 'Disabled'
1097	UserVisibleState ServerState `json:"userVisibleState,omitempty"`
1098	// FullyQualifiedDomainName - The fully qualified domain name of a server.
1099	FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"`
1100}
1101
1102// BasicServerPropertiesForCreate the properties used to create a new server.
1103type BasicServerPropertiesForCreate interface {
1104	AsServerPropertiesForDefaultCreate() (*ServerPropertiesForDefaultCreate, bool)
1105	AsServerPropertiesForRestore() (*ServerPropertiesForRestore, bool)
1106	AsServerPropertiesForCreate() (*ServerPropertiesForCreate, bool)
1107}
1108
1109// ServerPropertiesForCreate the properties used to create a new server.
1110type ServerPropertiesForCreate struct {
1111	// StorageMB - The maximum storage allowed for a server.
1112	StorageMB *int64 `json:"storageMB,omitempty"`
1113	// Version - Server version. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven'
1114	Version ServerVersion `json:"version,omitempty"`
1115	// SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled'
1116	SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"`
1117	// CreateMode - Possible values include: 'CreateModeServerPropertiesForCreate', 'CreateModeDefault', 'CreateModePointInTimeRestore'
1118	CreateMode CreateMode `json:"createMode,omitempty"`
1119}
1120
1121func unmarshalBasicServerPropertiesForCreate(body []byte) (BasicServerPropertiesForCreate, error) {
1122	var m map[string]interface{}
1123	err := json.Unmarshal(body, &m)
1124	if err != nil {
1125		return nil, err
1126	}
1127
1128	switch m["createMode"] {
1129	case string(CreateModeDefault):
1130		var spfdc ServerPropertiesForDefaultCreate
1131		err := json.Unmarshal(body, &spfdc)
1132		return spfdc, err
1133	case string(CreateModePointInTimeRestore):
1134		var spfr ServerPropertiesForRestore
1135		err := json.Unmarshal(body, &spfr)
1136		return spfr, err
1137	default:
1138		var spfc ServerPropertiesForCreate
1139		err := json.Unmarshal(body, &spfc)
1140		return spfc, err
1141	}
1142}
1143func unmarshalBasicServerPropertiesForCreateArray(body []byte) ([]BasicServerPropertiesForCreate, error) {
1144	var rawMessages []*json.RawMessage
1145	err := json.Unmarshal(body, &rawMessages)
1146	if err != nil {
1147		return nil, err
1148	}
1149
1150	spfcArray := make([]BasicServerPropertiesForCreate, len(rawMessages))
1151
1152	for index, rawMessage := range rawMessages {
1153		spfc, err := unmarshalBasicServerPropertiesForCreate(*rawMessage)
1154		if err != nil {
1155			return nil, err
1156		}
1157		spfcArray[index] = spfc
1158	}
1159	return spfcArray, nil
1160}
1161
1162// MarshalJSON is the custom marshaler for ServerPropertiesForCreate.
1163func (spfc ServerPropertiesForCreate) MarshalJSON() ([]byte, error) {
1164	spfc.CreateMode = CreateModeServerPropertiesForCreate
1165	objectMap := make(map[string]interface{})
1166	if spfc.StorageMB != nil {
1167		objectMap["storageMB"] = spfc.StorageMB
1168	}
1169	if spfc.Version != "" {
1170		objectMap["version"] = spfc.Version
1171	}
1172	if spfc.SslEnforcement != "" {
1173		objectMap["sslEnforcement"] = spfc.SslEnforcement
1174	}
1175	if spfc.CreateMode != "" {
1176		objectMap["createMode"] = spfc.CreateMode
1177	}
1178	return json.Marshal(objectMap)
1179}
1180
1181// AsServerPropertiesForDefaultCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForCreate.
1182func (spfc ServerPropertiesForCreate) AsServerPropertiesForDefaultCreate() (*ServerPropertiesForDefaultCreate, bool) {
1183	return nil, false
1184}
1185
1186// AsServerPropertiesForRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForCreate.
1187func (spfc ServerPropertiesForCreate) AsServerPropertiesForRestore() (*ServerPropertiesForRestore, bool) {
1188	return nil, false
1189}
1190
1191// AsServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForCreate.
1192func (spfc ServerPropertiesForCreate) AsServerPropertiesForCreate() (*ServerPropertiesForCreate, bool) {
1193	return &spfc, true
1194}
1195
1196// AsBasicServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForCreate.
1197func (spfc ServerPropertiesForCreate) AsBasicServerPropertiesForCreate() (BasicServerPropertiesForCreate, bool) {
1198	return &spfc, true
1199}
1200
1201// ServerPropertiesForDefaultCreate the properties used to create a new server.
1202type ServerPropertiesForDefaultCreate struct {
1203	// AdministratorLogin - The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation).
1204	AdministratorLogin *string `json:"administratorLogin,omitempty"`
1205	// AdministratorLoginPassword - The password of the administrator login.
1206	AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"`
1207	// StorageMB - The maximum storage allowed for a server.
1208	StorageMB *int64 `json:"storageMB,omitempty"`
1209	// Version - Server version. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven'
1210	Version ServerVersion `json:"version,omitempty"`
1211	// SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled'
1212	SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"`
1213	// CreateMode - Possible values include: 'CreateModeServerPropertiesForCreate', 'CreateModeDefault', 'CreateModePointInTimeRestore'
1214	CreateMode CreateMode `json:"createMode,omitempty"`
1215}
1216
1217// MarshalJSON is the custom marshaler for ServerPropertiesForDefaultCreate.
1218func (spfdc ServerPropertiesForDefaultCreate) MarshalJSON() ([]byte, error) {
1219	spfdc.CreateMode = CreateModeDefault
1220	objectMap := make(map[string]interface{})
1221	if spfdc.AdministratorLogin != nil {
1222		objectMap["administratorLogin"] = spfdc.AdministratorLogin
1223	}
1224	if spfdc.AdministratorLoginPassword != nil {
1225		objectMap["administratorLoginPassword"] = spfdc.AdministratorLoginPassword
1226	}
1227	if spfdc.StorageMB != nil {
1228		objectMap["storageMB"] = spfdc.StorageMB
1229	}
1230	if spfdc.Version != "" {
1231		objectMap["version"] = spfdc.Version
1232	}
1233	if spfdc.SslEnforcement != "" {
1234		objectMap["sslEnforcement"] = spfdc.SslEnforcement
1235	}
1236	if spfdc.CreateMode != "" {
1237		objectMap["createMode"] = spfdc.CreateMode
1238	}
1239	return json.Marshal(objectMap)
1240}
1241
1242// AsServerPropertiesForDefaultCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForDefaultCreate.
1243func (spfdc ServerPropertiesForDefaultCreate) AsServerPropertiesForDefaultCreate() (*ServerPropertiesForDefaultCreate, bool) {
1244	return &spfdc, true
1245}
1246
1247// AsServerPropertiesForRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForDefaultCreate.
1248func (spfdc ServerPropertiesForDefaultCreate) AsServerPropertiesForRestore() (*ServerPropertiesForRestore, bool) {
1249	return nil, false
1250}
1251
1252// AsServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForDefaultCreate.
1253func (spfdc ServerPropertiesForDefaultCreate) AsServerPropertiesForCreate() (*ServerPropertiesForCreate, bool) {
1254	return nil, false
1255}
1256
1257// AsBasicServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForDefaultCreate.
1258func (spfdc ServerPropertiesForDefaultCreate) AsBasicServerPropertiesForCreate() (BasicServerPropertiesForCreate, bool) {
1259	return &spfdc, true
1260}
1261
1262// ServerPropertiesForRestore the properties to a new server by restoring from a backup.
1263type ServerPropertiesForRestore struct {
1264	// SourceServerID - The source server id to restore from.
1265	SourceServerID *string `json:"sourceServerId,omitempty"`
1266	// RestorePointInTime - Restore point creation time (ISO8601 format), specifying the time to restore from.
1267	RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"`
1268	// StorageMB - The maximum storage allowed for a server.
1269	StorageMB *int64 `json:"storageMB,omitempty"`
1270	// Version - Server version. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven'
1271	Version ServerVersion `json:"version,omitempty"`
1272	// SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled'
1273	SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"`
1274	// CreateMode - Possible values include: 'CreateModeServerPropertiesForCreate', 'CreateModeDefault', 'CreateModePointInTimeRestore'
1275	CreateMode CreateMode `json:"createMode,omitempty"`
1276}
1277
1278// MarshalJSON is the custom marshaler for ServerPropertiesForRestore.
1279func (spfr ServerPropertiesForRestore) MarshalJSON() ([]byte, error) {
1280	spfr.CreateMode = CreateModePointInTimeRestore
1281	objectMap := make(map[string]interface{})
1282	if spfr.SourceServerID != nil {
1283		objectMap["sourceServerId"] = spfr.SourceServerID
1284	}
1285	if spfr.RestorePointInTime != nil {
1286		objectMap["restorePointInTime"] = spfr.RestorePointInTime
1287	}
1288	if spfr.StorageMB != nil {
1289		objectMap["storageMB"] = spfr.StorageMB
1290	}
1291	if spfr.Version != "" {
1292		objectMap["version"] = spfr.Version
1293	}
1294	if spfr.SslEnforcement != "" {
1295		objectMap["sslEnforcement"] = spfr.SslEnforcement
1296	}
1297	if spfr.CreateMode != "" {
1298		objectMap["createMode"] = spfr.CreateMode
1299	}
1300	return json.Marshal(objectMap)
1301}
1302
1303// AsServerPropertiesForDefaultCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForRestore.
1304func (spfr ServerPropertiesForRestore) AsServerPropertiesForDefaultCreate() (*ServerPropertiesForDefaultCreate, bool) {
1305	return nil, false
1306}
1307
1308// AsServerPropertiesForRestore is the BasicServerPropertiesForCreate implementation for ServerPropertiesForRestore.
1309func (spfr ServerPropertiesForRestore) AsServerPropertiesForRestore() (*ServerPropertiesForRestore, bool) {
1310	return &spfr, true
1311}
1312
1313// AsServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForRestore.
1314func (spfr ServerPropertiesForRestore) AsServerPropertiesForCreate() (*ServerPropertiesForCreate, bool) {
1315	return nil, false
1316}
1317
1318// AsBasicServerPropertiesForCreate is the BasicServerPropertiesForCreate implementation for ServerPropertiesForRestore.
1319func (spfr ServerPropertiesForRestore) AsBasicServerPropertiesForCreate() (BasicServerPropertiesForCreate, bool) {
1320	return &spfr, true
1321}
1322
1323// ServersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
1324// operation.
1325type ServersCreateOrUpdateFuture struct {
1326	azure.Future
1327	req *http.Request
1328}
1329
1330// Result returns the result of the asynchronous operation.
1331// If the operation has not completed it will return an error.
1332func (future ServersCreateOrUpdateFuture) Result(client ServersClient) (s Server, err error) {
1333	var done bool
1334	done, err = future.Done(client)
1335	if err != nil {
1336		err = autorest.NewErrorWithError(err, "mysql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
1337		return
1338	}
1339	if !done {
1340		return s, azure.NewAsyncOpIncompleteError("mysql.ServersCreateOrUpdateFuture")
1341	}
1342	if future.PollingMethod() == azure.PollingLocation {
1343		s, err = client.CreateOrUpdateResponder(future.Response())
1344		if err != nil {
1345			err = autorest.NewErrorWithError(err, "mysql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Failure responding to request")
1346		}
1347		return
1348	}
1349	var req *http.Request
1350	var resp *http.Response
1351	if future.PollingURL() != "" {
1352		req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil)
1353		if err != nil {
1354			return
1355		}
1356	} else {
1357		req = autorest.ChangeToGet(future.req)
1358	}
1359	resp, err = autorest.SendWithSender(client, req,
1360		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1361	if err != nil {
1362		err = autorest.NewErrorWithError(err, "mysql.ServersCreateOrUpdateFuture", "Result", resp, "Failure sending request")
1363		return
1364	}
1365	s, err = client.CreateOrUpdateResponder(resp)
1366	if err != nil {
1367		err = autorest.NewErrorWithError(err, "mysql.ServersCreateOrUpdateFuture", "Result", resp, "Failure responding to request")
1368	}
1369	return
1370}
1371
1372// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation.
1373type ServersDeleteFuture struct {
1374	azure.Future
1375	req *http.Request
1376}
1377
1378// Result returns the result of the asynchronous operation.
1379// If the operation has not completed it will return an error.
1380func (future ServersDeleteFuture) Result(client ServersClient) (ar autorest.Response, err error) {
1381	var done bool
1382	done, err = future.Done(client)
1383	if err != nil {
1384		err = autorest.NewErrorWithError(err, "mysql.ServersDeleteFuture", "Result", future.Response(), "Polling failure")
1385		return
1386	}
1387	if !done {
1388		return ar, azure.NewAsyncOpIncompleteError("mysql.ServersDeleteFuture")
1389	}
1390	if future.PollingMethod() == azure.PollingLocation {
1391		ar, err = client.DeleteResponder(future.Response())
1392		if err != nil {
1393			err = autorest.NewErrorWithError(err, "mysql.ServersDeleteFuture", "Result", future.Response(), "Failure responding to request")
1394		}
1395		return
1396	}
1397	var req *http.Request
1398	var resp *http.Response
1399	if future.PollingURL() != "" {
1400		req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil)
1401		if err != nil {
1402			return
1403		}
1404	} else {
1405		req = autorest.ChangeToGet(future.req)
1406	}
1407	resp, err = autorest.SendWithSender(client, req,
1408		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1409	if err != nil {
1410		err = autorest.NewErrorWithError(err, "mysql.ServersDeleteFuture", "Result", resp, "Failure sending request")
1411		return
1412	}
1413	ar, err = client.DeleteResponder(resp)
1414	if err != nil {
1415		err = autorest.NewErrorWithError(err, "mysql.ServersDeleteFuture", "Result", resp, "Failure responding to request")
1416	}
1417	return
1418}
1419
1420// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation.
1421type ServersUpdateFuture struct {
1422	azure.Future
1423	req *http.Request
1424}
1425
1426// Result returns the result of the asynchronous operation.
1427// If the operation has not completed it will return an error.
1428func (future ServersUpdateFuture) Result(client ServersClient) (s Server, err error) {
1429	var done bool
1430	done, err = future.Done(client)
1431	if err != nil {
1432		err = autorest.NewErrorWithError(err, "mysql.ServersUpdateFuture", "Result", future.Response(), "Polling failure")
1433		return
1434	}
1435	if !done {
1436		return s, azure.NewAsyncOpIncompleteError("mysql.ServersUpdateFuture")
1437	}
1438	if future.PollingMethod() == azure.PollingLocation {
1439		s, err = client.UpdateResponder(future.Response())
1440		if err != nil {
1441			err = autorest.NewErrorWithError(err, "mysql.ServersUpdateFuture", "Result", future.Response(), "Failure responding to request")
1442		}
1443		return
1444	}
1445	var req *http.Request
1446	var resp *http.Response
1447	if future.PollingURL() != "" {
1448		req, err = http.NewRequest(http.MethodGet, future.PollingURL(), nil)
1449		if err != nil {
1450			return
1451		}
1452	} else {
1453		req = autorest.ChangeToGet(future.req)
1454	}
1455	resp, err = autorest.SendWithSender(client, req,
1456		autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1457	if err != nil {
1458		err = autorest.NewErrorWithError(err, "mysql.ServersUpdateFuture", "Result", resp, "Failure sending request")
1459		return
1460	}
1461	s, err = client.UpdateResponder(resp)
1462	if err != nil {
1463		err = autorest.NewErrorWithError(err, "mysql.ServersUpdateFuture", "Result", resp, "Failure responding to request")
1464	}
1465	return
1466}
1467
1468// ServerUpdateParameters parameters allowd to update for a server.
1469type ServerUpdateParameters struct {
1470	// Sku - The SKU (pricing tier) of the server.
1471	Sku *Sku `json:"sku,omitempty"`
1472	// ServerUpdateParametersProperties - The properties that can be updated for a server.
1473	*ServerUpdateParametersProperties `json:"properties,omitempty"`
1474	// Tags - Application-specific metadata in the form of key-value pairs.
1475	Tags map[string]*string `json:"tags"`
1476}
1477
1478// MarshalJSON is the custom marshaler for ServerUpdateParameters.
1479func (sup ServerUpdateParameters) MarshalJSON() ([]byte, error) {
1480	objectMap := make(map[string]interface{})
1481	if sup.Sku != nil {
1482		objectMap["sku"] = sup.Sku
1483	}
1484	if sup.ServerUpdateParametersProperties != nil {
1485		objectMap["properties"] = sup.ServerUpdateParametersProperties
1486	}
1487	if sup.Tags != nil {
1488		objectMap["tags"] = sup.Tags
1489	}
1490	return json.Marshal(objectMap)
1491}
1492
1493// UnmarshalJSON is the custom unmarshaler for ServerUpdateParameters struct.
1494func (sup *ServerUpdateParameters) UnmarshalJSON(body []byte) error {
1495	var m map[string]*json.RawMessage
1496	err := json.Unmarshal(body, &m)
1497	if err != nil {
1498		return err
1499	}
1500	for k, v := range m {
1501		switch k {
1502		case "sku":
1503			if v != nil {
1504				var sku Sku
1505				err = json.Unmarshal(*v, &sku)
1506				if err != nil {
1507					return err
1508				}
1509				sup.Sku = &sku
1510			}
1511		case "properties":
1512			if v != nil {
1513				var serverUpdateParametersProperties ServerUpdateParametersProperties
1514				err = json.Unmarshal(*v, &serverUpdateParametersProperties)
1515				if err != nil {
1516					return err
1517				}
1518				sup.ServerUpdateParametersProperties = &serverUpdateParametersProperties
1519			}
1520		case "tags":
1521			if v != nil {
1522				var tags map[string]*string
1523				err = json.Unmarshal(*v, &tags)
1524				if err != nil {
1525					return err
1526				}
1527				sup.Tags = tags
1528			}
1529		}
1530	}
1531
1532	return nil
1533}
1534
1535// ServerUpdateParametersProperties the properties that can be updated for a server.
1536type ServerUpdateParametersProperties struct {
1537	// StorageMB - The max storage allowed for a server.
1538	StorageMB *int64 `json:"storageMB,omitempty"`
1539	// AdministratorLoginPassword - The password of the administrator login.
1540	AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"`
1541	// Version - The version of a server. Possible values include: 'FiveFullStopSix', 'FiveFullStopSeven'
1542	Version ServerVersion `json:"version,omitempty"`
1543	// SslEnforcement - Enable ssl enforcement or not when connect to server. Possible values include: 'SslEnforcementEnumEnabled', 'SslEnforcementEnumDisabled'
1544	SslEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"`
1545}
1546
1547// Sku billing information related properties of a server.
1548type Sku struct {
1549	// Name - The name of the sku, typically, a letter + Number code, e.g. P3.
1550	Name *string `json:"name,omitempty"`
1551	// Tier - The tier of the particular SKU, e.g. Basic. Possible values include: 'Basic', 'Standard'
1552	Tier SkuTier `json:"tier,omitempty"`
1553	// Capacity - The scale up/out capacity, representing server's compute units.
1554	Capacity *int32 `json:"capacity,omitempty"`
1555	// Size - The size code, to be interpreted by resource as appropriate.
1556	Size *string `json:"size,omitempty"`
1557	// Family - The family of hardware.
1558	Family *string `json:"family,omitempty"`
1559}
1560
1561// TrackedResource resource properties including location and tags for track resources.
1562type TrackedResource struct {
1563	// Location - The location the resource resides in.
1564	Location *string `json:"location,omitempty"`
1565	// Tags - Application-specific metadata in the form of key-value pairs.
1566	Tags map[string]*string `json:"tags"`
1567	// ID - Resource ID
1568	ID *string `json:"id,omitempty"`
1569	// Name - Resource name.
1570	Name *string `json:"name,omitempty"`
1571	// Type - Resource type.
1572	Type *string `json:"type,omitempty"`
1573}
1574
1575// MarshalJSON is the custom marshaler for TrackedResource.
1576func (tr TrackedResource) MarshalJSON() ([]byte, error) {
1577	objectMap := make(map[string]interface{})
1578	if tr.Location != nil {
1579		objectMap["location"] = tr.Location
1580	}
1581	if tr.Tags != nil {
1582		objectMap["tags"] = tr.Tags
1583	}
1584	if tr.ID != nil {
1585		objectMap["id"] = tr.ID
1586	}
1587	if tr.Name != nil {
1588		objectMap["name"] = tr.Name
1589	}
1590	if tr.Type != nil {
1591		objectMap["type"] = tr.Type
1592	}
1593	return json.Marshal(objectMap)
1594}
1595