1// +build go1.7
2
3package virtualmachinedisk
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	"github.com/Azure/azure-sdk-for-go/services/classic/management"
23)
24
25// DiskClient is used to perform operations on Azure Disks
26type DiskClient struct {
27	client management.Client
28}
29
30// CreateDiskParameters represents a disk
31//
32// https://msdn.microsoft.com/en-us/library/azure/jj157188.aspx
33type CreateDiskParameters struct {
34	XMLName   xml.Name            `xml:"http://schemas.microsoft.com/windowsazure Disk"`
35	OS        OperatingSystemType `xml:",omitempty"`
36	Label     string
37	MediaLink string `xml:",omitempty"`
38	Name      string
39}
40
41// UpdateDiskParameters represents a disk
42//
43// https://msdn.microsoft.com/en-us/library/azure/jj157188.aspx
44type UpdateDiskParameters struct {
45	XMLName         xml.Name `xml:"http://schemas.microsoft.com/windowsazure Disk"`
46	Label           string   `xml:",omitempty"`
47	Name            string
48	ResizedSizeInGB int `xml:",omitempty"`
49}
50
51// ListDiskResponse represents a disk
52//
53// https://msdn.microsoft.com/en-us/library/azure/jj157188.aspx
54type ListDiskResponse struct {
55	XMLName xml.Name `xml:"http://schemas.microsoft.com/windowsazure Disks"`
56	Disk    []DiskResponse
57}
58
59// DiskResponse represents a disk
60//
61// https://msdn.microsoft.com/en-us/library/azure/jj157188.aspx
62type DiskResponse struct {
63	XMLName             xml.Name `xml:"http://schemas.microsoft.com/windowsazure Disk"`
64	AffinityGroup       string
65	AttachedTo          Resource
66	IsCorrupted         bool
67	OS                  OperatingSystemType
68	Location            string
69	LogicalDiskSizeInGB int
70	MediaLink           string
71	Name                string
72	SourceImageName     string
73	CreatedTime         string
74	IOType              IOType
75}
76
77// Resource describes the resource details a disk is currently attached to
78type Resource struct {
79	XMLName           xml.Name `xml:"http://schemas.microsoft.com/windowsazure AttachedTo"`
80	DeploymentName    string
81	HostedServiceName string
82	RoleName          string
83}
84
85// IOType represents an IO type
86type IOType string
87
88// These constants represent the possible IO types
89const (
90	IOTypeProvisioned IOType = "Provisioned"
91	IOTypeStandard    IOType = "Standard"
92)
93
94// OperatingSystemType represents an operating system type
95type OperatingSystemType string
96
97// These constants represent the valid operating system types
98const (
99	OperatingSystemTypeNull    OperatingSystemType = "NULL"
100	OperatingSystemTypeLinux   OperatingSystemType = "Linux"
101	OperatingSystemTypeWindows OperatingSystemType = "Windows"
102)
103
104// CreateDataDiskParameters represents a data disk
105//
106// https://msdn.microsoft.com/en-us/library/azure/jj157188.aspx
107type CreateDataDiskParameters struct {
108	XMLName             xml.Name        `xml:"http://schemas.microsoft.com/windowsazure DataVirtualHardDisk"`
109	HostCaching         HostCachingType `xml:",omitempty"`
110	DiskLabel           string          `xml:",omitempty"`
111	DiskName            string          `xml:",omitempty"`
112	Lun                 int             `xml:",omitempty"`
113	LogicalDiskSizeInGB int             `xml:",omitempty"`
114	MediaLink           string
115	SourceMediaLink     string `xml:",omitempty"`
116}
117
118// UpdateDataDiskParameters represents a data disk
119//
120// https://msdn.microsoft.com/en-us/library/azure/jj157188.aspx
121type UpdateDataDiskParameters struct {
122	XMLName     xml.Name        `xml:"http://schemas.microsoft.com/windowsazure DataVirtualHardDisk"`
123	HostCaching HostCachingType `xml:",omitempty"`
124	DiskName    string
125	Lun         int
126	MediaLink   string
127}
128
129// DataDiskResponse represents a data disk
130//
131// https://msdn.microsoft.com/en-us/library/azure/jj157188.aspx
132type DataDiskResponse struct {
133	XMLName             xml.Name `xml:"http://schemas.microsoft.com/windowsazure DataVirtualHardDisk"`
134	HostCaching         HostCachingType
135	DiskLabel           string
136	DiskName            string
137	Lun                 int
138	LogicalDiskSizeInGB int
139	MediaLink           string
140}
141
142// HostCachingType represents a host caching type
143type HostCachingType string
144
145// These constants represent the valid host caching types
146const (
147	HostCachingTypeNone      HostCachingType = "None"
148	HostCachingTypeReadOnly  HostCachingType = "ReadOnly"
149	HostCachingTypeReadWrite HostCachingType = "ReadWrite"
150)
151