yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/hcso/order.go (about)

     1  // Copyright 2019 Yunion
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package hcso
    16  
    17  import (
    18  	"fmt"
    19  	"time"
    20  )
    21  
    22  type SOrder struct {
    23  	ErrorCode *string     `json:"error_code"` // 只有失败时才返回此参数
    24  	ErrorMsg  *string     `json:"error_msg"`  //只有失败时才返回此参数
    25  	TotalSize int         `json:"totalSize"`  // 只有成功时才返回此参数
    26  	Resources []SResource `json:"resources"`
    27  }
    28  
    29  type SResource struct {
    30  	ResourceID       string `json:"resourceId"`
    31  	CloudServiceType string `json:"cloudServiceType"`
    32  	RegionCode       string `json:"regionCode"`
    33  	ResourceType     string `json:"resourceType"`
    34  	ResourceSpecCode string `json:"resourceSpecCode"`
    35  	Status           int64  `json:"status"`
    36  }
    37  
    38  type SResourceDetail struct {
    39  	ID                   string    `json:"id"`
    40  	Status               int64     `json:"status"`
    41  	ResourceID           string    `json:"resource_id"`
    42  	ResourceName         string    `json:"resource_name"`
    43  	RegionCode           string    `json:"region_code"`
    44  	CloudServiceTypeCode string    `json:"cloud_service_type_code"`
    45  	ResourceTypeCode     string    `json:"resource_type_code"`
    46  	ResourceSpecCode     string    `json:"resource_spec_code"`
    47  	ProjectCode          string    `json:"project_code"`
    48  	ProductID            string    `json:"product_id"`
    49  	MainResourceID       string    `json:"main_resource_id"`
    50  	IsMainResource       int64     `json:"is_main_resource"`
    51  	ValidTime            time.Time `json:"valid_time"`
    52  	ExpireTime           time.Time `json:"expire_time"`
    53  	NextOperationPolicy  string    `json:"next_operation_policy"`
    54  }
    55  
    56  func (self *SRegion) getDomianId() (string, error) {
    57  	domains, err := self.client.getEnabledDomains()
    58  	if err != nil {
    59  		return "", err
    60  	}
    61  
    62  	if domains == nil || len(domains) == 0 {
    63  		return "", fmt.Errorf("GetAllResByOrderId domain is empty")
    64  	} else if len(domains) > 1 {
    65  		// not supported??
    66  		return "", fmt.Errorf("GetAllResByOrderId mutliple domain(%d) found", len(domains))
    67  	}
    68  
    69  	return domains[0].ID, nil
    70  }