1// +build go1.7
2
3package sql
4
5// Copyright 2017 Microsoft Corporation
6//
7//    Licensed under the Apache License, Version 2.0 (the "License");
8//    you may not use this file except in compliance with the License.
9//    You may obtain a copy of the License at
10//
11//        http://www.apache.org/licenses/LICENSE-2.0
12//
13//    Unless required by applicable law or agreed to in writing, software
14//    distributed under the License is distributed on an "AS IS" BASIS,
15//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16//    See the License for the specific language governing permissions and
17//    limitations under the License.
18
19import (
20	"encoding/xml"
21)
22
23// DatabaseServerCreateParams represents the set of possible parameters
24// when issuing a database server creation request to Azure.
25//
26// https://msdn.microsoft.com/en-us/library/azure/dn505699.aspx
27type DatabaseServerCreateParams struct {
28	XMLName                    xml.Name `xml:"http://schemas.microsoft.com/sqlazure/2010/12/ Server"`
29	AdministratorLogin         string
30	AdministratorLoginPassword string
31	Location                   string
32	Version                    string
33}
34
35// DatabaseServerCreateResponse represents the response following the creation of
36// a database server on Azure.
37type DatabaseServerCreateResponse struct {
38	ServerName string
39}
40
41const (
42	DatabaseServerVersion11 = "2.0"
43	DatabaseServerVersion12 = "12.0"
44)
45
46// DatabaseServer represents the set of data received from
47// a database server list operation.
48//
49// https://msdn.microsoft.com/en-us/library/azure/dn505702.aspx
50type DatabaseServer struct {
51	Name                     string
52	AdministratorLogin       string
53	Location                 string
54	FullyQualifiedDomainName string
55	Version                  string
56	State                    string
57}
58
59type ListServersResponse struct {
60	DatabaseServers []DatabaseServer `xml:"Server"`
61}
62
63// FirewallRuleCreateParams represents the set of possible
64// parameters when creating a firewall rule on an Azure database server.
65//
66// https://msdn.microsoft.com/en-us/library/azure/dn505712.aspx
67type FirewallRuleCreateParams struct {
68	XMLName        xml.Name `xml:"http://schemas.microsoft.com/windowsazure ServiceResource"`
69	Name           string
70	StartIPAddress string
71	EndIPAddress   string
72}
73
74// FirewallRuleResponse represents the set of data received from
75// an Azure database server firewall rule get response.
76//
77// https://msdn.microsoft.com/en-us/library/azure/dn505698.aspx
78type FirewallRuleResponse struct {
79	Name           string
80	StartIPAddress string
81	EndIPAddress   string
82}
83
84type ListFirewallRulesResponse struct {
85	FirewallRules []FirewallRuleResponse `xml:"ServiceResource"`
86}
87
88// FirewallRuleUpdateParams represents the set of possible
89// parameters when issuing an update of a database server firewall rule.
90//
91// https://msdn.microsoft.com/en-us/library/azure/dn505707.aspx
92type FirewallRuleUpdateParams struct {
93	XMLName        xml.Name `xml:"http://schemas.microsoft.com/windowsazure ServiceResource"`
94	Name           string
95	StartIPAddress string
96	EndIPAddress   string
97}
98
99// DatabaseCreateParams represents the set of possible parameters when issuing
100// a database creation to Azure, and reading a list response from Azure.
101//
102// https://msdn.microsoft.com/en-us/library/azure/dn505701.aspx
103type DatabaseCreateParams struct {
104	XMLName            xml.Name `xml:"http://schemas.microsoft.com/windowsazure ServiceResource"`
105	Name               string
106	Edition            string `xml:",omitempty"`
107	CollationName      string `xml:",omitempty"`
108	MaxSizeBytes       int64  `xml:",omitempty"`
109	ServiceObjectiveID string `xml:"ServiceObjectiveId,omitempty"`
110}
111
112// ServiceResource represents the set of parameters obtained from a database
113// get or list call.
114//
115// https://msdn.microsoft.com/en-us/library/azure/dn505708.aspx
116type ServiceResource struct {
117	Name               string
118	State              string
119	SelfLink           string
120	Edition            string
121	CollationName      string
122	MaxSizeBytes       int64
123	ServiceObjectiveID string `xml:"ServiceObjectiveId,omitempty"`
124}
125
126type ListDatabasesResponse struct {
127	ServiceResources []ServiceResource `xml:"ServiceResource"`
128}
129
130// ServiceResourceUpdateParams represents the set of parameters available
131// for a database service update operation.
132//
133// https://msdn.microsoft.com/en-us/library/azure/dn505718.aspx
134type ServiceResourceUpdateParams struct {
135	XMLName            xml.Name `xml:"http://schemas.microsoft.com/windowsazure ServiceResource"`
136	Name               string
137	Edition            string `xml:",omitempty"`
138	MaxSizeBytes       int64  `xml:",omitempty"`
139	ServiceObjectiveID string `xml:"ServiceObjectiveId,omitempty"`
140}
141