github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/apigw/v2/instances/results.go (about)

     1  package instances
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"github.com/huaweicloud/golangsdk"
     7  	"github.com/huaweicloud/golangsdk/pagination"
     8  )
     9  
    10  type commonResult struct {
    11  	golangsdk.Result
    12  }
    13  
    14  // GetResult represents the result of a create operation.
    15  type CreateResult struct {
    16  	commonResult
    17  }
    18  
    19  type CreateResp struct {
    20  	Id      string `json:"instance_id"`
    21  	Message string `json:"message"`
    22  }
    23  
    24  //Call its Extract method to interpret it as a Instance Id.
    25  func (r CreateResult) Extract() (*CreateResp, error) {
    26  	var s CreateResp
    27  	err := r.ExtractInto(&s)
    28  	return &s, err
    29  }
    30  
    31  // GetResult represents the result of a Get operation.
    32  type GetResult struct {
    33  	commonResult
    34  }
    35  
    36  // UpdateResult represents the result of a Update operation.
    37  type UpdateResult struct {
    38  	commonResult
    39  }
    40  
    41  type Instance struct {
    42  	// Instance ID.
    43  	Id string `json:"id"`
    44  	// Project ID.
    45  	ProjectId string `json:"project_id"`
    46  	// Instance name.
    47  	Name string `json:"instance_name"`
    48  	// Instance status. The value are as following:
    49  	//   Creating, CreateSuccess, CreateFail, Initing, Registering, Running, InitingFailed, RegisterFailed, Installing
    50  	//   InstallFailed, Updating, UpdateFailed, Rollbacking, RollbackSuccess, RollbackFailed, Deleting, DeleteFailed
    51  	//   Unregistering, UnRegisterFailed, CreateTimeout, InitTimeout, RegisterTimeout, InstallTimeout, UpdateTimeout
    52  	//   RollbackTimeout, DeleteTimeout, UnregisterTimeout, Starting, Freezing, Frozen, Restarting, RestartFail
    53  	//   Unhealthy, RestartTimeout
    54  	// The status 'Deleting' is not supported, it's a BUG. --2021/06/15
    55  	Status string `json:"status"`
    56  	// Instance status ID.
    57  	//   1:Creating, 2:CreateSuccess, 3:CreateFail, 4:Initing, 5:Registering, 6:Running, 7:InitingFailed
    58  	//   8:RegisterFailed, 10:Installing, 11:InstallFailed, 12:Updating, 13:UpdateFailed, 20:Rollbacking
    59  	//   21:RollbackSuccess, 22:RollbackFailed, 23:Deleting, 24:DeleteFailed, 25:Unregistering, 26:UnRegisterFailed
    60  	//   27:CreateTimeout, 28:InitTimeout, 29:RegisterTimeout, 30:InstallTimeout, 31:UpdateTimeout
    61  	//   32:RollbackTimeout, 33:DeleteTimeout, 34:UnregisterTimeout, 35:Starting, 36:Freezing, 37:Frozen, 38:Restarting
    62  	//   39:RestartFail, 40:Unhealthy, 41:RestartTimeout
    63  	// Ditto: Issue of status id 23 (Deleting). --2021/06/15
    64  	StatusId int `json:"instance_status"`
    65  	// Instance type.
    66  	Type string `json:"type"`
    67  	// Instance edition.
    68  	Edition string `json:"spec"`
    69  	// Time when the APIG dedicated instance is created, in Unix timestamp format.
    70  	CreateTimestamp int64 `json:"create_time"`
    71  	// Enterprise project ID.
    72  	EnterpriseProjectId string `json:"enterprise_project_id"`
    73  	// Billing mode of the APIG dedicated instance.
    74  	//   0:Pay per use
    75  	//   1:Pay per use
    76  	ChargeMode int `json:"charging_mode"`
    77  	// Yearly/Monthly subscription order ID.
    78  	CbcMetadata string `json:"cbc_metadata"`
    79  	// Description about the APIG dedicated instance.
    80  	Description string `json:"description"`
    81  	// VPC ID.
    82  	VpcId string `json:"vpc_id"`
    83  	// Subnet network ID.
    84  	SubnetId string `json:"subnet_id"`
    85  	// ID of the security group to which the APIG dedicated instance belongs to.
    86  	SecurityGroupId string `json:"security_group_id"`
    87  	// Start time of the maintenance time window in the format "xx:00:00".
    88  	MaintainBegin string `json:"maintain_begin"`
    89  	// End time of the maintenance time window in the format "xx:00:00".
    90  	MaintainEnd string `json:"maintain_end"`
    91  	// VPC ingress private address.
    92  	Ipv4VpcIngressAddress string `json:"ingress_ip"`
    93  	// VPC ingress private address (IPv6).
    94  	Ipv6VpcIngressAddress string `json:"ingress_ip_v6"`
    95  	// ID of the account to which the APIG dedicated instance belongs.
    96  	UserId string `json:"user_id"`
    97  	// EIP bound to the APIG dedicated instance.
    98  	Ipv4IngressEipAddress string `json:"eip_address"`
    99  	// EIP (IPv6).
   100  	Ipv6IngressEipAddress string `json:"eip_ipv6_address"`
   101  	// Public egress address (IPv6).
   102  	Ipv6EgressCidr string `json:"nat_eip_ipv6_cidr"`
   103  	// IP address for public outbound access.
   104  	Ipv4EgressAddress string `json:"nat_eip_address"`
   105  	// Outbound access bandwidth.
   106  	BandwidthSize int `json:"bandwidth_size"`
   107  	// AZs.
   108  	AvailableZoneIds string `json:"available_zone_ids"`
   109  	// Instance version.
   110  	Version string `json:"instance_version"`
   111  	// Supported features.
   112  	SupportedFeatures []string `json:"supported_features"`
   113  }
   114  
   115  // Call its Extract method to interpret it as a Instance.
   116  func (r commonResult) Extract() (*Instance, error) {
   117  	var s Instance
   118  	err := r.ExtractInto(&s)
   119  	return &s, err
   120  }
   121  
   122  type BaseInstance struct {
   123  	// Instance ID.
   124  	Id string `json:"id"`
   125  	// Project ID
   126  	ProjectId string `json:"project_id"`
   127  	// Instance name.
   128  	Name string `json:"instance_name"`
   129  	// Instance status. The value are as following:
   130  	//   Creating, CreateSuccess, CreateFail, Initing, Registering, Running, InitingFailed, RegisterFailed, Installing
   131  	//   InstallFailed, Updating, UpdateFailed, Rollbacking, RollbackSuccess, RollbackFailed, Deleting, DeleteFailed
   132  	//   Unregistering, UnRegisterFailed, CreateTimeout, InitTimeout, RegisterTimeout, InstallTimeout, UpdateTimeout
   133  	//   RollbackTimeout, DeleteTimeout, UnregisterTimeout, Starting, Freezing, Frozen, Restarting, RestartFail
   134  	//   Unhealthy, RestartTimeout
   135  	// Ditto: Issue of status 'Deleting'. --2021/06/15
   136  	Status string `json:"status"`
   137  	// Instance status ID.
   138  	//   1:Creating, 2:CreateSuccess, 3:CreateFail, 4:Initing, 5:Registering, 6:Running, 7:InitingFailed
   139  	//   8:RegisterFailed, 10:Installing, 11:InstallFailed, 12:Updating, 13:UpdateFailed, 20:Rollbacking
   140  	//   21:RollbackSuccess, 22:RollbackFailed, 23:Deleting, 24:DeleteFailed, 25:Unregistering, 26:UnRegisterFailed
   141  	//   27:CreateTimeout, 28:InitTimeout, 29:RegisterTimeout, 30:InstallTimeout, 31:UpdateTimeout
   142  	//   32:RollbackTimeout, 33:DeleteTimeout, 34:UnregisterTimeout, 35:Starting, 36:Freezing, 37:Frozen, 38:Restarting
   143  	//   39:RestartFail, 40:Unhealthy, 41:RestartTimeout
   144  	// Ditto: Issue of status id 23 (Deleting). --2021/06/15
   145  	StatusId int `json:"instance_status"`
   146  	// Instance type.
   147  	Type string `json:"type"`
   148  	// Instance edition.
   149  	Edition string `json:"spec"`
   150  	// Time when the APIG dedicated instance is created, in Unix timestamp format.
   151  	CreateTimestamp int64 `json:"create_time"`
   152  	// Enterprise project ID.
   153  	EnterpriseProjectId string `json:"enterprise_project_id"`
   154  	// EIP bound to the APIG dedicated instance.
   155  	Ipv4Address string `json:"eip_address"`
   156  	// Billing mode of the APIG dedicated instance.
   157  	//   0:Pay per use
   158  	//   1:Pay per use
   159  	ChargeMode int `json:"charging_mode"`
   160  	// Yearly/Monthly subscription order ID.
   161  	CbcMetadata string `json:"cbc_metadata"`
   162  }
   163  
   164  // InstancePage represents the result of a List operation.
   165  type InstancePage struct {
   166  	pagination.SinglePageBase
   167  }
   168  
   169  // Call its Extract method to interpret it as a BaseInstance array.
   170  func ExtractInstances(r pagination.Page) ([]BaseInstance, error) {
   171  	var s []BaseInstance
   172  	err := r.(InstancePage).Result.ExtractIntoSlicePtr(&s, "instances")
   173  	return s, err
   174  }
   175  
   176  // DeleteResult represents the result of a Delete operation.
   177  type DeleteResult struct {
   178  	golangsdk.ErrResult
   179  }
   180  
   181  // EnableEgressResult represents the result of a EnableEgressAccess operation.
   182  type EnableEgressResult struct {
   183  	EgressResult
   184  }
   185  
   186  // UdpateEgressResult represents the result of a UpdateEgressBandwidth operation.
   187  type UdpateEgressResult struct {
   188  	EgressResult
   189  }
   190  
   191  type EgressResult struct {
   192  	golangsdk.Result
   193  }
   194  
   195  type Egress struct {
   196  	Id               string `json:"id"`
   197  	CloudEipId       string `json:"cloudEipId"`
   198  	CloudEipAddress  string `json:"cloudEipAddress"`
   199  	InstanceId       string `json:"instanceId"`
   200  	CloudBandwidthId string `json:"cloudBandwidthId"`
   201  	BandwidthName    string `json:"bandwidthName"`
   202  	BandwidthSize    int    `json:"bandwidthSize"`
   203  }
   204  
   205  // Call its Extract method to interpret it as a Egress.
   206  func (r EgressResult) Extract() (*Egress, error) {
   207  	var s Egress
   208  	if r.Err != nil {
   209  		return &s, r.Err
   210  	}
   211  	err := json.Unmarshal([]byte(r.Body.(string)), &s)
   212  	return &s, err
   213  }
   214  
   215  // DisableEgressResult represents the result of a DisableEgressAccess operation.
   216  type DisableEgressResult struct {
   217  	golangsdk.ErrResult
   218  }
   219  
   220  // EnableIngressResult represents the result of a EnableIngressAccess operation.
   221  type EnableIngressResult struct {
   222  	commonResult
   223  }
   224  
   225  type Ingress struct {
   226  	Id          string `json:"eip_id"`
   227  	EipAddress  string `json:"eip_address"`
   228  	Status      string `json:"eip_status"`
   229  	Ipv6Address string `json:"eip_ipv6_address"`
   230  }
   231  
   232  // Call its Extract method to interpret it as a Ingress.
   233  func (r EnableIngressResult) Extract() (*Ingress, error) {
   234  	var s Ingress
   235  	err := r.ExtractInto(&s)
   236  	return &s, err
   237  }
   238  
   239  // DisableIngressResult represents the result of a DisableIngressAccess operation.
   240  type DisableIngressResult struct {
   241  	golangsdk.ErrResult
   242  }