1package containerservice
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	"context"
22	"encoding/json"
23	"github.com/Azure/go-autorest/autorest"
24	"github.com/Azure/go-autorest/autorest/azure"
25	"github.com/Azure/go-autorest/autorest/to"
26	"github.com/Azure/go-autorest/tracing"
27	"net/http"
28)
29
30// The package's fully qualified name.
31const fqdn = "github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2016-09-30/containerservice"
32
33// AgentPoolProfile profile for the container service agent pool.
34type AgentPoolProfile struct {
35	// Name - Unique name of the agent pool profile in the context of the subscription and resource group.
36	Name *string `json:"name,omitempty"`
37	// Count - Number of agents (VMs) to host docker containers. Allowed values must be in the range of 1 to 100 (inclusive). The default value is 1.
38	Count *int32 `json:"count,omitempty"`
39	// VMSize - Size of agent VMs. Possible values include: 'StandardA0', 'StandardA1', 'StandardA2', 'StandardA3', 'StandardA4', 'StandardA5', 'StandardA6', 'StandardA7', 'StandardA8', 'StandardA9', 'StandardA10', 'StandardA11', 'StandardD1', 'StandardD2', 'StandardD3', 'StandardD4', 'StandardD11', 'StandardD12', 'StandardD13', 'StandardD14', 'StandardD1V2', 'StandardD2V2', 'StandardD3V2', 'StandardD4V2', 'StandardD5V2', 'StandardD11V2', 'StandardD12V2', 'StandardD13V2', 'StandardD14V2', 'StandardG1', 'StandardG2', 'StandardG3', 'StandardG4', 'StandardG5', 'StandardDS1', 'StandardDS2', 'StandardDS3', 'StandardDS4', 'StandardDS11', 'StandardDS12', 'StandardDS13', 'StandardDS14', 'StandardGS1', 'StandardGS2', 'StandardGS3', 'StandardGS4', 'StandardGS5'
40	VMSize VMSizeTypes `json:"vmSize,omitempty"`
41	// DNSPrefix - DNS prefix to be used to create the FQDN for the agent pool.
42	DNSPrefix *string `json:"dnsPrefix,omitempty"`
43	// Fqdn - READ-ONLY; FQDN for the agent pool.
44	Fqdn *string `json:"fqdn,omitempty"`
45}
46
47// MarshalJSON is the custom marshaler for AgentPoolProfile.
48func (app AgentPoolProfile) MarshalJSON() ([]byte, error) {
49	objectMap := make(map[string]interface{})
50	if app.Name != nil {
51		objectMap["name"] = app.Name
52	}
53	if app.Count != nil {
54		objectMap["count"] = app.Count
55	}
56	if app.VMSize != "" {
57		objectMap["vmSize"] = app.VMSize
58	}
59	if app.DNSPrefix != nil {
60		objectMap["dnsPrefix"] = app.DNSPrefix
61	}
62	return json.Marshal(objectMap)
63}
64
65// ContainerService container service.
66type ContainerService struct {
67	autorest.Response `json:"-"`
68	*Properties       `json:"properties,omitempty"`
69	// ID - READ-ONLY; Resource Id
70	ID *string `json:"id,omitempty"`
71	// Name - READ-ONLY; Resource name
72	Name *string `json:"name,omitempty"`
73	// Type - READ-ONLY; Resource type
74	Type *string `json:"type,omitempty"`
75	// Location - Resource location
76	Location *string `json:"location,omitempty"`
77	// Tags - Resource tags
78	Tags map[string]*string `json:"tags"`
79}
80
81// MarshalJSON is the custom marshaler for ContainerService.
82func (cs ContainerService) MarshalJSON() ([]byte, error) {
83	objectMap := make(map[string]interface{})
84	if cs.Properties != nil {
85		objectMap["properties"] = cs.Properties
86	}
87	if cs.Location != nil {
88		objectMap["location"] = cs.Location
89	}
90	if cs.Tags != nil {
91		objectMap["tags"] = cs.Tags
92	}
93	return json.Marshal(objectMap)
94}
95
96// UnmarshalJSON is the custom unmarshaler for ContainerService struct.
97func (cs *ContainerService) UnmarshalJSON(body []byte) error {
98	var m map[string]*json.RawMessage
99	err := json.Unmarshal(body, &m)
100	if err != nil {
101		return err
102	}
103	for k, v := range m {
104		switch k {
105		case "properties":
106			if v != nil {
107				var properties Properties
108				err = json.Unmarshal(*v, &properties)
109				if err != nil {
110					return err
111				}
112				cs.Properties = &properties
113			}
114		case "id":
115			if v != nil {
116				var ID string
117				err = json.Unmarshal(*v, &ID)
118				if err != nil {
119					return err
120				}
121				cs.ID = &ID
122			}
123		case "name":
124			if v != nil {
125				var name string
126				err = json.Unmarshal(*v, &name)
127				if err != nil {
128					return err
129				}
130				cs.Name = &name
131			}
132		case "type":
133			if v != nil {
134				var typeVar string
135				err = json.Unmarshal(*v, &typeVar)
136				if err != nil {
137					return err
138				}
139				cs.Type = &typeVar
140			}
141		case "location":
142			if v != nil {
143				var location string
144				err = json.Unmarshal(*v, &location)
145				if err != nil {
146					return err
147				}
148				cs.Location = &location
149			}
150		case "tags":
151			if v != nil {
152				var tags map[string]*string
153				err = json.Unmarshal(*v, &tags)
154				if err != nil {
155					return err
156				}
157				cs.Tags = tags
158			}
159		}
160	}
161
162	return nil
163}
164
165// ContainerServicesCreateOrUpdateFutureType an abstraction for monitoring and retrieving the results of a
166// long-running operation.
167type ContainerServicesCreateOrUpdateFutureType struct {
168	azure.FutureAPI
169	// Result returns the result of the asynchronous operation.
170	// If the operation has not completed it will return an error.
171	Result func(ContainerServicesClient) (ContainerService, error)
172}
173
174// ContainerServicesDeleteFutureType an abstraction for monitoring and retrieving the results of a
175// long-running operation.
176type ContainerServicesDeleteFutureType struct {
177	azure.FutureAPI
178	// Result returns the result of the asynchronous operation.
179	// If the operation has not completed it will return an error.
180	Result func(ContainerServicesClient) (autorest.Response, error)
181}
182
183// CustomProfile properties to configure a custom container service cluster.
184type CustomProfile struct {
185	// Orchestrator - The name of the custom orchestrator to use.
186	Orchestrator *string `json:"orchestrator,omitempty"`
187}
188
189// DiagnosticsProfile ...
190type DiagnosticsProfile struct {
191	// VMDiagnostics - Profile for the container service VM diagnostic agent.
192	VMDiagnostics *VMDiagnostics `json:"vmDiagnostics,omitempty"`
193}
194
195// LinuxProfile profile for Linux VMs in the container service cluster.
196type LinuxProfile struct {
197	// AdminUsername - The administrator username to use for Linux VMs.
198	AdminUsername *string `json:"adminUsername,omitempty"`
199	// SSH - The ssh key configuration for Linux VMs.
200	SSH *SSHConfiguration `json:"ssh,omitempty"`
201}
202
203// ListResult the response from the List Container Services operation.
204type ListResult struct {
205	autorest.Response `json:"-"`
206	// Value - the list of container services.
207	Value *[]ContainerService `json:"value,omitempty"`
208	// NextLink - The URL to get the next set of container service results.
209	NextLink *string `json:"nextLink,omitempty"`
210}
211
212// ListResultIterator provides access to a complete listing of ContainerService values.
213type ListResultIterator struct {
214	i    int
215	page ListResultPage
216}
217
218// NextWithContext advances to the next value.  If there was an error making
219// the request the iterator does not advance and the error is returned.
220func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) {
221	if tracing.IsEnabled() {
222		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext")
223		defer func() {
224			sc := -1
225			if iter.Response().Response.Response != nil {
226				sc = iter.Response().Response.Response.StatusCode
227			}
228			tracing.EndSpan(ctx, sc, err)
229		}()
230	}
231	iter.i++
232	if iter.i < len(iter.page.Values()) {
233		return nil
234	}
235	err = iter.page.NextWithContext(ctx)
236	if err != nil {
237		iter.i--
238		return err
239	}
240	iter.i = 0
241	return nil
242}
243
244// Next advances to the next value.  If there was an error making
245// the request the iterator does not advance and the error is returned.
246// Deprecated: Use NextWithContext() instead.
247func (iter *ListResultIterator) Next() error {
248	return iter.NextWithContext(context.Background())
249}
250
251// NotDone returns true if the enumeration should be started or is not yet complete.
252func (iter ListResultIterator) NotDone() bool {
253	return iter.page.NotDone() && iter.i < len(iter.page.Values())
254}
255
256// Response returns the raw server response from the last page request.
257func (iter ListResultIterator) Response() ListResult {
258	return iter.page.Response()
259}
260
261// Value returns the current value or a zero-initialized value if the
262// iterator has advanced beyond the end of the collection.
263func (iter ListResultIterator) Value() ContainerService {
264	if !iter.page.NotDone() {
265		return ContainerService{}
266	}
267	return iter.page.Values()[iter.i]
268}
269
270// Creates a new instance of the ListResultIterator type.
271func NewListResultIterator(page ListResultPage) ListResultIterator {
272	return ListResultIterator{page: page}
273}
274
275// IsEmpty returns true if the ListResult contains no values.
276func (lr ListResult) IsEmpty() bool {
277	return lr.Value == nil || len(*lr.Value) == 0
278}
279
280// hasNextLink returns true if the NextLink is not empty.
281func (lr ListResult) hasNextLink() bool {
282	return lr.NextLink != nil && len(*lr.NextLink) != 0
283}
284
285// listResultPreparer prepares a request to retrieve the next set of results.
286// It returns nil if no more results exist.
287func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) {
288	if !lr.hasNextLink() {
289		return nil, nil
290	}
291	return autorest.Prepare((&http.Request{}).WithContext(ctx),
292		autorest.AsJSON(),
293		autorest.AsGet(),
294		autorest.WithBaseURL(to.String(lr.NextLink)))
295}
296
297// ListResultPage contains a page of ContainerService values.
298type ListResultPage struct {
299	fn func(context.Context, ListResult) (ListResult, error)
300	lr ListResult
301}
302
303// NextWithContext advances to the next page of values.  If there was an error making
304// the request the page does not advance and the error is returned.
305func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) {
306	if tracing.IsEnabled() {
307		ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext")
308		defer func() {
309			sc := -1
310			if page.Response().Response.Response != nil {
311				sc = page.Response().Response.Response.StatusCode
312			}
313			tracing.EndSpan(ctx, sc, err)
314		}()
315	}
316	for {
317		next, err := page.fn(ctx, page.lr)
318		if err != nil {
319			return err
320		}
321		page.lr = next
322		if !next.hasNextLink() || !next.IsEmpty() {
323			break
324		}
325	}
326	return nil
327}
328
329// Next advances to the next page of values.  If there was an error making
330// the request the page does not advance and the error is returned.
331// Deprecated: Use NextWithContext() instead.
332func (page *ListResultPage) Next() error {
333	return page.NextWithContext(context.Background())
334}
335
336// NotDone returns true if the page enumeration should be started or is not yet complete.
337func (page ListResultPage) NotDone() bool {
338	return !page.lr.IsEmpty()
339}
340
341// Response returns the raw server response from the last page request.
342func (page ListResultPage) Response() ListResult {
343	return page.lr
344}
345
346// Values returns the slice of values for the current page or nil if there are no values.
347func (page ListResultPage) Values() []ContainerService {
348	if page.lr.IsEmpty() {
349		return nil
350	}
351	return *page.lr.Value
352}
353
354// Creates a new instance of the ListResultPage type.
355func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
356	return ListResultPage{
357		fn: getNextPage,
358		lr: cur,
359	}
360}
361
362// MasterProfile profile for the container service master.
363type MasterProfile struct {
364	// Count - Number of masters (VMs) in the container service cluster. Allowed values are 1, 3, and 5. The default value is 1.
365	Count *int32 `json:"count,omitempty"`
366	// DNSPrefix - DNS prefix to be used to create the FQDN for master.
367	DNSPrefix *string `json:"dnsPrefix,omitempty"`
368	// Fqdn - READ-ONLY; FQDN for the master.
369	Fqdn *string `json:"fqdn,omitempty"`
370}
371
372// MarshalJSON is the custom marshaler for MasterProfile.
373func (mp MasterProfile) MarshalJSON() ([]byte, error) {
374	objectMap := make(map[string]interface{})
375	if mp.Count != nil {
376		objectMap["count"] = mp.Count
377	}
378	if mp.DNSPrefix != nil {
379		objectMap["dnsPrefix"] = mp.DNSPrefix
380	}
381	return json.Marshal(objectMap)
382}
383
384// OrchestratorProfile profile for the container service orchestrator.
385type OrchestratorProfile struct {
386	// OrchestratorType - The orchestrator to use to manage container service cluster resources. Valid values are Swarm, DCOS, and Custom. Possible values include: 'Swarm', 'DCOS', 'Custom', 'Kubernetes'
387	OrchestratorType OchestratorTypes `json:"orchestratorType,omitempty"`
388}
389
390// Properties properties of the container service.
391type Properties struct {
392	// ProvisioningState - READ-ONLY; the current deployment or provisioning state, which only appears in the response.
393	ProvisioningState *string `json:"provisioningState,omitempty"`
394	// OrchestratorProfile - Properties of the orchestrator.
395	OrchestratorProfile *OrchestratorProfile `json:"orchestratorProfile,omitempty"`
396	// CustomProfile - Properties for custom clusters.
397	CustomProfile *CustomProfile `json:"customProfile,omitempty"`
398	// ServicePrincipalProfile - Properties for cluster service principals.
399	ServicePrincipalProfile *ServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"`
400	// MasterProfile - Properties of master agents.
401	MasterProfile *MasterProfile `json:"masterProfile,omitempty"`
402	// AgentPoolProfiles - Properties of the agent pool.
403	AgentPoolProfiles *[]AgentPoolProfile `json:"agentPoolProfiles,omitempty"`
404	// WindowsProfile - Properties of Windows VMs.
405	WindowsProfile *WindowsProfile `json:"windowsProfile,omitempty"`
406	// LinuxProfile - Properties of Linux VMs.
407	LinuxProfile *LinuxProfile `json:"linuxProfile,omitempty"`
408	// DiagnosticsProfile - Properties of the diagnostic agent.
409	DiagnosticsProfile *DiagnosticsProfile `json:"diagnosticsProfile,omitempty"`
410}
411
412// MarshalJSON is the custom marshaler for Properties.
413func (p Properties) MarshalJSON() ([]byte, error) {
414	objectMap := make(map[string]interface{})
415	if p.OrchestratorProfile != nil {
416		objectMap["orchestratorProfile"] = p.OrchestratorProfile
417	}
418	if p.CustomProfile != nil {
419		objectMap["customProfile"] = p.CustomProfile
420	}
421	if p.ServicePrincipalProfile != nil {
422		objectMap["servicePrincipalProfile"] = p.ServicePrincipalProfile
423	}
424	if p.MasterProfile != nil {
425		objectMap["masterProfile"] = p.MasterProfile
426	}
427	if p.AgentPoolProfiles != nil {
428		objectMap["agentPoolProfiles"] = p.AgentPoolProfiles
429	}
430	if p.WindowsProfile != nil {
431		objectMap["windowsProfile"] = p.WindowsProfile
432	}
433	if p.LinuxProfile != nil {
434		objectMap["linuxProfile"] = p.LinuxProfile
435	}
436	if p.DiagnosticsProfile != nil {
437		objectMap["diagnosticsProfile"] = p.DiagnosticsProfile
438	}
439	return json.Marshal(objectMap)
440}
441
442// Resource the Resource model definition.
443type Resource struct {
444	// ID - READ-ONLY; Resource Id
445	ID *string `json:"id,omitempty"`
446	// Name - READ-ONLY; Resource name
447	Name *string `json:"name,omitempty"`
448	// Type - READ-ONLY; Resource type
449	Type *string `json:"type,omitempty"`
450	// Location - Resource location
451	Location *string `json:"location,omitempty"`
452	// Tags - Resource tags
453	Tags map[string]*string `json:"tags"`
454}
455
456// MarshalJSON is the custom marshaler for Resource.
457func (r Resource) MarshalJSON() ([]byte, error) {
458	objectMap := make(map[string]interface{})
459	if r.Location != nil {
460		objectMap["location"] = r.Location
461	}
462	if r.Tags != nil {
463		objectMap["tags"] = r.Tags
464	}
465	return json.Marshal(objectMap)
466}
467
468// ServicePrincipalProfile information about a service principal identity for the cluster to use for
469// manipulating Azure APIs.
470type ServicePrincipalProfile struct {
471	// ClientID - The ID for the service principal.
472	ClientID *string `json:"clientId,omitempty"`
473	// Secret - The secret password associated with the service principal.
474	Secret *string `json:"secret,omitempty"`
475}
476
477// SSHConfiguration SSH configuration for Linux-based VMs running on Azure.
478type SSHConfiguration struct {
479	// PublicKeys - the list of SSH public keys used to authenticate with Linux-based VMs.
480	PublicKeys *[]SSHPublicKey `json:"publicKeys,omitempty"`
481}
482
483// SSHPublicKey contains information about SSH certificate public key data.
484type SSHPublicKey struct {
485	// KeyData - Certificate public key used to authenticate with VMs through SSH. The certificate must be in PEM format with or without headers.
486	KeyData *string `json:"keyData,omitempty"`
487}
488
489// VMDiagnostics profile for diagnostics on the container service VMs.
490type VMDiagnostics struct {
491	// Enabled - Whether the VM diagnostic agent is provisioned on the VM.
492	Enabled *bool `json:"enabled,omitempty"`
493	// StorageURI - READ-ONLY; The URI of the storage account where diagnostics are stored.
494	StorageURI *string `json:"storageUri,omitempty"`
495}
496
497// MarshalJSON is the custom marshaler for VMDiagnostics.
498func (vd VMDiagnostics) MarshalJSON() ([]byte, error) {
499	objectMap := make(map[string]interface{})
500	if vd.Enabled != nil {
501		objectMap["enabled"] = vd.Enabled
502	}
503	return json.Marshal(objectMap)
504}
505
506// WindowsProfile profile for Windows VMs in the container service cluster.
507type WindowsProfile struct {
508	// AdminUsername - The administrator username to use for Windows VMs.
509	AdminUsername *string `json:"adminUsername,omitempty"`
510	// AdminPassword - The administrator password to use for Windows VMs.
511	AdminPassword *string `json:"adminPassword,omitempty"`
512}
513