Modifier

Schema in Different Languages

JSON Schema File

Here provides the schema definitions as the OpenAPI specifications in JSON Schema document, which used in HCS APIs as configuration strings.

Schema Generated Code Samples

It is easy to use tools, such as Swagger CodeGen, to generate language-specific representations of the schema programming language used by a client. Swagger supports a variety of languages such as C#, Go, Javascript, and Python.

Here shows the example of generated C# and Go code for the top level VirtualMachine object

Sample of Generated C# Code

/* 
 * Schema Open API
 *
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: 2.4
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;

namespace IO.Swagger.Model
{
    /// <summary>
    /// VirtualMachine
    /// </summary>
    [DataContract]
    public partial class VirtualMachine :  IEquatable<VirtualMachine>, IValidatableObject
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="VirtualMachine" /> class.
        /// </summary>
        /// <param name="version">version.</param>
        /// <param name="stopOnReset">stopOnReset.</param>
        /// <param name="chipset">chipset.</param>
        /// <param name="computeTopology">computeTopology.</param>
        /// <param name="devices">devices.</param>
        /// <param name="services">services.</param>
        /// <param name="guestState">guestState.</param>
        /// <param name="restoreState">restoreState.</param>
        /// <param name="registryChanges">registryChanges.</param>
        /// <param name="storageQoS">storageQoS.</param>
        /// <param name="guestConnection">guestConnection.</param>
        public VirtualMachine(Version version = default(Version), bool? stopOnReset = default(bool?), Chipset chipset = default(Chipset), Topology computeTopology = default(Topology), Devices devices = default(Devices), Services services = default(Services), GuestState guestState = default(GuestState), RestoreState restoreState = default(RestoreState), RegistryChanges registryChanges = default(RegistryChanges), StorageQoS storageQoS = default(StorageQoS), GuestConnection guestConnection = default(GuestConnection))
        {
            this.Version = version;
            this.StopOnReset = stopOnReset;
            this.Chipset = chipset;
            this.ComputeTopology = computeTopology;
            this.Devices = devices;
            this.Services = services;
            this.GuestState = guestState;
            this.RestoreState = restoreState;
            this.RegistryChanges = registryChanges;
            this.StorageQoS = storageQoS;
            this.GuestConnection = guestConnection;
        }
        
        /// <summary>
        /// Gets or Sets Version
        /// </summary>
        [DataMember(Name="Version", EmitDefaultValue=false)]
        public Version Version { get; set; }

        /// <summary>
        /// Gets or Sets StopOnReset
        /// </summary>
        [DataMember(Name="StopOnReset", EmitDefaultValue=false)]
        public bool? StopOnReset { get; set; }

        /// <summary>
        /// Gets or Sets Chipset
        /// </summary>
        [DataMember(Name="Chipset", EmitDefaultValue=false)]
        public Chipset Chipset { get; set; }

        /// <summary>
        /// Gets or Sets ComputeTopology
        /// </summary>
        [DataMember(Name="ComputeTopology", EmitDefaultValue=false)]
        public Topology ComputeTopology { get; set; }

        /// <summary>
        /// Gets or Sets Devices
        /// </summary>
        [DataMember(Name="Devices", EmitDefaultValue=false)]
        public Devices Devices { get; set; }

        /// <summary>
        /// Gets or Sets Services
        /// </summary>
        [DataMember(Name="Services", EmitDefaultValue=false)]
        public Services Services { get; set; }

        /// <summary>
        /// Gets or Sets GuestState
        /// </summary>
        [DataMember(Name="GuestState", EmitDefaultValue=false)]
        public GuestState GuestState { get; set; }

        /// <summary>
        /// Gets or Sets RestoreState
        /// </summary>
        [DataMember(Name="RestoreState", EmitDefaultValue=false)]
        public RestoreState RestoreState { get; set; }

        /// <summary>
        /// Gets or Sets RegistryChanges
        /// </summary>
        [DataMember(Name="RegistryChanges", EmitDefaultValue=false)]
        public RegistryChanges RegistryChanges { get; set; }

        /// <summary>
        /// Gets or Sets StorageQoS
        /// </summary>
        [DataMember(Name="StorageQoS", EmitDefaultValue=false)]
        public StorageQoS StorageQoS { get; set; }

        /// <summary>
        /// Gets or Sets GuestConnection
        /// </summary>
        [DataMember(Name="GuestConnection", EmitDefaultValue=false)]
        public GuestConnection GuestConnection { get; set; }

        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append("class VirtualMachine {\n");
            sb.Append("  Version: ").Append(Version).Append("\n");
            sb.Append("  StopOnReset: ").Append(StopOnReset).Append("\n");
            sb.Append("  Chipset: ").Append(Chipset).Append("\n");
            sb.Append("  ComputeTopology: ").Append(ComputeTopology).Append("\n");
            sb.Append("  Devices: ").Append(Devices).Append("\n");
            sb.Append("  Services: ").Append(Services).Append("\n");
            sb.Append("  GuestState: ").Append(GuestState).Append("\n");
            sb.Append("  RestoreState: ").Append(RestoreState).Append("\n");
            sb.Append("  RegistryChanges: ").Append(RegistryChanges).Append("\n");
            sb.Append("  StorageQoS: ").Append(StorageQoS).Append("\n");
            sb.Append("  GuestConnection: ").Append(GuestConnection).Append("\n");
            sb.Append("}\n");
            return sb.ToString();
        }
  
        /// <summary>
        /// Returns the JSON string presentation of the object
        /// </summary>
        /// <returns>JSON string presentation of the object</returns>
        public virtual string ToJson()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }

        /// <summary>
        /// Returns true if objects are equal
        /// </summary>
        /// <param name="input">Object to be compared</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object input)
        {
            return this.Equals(input as VirtualMachine);
        }

        /// <summary>
        /// Returns true if VirtualMachine instances are equal
        /// </summary>
        /// <param name="input">Instance of VirtualMachine to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(VirtualMachine input)
        {
            if (input == null)
                return false;

            return 
                (
                    this.Version == input.Version ||
                    (this.Version != null &&
                    this.Version.Equals(input.Version))
                ) && 
                (
                    this.StopOnReset == input.StopOnReset ||
                    (this.StopOnReset != null &&
                    this.StopOnReset.Equals(input.StopOnReset))
                ) && 
                (
                    this.Chipset == input.Chipset ||
                    (this.Chipset != null &&
                    this.Chipset.Equals(input.Chipset))
                ) && 
                (
                    this.ComputeTopology == input.ComputeTopology ||
                    (this.ComputeTopology != null &&
                    this.ComputeTopology.Equals(input.ComputeTopology))
                ) && 
                (
                    this.Devices == input.Devices ||
                    (this.Devices != null &&
                    this.Devices.Equals(input.Devices))
                ) && 
                (
                    this.Services == input.Services ||
                    (this.Services != null &&
                    this.Services.Equals(input.Services))
                ) && 
                (
                    this.GuestState == input.GuestState ||
                    (this.GuestState != null &&
                    this.GuestState.Equals(input.GuestState))
                ) && 
                (
                    this.RestoreState == input.RestoreState ||
                    (this.RestoreState != null &&
                    this.RestoreState.Equals(input.RestoreState))
                ) && 
                (
                    this.RegistryChanges == input.RegistryChanges ||
                    (this.RegistryChanges != null &&
                    this.RegistryChanges.Equals(input.RegistryChanges))
                ) && 
                (
                    this.StorageQoS == input.StorageQoS ||
                    (this.StorageQoS != null &&
                    this.StorageQoS.Equals(input.StorageQoS))
                ) && 
                (
                    this.GuestConnection == input.GuestConnection ||
                    (this.GuestConnection != null &&
                    this.GuestConnection.Equals(input.GuestConnection))
                );
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.Version != null)
                    hashCode = hashCode * 59 + this.Version.GetHashCode();
                if (this.StopOnReset != null)
                    hashCode = hashCode * 59 + this.StopOnReset.GetHashCode();
                if (this.Chipset != null)
                    hashCode = hashCode * 59 + this.Chipset.GetHashCode();
                if (this.ComputeTopology != null)
                    hashCode = hashCode * 59 + this.ComputeTopology.GetHashCode();
                if (this.Devices != null)
                    hashCode = hashCode * 59 + this.Devices.GetHashCode();
                if (this.Services != null)
                    hashCode = hashCode * 59 + this.Services.GetHashCode();
                if (this.GuestState != null)
                    hashCode = hashCode * 59 + this.GuestState.GetHashCode();
                if (this.RestoreState != null)
                    hashCode = hashCode * 59 + this.RestoreState.GetHashCode();
                if (this.RegistryChanges != null)
                    hashCode = hashCode * 59 + this.RegistryChanges.GetHashCode();
                if (this.StorageQoS != null)
                    hashCode = hashCode * 59 + this.StorageQoS.GetHashCode();
                if (this.GuestConnection != null)
                    hashCode = hashCode * 59 + this.GuestConnection.GetHashCode();
                return hashCode;
            }
        }

        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            yield break;
        }
    }

}

Sample of Generated Go Code

/*
 * Schema Open API
 *
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * API version: 2.4
 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 */

package swagger

type VirtualMachine struct {
	Version *Version `json:"Version,omitempty"`
	StopOnReset bool `json:"StopOnReset,omitempty"`
	Chipset *Chipset `json:"Chipset,omitempty"`
	ComputeTopology *Topology `json:"ComputeTopology,omitempty"`
	Devices *Devices `json:"Devices,omitempty"`
	Services *Services `json:"Services,omitempty"`
	GuestState *GuestState `json:"GuestState,omitempty"`
	RestoreState *RestoreState `json:"RestoreState,omitempty"`
	RegistryChanges *RegistryChanges `json:"RegistryChanges,omitempty"`
	StorageQoS *StorageQoS `json:"StorageQoS,omitempty"`
	GuestConnection *GuestConnection `json:"GuestConnection,omitempty"`
}