1// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. 2// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. 3// Code generated. DO NOT EDIT. 4 5// Autoscaling API 6// 7// APIs for dynamically scaling Compute resources to meet application requirements. For more information about 8// autoscaling, see Autoscaling (https://docs.cloud.oracle.com/Content/Compute/Tasks/autoscalinginstancepools.htm). For information about the 9// Compute service, see Overview of the Compute Service (https://docs.cloud.oracle.com/Content/Compute/Concepts/computeoverview.htm). 10// **Note:** Autoscaling is not available in US Government Cloud tenancies. For more information, see 11// Oracle Cloud Infrastructure US Government Cloud (https://docs.cloud.oracle.com/Content/General/Concepts/govoverview.htm). 12// 13 14package autoscaling 15 16import ( 17 "encoding/json" 18 "github.com/oracle/oci-go-sdk/common" 19) 20 21// Resource A resource that is managed by an autoscaling configuration. The only supported type is "instancePool." 22// Each instance pool can have one autoscaling configuration. 23type Resource interface { 24 25 // The OCID (https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm) of the resource that is managed by the autoscaling configuration. 26 GetId() *string 27} 28 29type resource struct { 30 JsonData []byte 31 Id *string `mandatory:"true" json:"id"` 32 Type string `json:"type"` 33} 34 35// UnmarshalJSON unmarshals json 36func (m *resource) UnmarshalJSON(data []byte) error { 37 m.JsonData = data 38 type Unmarshalerresource resource 39 s := struct { 40 Model Unmarshalerresource 41 }{} 42 err := json.Unmarshal(data, &s.Model) 43 if err != nil { 44 return err 45 } 46 m.Id = s.Model.Id 47 m.Type = s.Model.Type 48 49 return err 50} 51 52// UnmarshalPolymorphicJSON unmarshals polymorphic json 53func (m *resource) UnmarshalPolymorphicJSON(data []byte) (interface{}, error) { 54 55 if data == nil || string(data) == "null" { 56 return nil, nil 57 } 58 59 var err error 60 switch m.Type { 61 case "instancePool": 62 mm := InstancePoolResource{} 63 err = json.Unmarshal(data, &mm) 64 return mm, err 65 default: 66 return *m, nil 67 } 68} 69 70//GetId returns Id 71func (m resource) GetId() *string { 72 return m.Id 73} 74 75func (m resource) String() string { 76 return common.PointerString(m) 77} 78