1package azurestackhci
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/date"
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/azurestackhci/mgmt/2020-10-01/azurestackhci"
32
33// AvailableOperations available operations of the service
34type AvailableOperations struct {
35	autorest.Response `json:"-"`
36	// Value - Collection of available operation details
37	Value *[]OperationDetail `json:"value,omitempty"`
38	// NextLink - URL client should use to fetch the next page (per server side paging).
39	// It's null for now, added for future use.
40	NextLink *string `json:"nextLink,omitempty"`
41}
42
43// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag.
44type AzureEntityResource struct {
45	// Etag - READ-ONLY; Resource Etag.
46	Etag *string `json:"etag,omitempty"`
47	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
48	ID *string `json:"id,omitempty"`
49	// Name - READ-ONLY; The name of the resource
50	Name *string `json:"name,omitempty"`
51	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
52	Type *string `json:"type,omitempty"`
53}
54
55// Cluster cluster details.
56type Cluster struct {
57	autorest.Response `json:"-"`
58	// ClusterProperties - Cluster properties.
59	*ClusterProperties `json:"properties,omitempty"`
60	// Tags - Resource tags.
61	Tags map[string]*string `json:"tags"`
62	// Location - The geo-location where the resource lives
63	Location *string `json:"location,omitempty"`
64	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
65	ID *string `json:"id,omitempty"`
66	// Name - READ-ONLY; The name of the resource
67	Name *string `json:"name,omitempty"`
68	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
69	Type *string `json:"type,omitempty"`
70}
71
72// MarshalJSON is the custom marshaler for Cluster.
73func (c Cluster) MarshalJSON() ([]byte, error) {
74	objectMap := make(map[string]interface{})
75	if c.ClusterProperties != nil {
76		objectMap["properties"] = c.ClusterProperties
77	}
78	if c.Tags != nil {
79		objectMap["tags"] = c.Tags
80	}
81	if c.Location != nil {
82		objectMap["location"] = c.Location
83	}
84	return json.Marshal(objectMap)
85}
86
87// UnmarshalJSON is the custom unmarshaler for Cluster struct.
88func (c *Cluster) UnmarshalJSON(body []byte) error {
89	var m map[string]*json.RawMessage
90	err := json.Unmarshal(body, &m)
91	if err != nil {
92		return err
93	}
94	for k, v := range m {
95		switch k {
96		case "properties":
97			if v != nil {
98				var clusterProperties ClusterProperties
99				err = json.Unmarshal(*v, &clusterProperties)
100				if err != nil {
101					return err
102				}
103				c.ClusterProperties = &clusterProperties
104			}
105		case "tags":
106			if v != nil {
107				var tags map[string]*string
108				err = json.Unmarshal(*v, &tags)
109				if err != nil {
110					return err
111				}
112				c.Tags = tags
113			}
114		case "location":
115			if v != nil {
116				var location string
117				err = json.Unmarshal(*v, &location)
118				if err != nil {
119					return err
120				}
121				c.Location = &location
122			}
123		case "id":
124			if v != nil {
125				var ID string
126				err = json.Unmarshal(*v, &ID)
127				if err != nil {
128					return err
129				}
130				c.ID = &ID
131			}
132		case "name":
133			if v != nil {
134				var name string
135				err = json.Unmarshal(*v, &name)
136				if err != nil {
137					return err
138				}
139				c.Name = &name
140			}
141		case "type":
142			if v != nil {
143				var typeVar string
144				err = json.Unmarshal(*v, &typeVar)
145				if err != nil {
146					return err
147				}
148				c.Type = &typeVar
149			}
150		}
151	}
152
153	return nil
154}
155
156// ClusterList list of clusters.
157type ClusterList struct {
158	autorest.Response `json:"-"`
159	// Value - List of clusters.
160	Value *[]Cluster `json:"value,omitempty"`
161	// NextLink - READ-ONLY; Link to the next set of results.
162	NextLink *string `json:"nextLink,omitempty"`
163}
164
165// MarshalJSON is the custom marshaler for ClusterList.
166func (cl ClusterList) MarshalJSON() ([]byte, error) {
167	objectMap := make(map[string]interface{})
168	if cl.Value != nil {
169		objectMap["value"] = cl.Value
170	}
171	return json.Marshal(objectMap)
172}
173
174// ClusterListIterator provides access to a complete listing of Cluster values.
175type ClusterListIterator struct {
176	i    int
177	page ClusterListPage
178}
179
180// NextWithContext advances to the next value.  If there was an error making
181// the request the iterator does not advance and the error is returned.
182func (iter *ClusterListIterator) NextWithContext(ctx context.Context) (err error) {
183	if tracing.IsEnabled() {
184		ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListIterator.NextWithContext")
185		defer func() {
186			sc := -1
187			if iter.Response().Response.Response != nil {
188				sc = iter.Response().Response.Response.StatusCode
189			}
190			tracing.EndSpan(ctx, sc, err)
191		}()
192	}
193	iter.i++
194	if iter.i < len(iter.page.Values()) {
195		return nil
196	}
197	err = iter.page.NextWithContext(ctx)
198	if err != nil {
199		iter.i--
200		return err
201	}
202	iter.i = 0
203	return nil
204}
205
206// Next advances to the next value.  If there was an error making
207// the request the iterator does not advance and the error is returned.
208// Deprecated: Use NextWithContext() instead.
209func (iter *ClusterListIterator) Next() error {
210	return iter.NextWithContext(context.Background())
211}
212
213// NotDone returns true if the enumeration should be started or is not yet complete.
214func (iter ClusterListIterator) NotDone() bool {
215	return iter.page.NotDone() && iter.i < len(iter.page.Values())
216}
217
218// Response returns the raw server response from the last page request.
219func (iter ClusterListIterator) Response() ClusterList {
220	return iter.page.Response()
221}
222
223// Value returns the current value or a zero-initialized value if the
224// iterator has advanced beyond the end of the collection.
225func (iter ClusterListIterator) Value() Cluster {
226	if !iter.page.NotDone() {
227		return Cluster{}
228	}
229	return iter.page.Values()[iter.i]
230}
231
232// Creates a new instance of the ClusterListIterator type.
233func NewClusterListIterator(page ClusterListPage) ClusterListIterator {
234	return ClusterListIterator{page: page}
235}
236
237// IsEmpty returns true if the ListResult contains no values.
238func (cl ClusterList) IsEmpty() bool {
239	return cl.Value == nil || len(*cl.Value) == 0
240}
241
242// hasNextLink returns true if the NextLink is not empty.
243func (cl ClusterList) hasNextLink() bool {
244	return cl.NextLink != nil && len(*cl.NextLink) != 0
245}
246
247// clusterListPreparer prepares a request to retrieve the next set of results.
248// It returns nil if no more results exist.
249func (cl ClusterList) clusterListPreparer(ctx context.Context) (*http.Request, error) {
250	if !cl.hasNextLink() {
251		return nil, nil
252	}
253	return autorest.Prepare((&http.Request{}).WithContext(ctx),
254		autorest.AsJSON(),
255		autorest.AsGet(),
256		autorest.WithBaseURL(to.String(cl.NextLink)))
257}
258
259// ClusterListPage contains a page of Cluster values.
260type ClusterListPage struct {
261	fn func(context.Context, ClusterList) (ClusterList, error)
262	cl ClusterList
263}
264
265// NextWithContext advances to the next page of values.  If there was an error making
266// the request the page does not advance and the error is returned.
267func (page *ClusterListPage) NextWithContext(ctx context.Context) (err error) {
268	if tracing.IsEnabled() {
269		ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListPage.NextWithContext")
270		defer func() {
271			sc := -1
272			if page.Response().Response.Response != nil {
273				sc = page.Response().Response.Response.StatusCode
274			}
275			tracing.EndSpan(ctx, sc, err)
276		}()
277	}
278	for {
279		next, err := page.fn(ctx, page.cl)
280		if err != nil {
281			return err
282		}
283		page.cl = next
284		if !next.hasNextLink() || !next.IsEmpty() {
285			break
286		}
287	}
288	return nil
289}
290
291// Next advances to the next page of values.  If there was an error making
292// the request the page does not advance and the error is returned.
293// Deprecated: Use NextWithContext() instead.
294func (page *ClusterListPage) Next() error {
295	return page.NextWithContext(context.Background())
296}
297
298// NotDone returns true if the page enumeration should be started or is not yet complete.
299func (page ClusterListPage) NotDone() bool {
300	return !page.cl.IsEmpty()
301}
302
303// Response returns the raw server response from the last page request.
304func (page ClusterListPage) Response() ClusterList {
305	return page.cl
306}
307
308// Values returns the slice of values for the current page or nil if there are no values.
309func (page ClusterListPage) Values() []Cluster {
310	if page.cl.IsEmpty() {
311		return nil
312	}
313	return *page.cl.Value
314}
315
316// Creates a new instance of the ClusterListPage type.
317func NewClusterListPage(cur ClusterList, getNextPage func(context.Context, ClusterList) (ClusterList, error)) ClusterListPage {
318	return ClusterListPage{
319		fn: getNextPage,
320		cl: cur,
321	}
322}
323
324// ClusterNode cluster node details.
325type ClusterNode struct {
326	// Name - READ-ONLY; Name of the cluster node.
327	Name *string `json:"name,omitempty"`
328	// ID - READ-ONLY; Id of the node in the cluster.
329	ID *float64 `json:"id,omitempty"`
330	// Manufacturer - READ-ONLY; Manufacturer of the cluster node hardware.
331	Manufacturer *string `json:"manufacturer,omitempty"`
332	// Model - READ-ONLY; Model name of the cluster node hardware.
333	Model *string `json:"model,omitempty"`
334	// OsName - READ-ONLY; Operating system running on the cluster node.
335	OsName *string `json:"osName,omitempty"`
336	// OsVersion - READ-ONLY; Version of the operating system running on the cluster node.
337	OsVersion *string `json:"osVersion,omitempty"`
338	// SerialNumber - READ-ONLY; Immutable id of the cluster node.
339	SerialNumber *string `json:"serialNumber,omitempty"`
340	// CoreCount - READ-ONLY; Number of physical cores on the cluster node.
341	CoreCount *float64 `json:"coreCount,omitempty"`
342	// MemoryInGiB - READ-ONLY; Total available memory on the cluster node (in GiB).
343	MemoryInGiB *float64 `json:"memoryInGiB,omitempty"`
344}
345
346// ClusterProperties cluster properties.
347type ClusterProperties struct {
348	// ProvisioningState - READ-ONLY; Provisioning state. Possible values include: 'Succeeded', 'Failed', 'Canceled', 'Accepted', 'Provisioning'
349	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
350	// Status - READ-ONLY; Status of the cluster agent. Possible values include: 'NotYetRegistered', 'ConnectedRecently', 'NotConnectedRecently', 'Disconnected', 'Error'
351	Status Status `json:"status,omitempty"`
352	// CloudID - READ-ONLY; Unique, immutable resource id.
353	CloudID *string `json:"cloudId,omitempty"`
354	// AadClientID - App id of cluster AAD identity.
355	AadClientID *string `json:"aadClientId,omitempty"`
356	// AadTenantID - Tenant id of cluster AAD identity.
357	AadTenantID *string `json:"aadTenantId,omitempty"`
358	// ReportedProperties - Properties reported by cluster agent.
359	ReportedProperties *ClusterReportedProperties `json:"reportedProperties,omitempty"`
360	// TrialDaysRemaining - READ-ONLY; Number of days remaining in the trial period.
361	TrialDaysRemaining *float64 `json:"trialDaysRemaining,omitempty"`
362	// BillingModel - READ-ONLY; Type of billing applied to the resource.
363	BillingModel *string `json:"billingModel,omitempty"`
364	// RegistrationTimestamp - READ-ONLY; First cluster sync timestamp.
365	RegistrationTimestamp *date.Time `json:"registrationTimestamp,omitempty"`
366	// LastSyncTimestamp - READ-ONLY; Most recent cluster sync timestamp.
367	LastSyncTimestamp *date.Time `json:"lastSyncTimestamp,omitempty"`
368	// LastBillingTimestamp - READ-ONLY; Most recent billing meter timestamp.
369	LastBillingTimestamp *date.Time `json:"lastBillingTimestamp,omitempty"`
370}
371
372// MarshalJSON is the custom marshaler for ClusterProperties.
373func (cp ClusterProperties) MarshalJSON() ([]byte, error) {
374	objectMap := make(map[string]interface{})
375	if cp.AadClientID != nil {
376		objectMap["aadClientId"] = cp.AadClientID
377	}
378	if cp.AadTenantID != nil {
379		objectMap["aadTenantId"] = cp.AadTenantID
380	}
381	if cp.ReportedProperties != nil {
382		objectMap["reportedProperties"] = cp.ReportedProperties
383	}
384	return json.Marshal(objectMap)
385}
386
387// ClusterReportedProperties properties reported by cluster agent.
388type ClusterReportedProperties struct {
389	// ClusterName - READ-ONLY; Name of the on-prem cluster connected to this resource.
390	ClusterName *string `json:"clusterName,omitempty"`
391	// ClusterID - READ-ONLY; Unique id generated by the on-prem cluster.
392	ClusterID *string `json:"clusterId,omitempty"`
393	// ClusterVersion - READ-ONLY; Version of the cluster software.
394	ClusterVersion *string `json:"clusterVersion,omitempty"`
395	// Nodes - READ-ONLY; List of nodes reported by the cluster.
396	Nodes *[]ClusterNode `json:"nodes,omitempty"`
397	// LastUpdated - READ-ONLY; Last time the cluster reported the data.
398	LastUpdated *date.Time `json:"lastUpdated,omitempty"`
399}
400
401// ClusterUpdate cluster details to update.
402type ClusterUpdate struct {
403	// Tags - Resource tags.
404	Tags map[string]*string `json:"tags"`
405}
406
407// MarshalJSON is the custom marshaler for ClusterUpdate.
408func (cu ClusterUpdate) MarshalJSON() ([]byte, error) {
409	objectMap := make(map[string]interface{})
410	if cu.Tags != nil {
411		objectMap["tags"] = cu.Tags
412	}
413	return json.Marshal(objectMap)
414}
415
416// ErrorAdditionalInfo the resource management error additional info.
417type ErrorAdditionalInfo struct {
418	// Type - READ-ONLY; The additional info type.
419	Type *string `json:"type,omitempty"`
420	// Info - READ-ONLY; The additional info.
421	Info interface{} `json:"info,omitempty"`
422}
423
424// ErrorDetail the error detail.
425type ErrorDetail struct {
426	// Code - READ-ONLY; The error code.
427	Code *string `json:"code,omitempty"`
428	// Message - READ-ONLY; The error message.
429	Message *string `json:"message,omitempty"`
430	// Target - READ-ONLY; The error target.
431	Target *string `json:"target,omitempty"`
432	// Details - READ-ONLY; The error details.
433	Details *[]ErrorDetail `json:"details,omitempty"`
434	// AdditionalInfo - READ-ONLY; The error additional info.
435	AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"`
436}
437
438// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for
439// failed operations. (This also follows the OData error response format.).
440type ErrorResponse struct {
441	// Error - The error object.
442	Error *ErrorDetail `json:"error,omitempty"`
443}
444
445// OperationDetail operation detail payload
446type OperationDetail struct {
447	// Name - Name of the operation
448	Name *string `json:"name,omitempty"`
449	// IsDataAction - Indicates whether the operation is a data action
450	IsDataAction *bool `json:"isDataAction,omitempty"`
451	// Display - Display of the operation
452	Display *OperationDisplay `json:"display,omitempty"`
453	// Origin - Origin of the operation
454	Origin *string `json:"origin,omitempty"`
455	// Properties - Properties of the operation
456	Properties interface{} `json:"properties,omitempty"`
457}
458
459// OperationDisplay operation display payload
460type OperationDisplay struct {
461	// Provider - Resource provider of the operation
462	Provider *string `json:"provider,omitempty"`
463	// Resource - Resource of the operation
464	Resource *string `json:"resource,omitempty"`
465	// Operation - Localized friendly name for the operation
466	Operation *string `json:"operation,omitempty"`
467	// Description - Localized friendly description for the operation
468	Description *string `json:"description,omitempty"`
469}
470
471// ProxyResource the resource model definition for an Azure Resource Manager proxy resource. It will have
472// everything other than required location and tags
473type ProxyResource struct {
474	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
475	ID *string `json:"id,omitempty"`
476	// Name - READ-ONLY; The name of the resource
477	Name *string `json:"name,omitempty"`
478	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
479	Type *string `json:"type,omitempty"`
480}
481
482// Resource common fields that are returned in the response for all Azure Resource Manager resources
483type Resource struct {
484	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
485	ID *string `json:"id,omitempty"`
486	// Name - READ-ONLY; The name of the resource
487	Name *string `json:"name,omitempty"`
488	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
489	Type *string `json:"type,omitempty"`
490}
491
492// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource
493type TrackedResource struct {
494	// Tags - Resource tags.
495	Tags map[string]*string `json:"tags"`
496	// Location - The geo-location where the resource lives
497	Location *string `json:"location,omitempty"`
498	// ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
499	ID *string `json:"id,omitempty"`
500	// Name - READ-ONLY; The name of the resource
501	Name *string `json:"name,omitempty"`
502	// Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
503	Type *string `json:"type,omitempty"`
504}
505
506// MarshalJSON is the custom marshaler for TrackedResource.
507func (tr TrackedResource) MarshalJSON() ([]byte, error) {
508	objectMap := make(map[string]interface{})
509	if tr.Tags != nil {
510		objectMap["tags"] = tr.Tags
511	}
512	if tr.Location != nil {
513		objectMap["location"] = tr.Location
514	}
515	return json.Marshal(objectMap)
516}
517