yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/ctyun/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 ctyun
    16  
    17  import "yunion.io/x/pkg/errors"
    18  
    19  type SOrder struct {
    20  	OrderItemID        string            `json:"orderItemId"`
    21  	InstanceID         string            `json:"instanceId"`
    22  	AccountID          string            `json:"accountId"`
    23  	UserID             string            `json:"userId"`
    24  	InnerOrderID       string            `json:"innerOrderId"`
    25  	InnerOrderItemID   string            `json:"innerOrderItemId"`
    26  	ProductID          string            `json:"productId"`
    27  	MasterOrderID      string            `json:"masterOrderId"`
    28  	OrderID            string            `json:"orderId"`
    29  	MasterResourceID   string            `json:"masterResourceId"`
    30  	ResourceID         string            `json:"resourceId"`
    31  	ServiceTag         string            `json:"serviceTag"`
    32  	ResourceType       string            `json:"resourceType"`
    33  	ResourceInfo       string            `json:"resourceInfo"`
    34  	StartDate          int64             `json:"startDate"`
    35  	ExpireDate         int64             `json:"expireDate"`
    36  	CreateDate         int64             `json:"createDate"`
    37  	UpdateDate         int64             `json:"updateDate"`
    38  	Status             int64             `json:"status"`
    39  	WorkOrderID        string            `json:"workOrderId"`
    40  	WorkOrderItemID    string            `json:"workOrderItemId"`
    41  	SalesEntryID       string            `json:"salesEntryId"`
    42  	OrderStatus        int64             `json:"orderStatus"`
    43  	ToOndemand         string            `json:"toOndemand"`
    44  	ItemValue          string            `json:"itemValue"`
    45  	ChargingStatus     int64             `json:"chargingStatus"`
    46  	ChargingDate       int64             `json:"chargingDate"`
    47  	ResourceConfig     string            `json:"resourceConfig"`
    48  	AutoToOnDemand     bool              `json:"autoToOnDemand"`
    49  	BuildingChannel    int64             `json:"buildingChannel"`
    50  	IsPlatformSpecific bool              `json:"isPlatformSpecific"`
    51  	BillingOwner       int64             `json:"billingOwner"`
    52  	IsPackage          bool              `json:"isPackage"`
    53  	CanRelease         bool              `json:"canRelease"`
    54  	IsChargeOff        bool              `json:"isChargeOff"`
    55  	IsPublicTest       int64             `json:"isPublicTest"`
    56  	Master             bool              `json:"master"`
    57  	ResourceConfigMap  ResourceConfigMap `json:"resourceConfigMap"`
    58  }
    59  
    60  type ResourceConfigMap struct {
    61  	AvailabilityZone string            `json:"availability_zone"`
    62  	Value            string            `json:"value"`
    63  	Number           string            `json:"number"`
    64  	IsSystemVolume   bool              `json:"isSystemVolume"`
    65  	VolumeType       string            `json:"volumeType"`
    66  	Size             int64             `json:"size"`
    67  	ZoneID           string            `json:"zoneId"`
    68  	RegionID         string            `json:"regionId"`
    69  	Version          string            `json:"version"`
    70  	CycleCnt         int64             `json:"cycleCnt"`
    71  	CycleType        int64             `json:"cycleType"`
    72  	ResEbsID         string            `json:"resEbsId"`
    73  	ActualResourceID string            `json:"actualResourceId"`
    74  	SecurityGroups   []SecurityGroupID `json:"security_groups"`
    75  }
    76  
    77  type SecurityGroupID struct {
    78  	ID string `json:"id"`
    79  }
    80  
    81  func (self *SRegion) GetOrder(orderId string) ([]SOrder, error) {
    82  	params := map[string]string{
    83  		"masterOrderId": orderId,
    84  	}
    85  
    86  	resp, err := self.client.DoGet("/apiproxy/v3/order/queryResourceInfoByMasterOrderId", params)
    87  	if err != nil {
    88  		return nil, errors.Wrap(err, "SRegion.GetOrder.DoGet")
    89  	}
    90  
    91  	ret := make([]SOrder, 0)
    92  	err = resp.Unmarshal(&ret, "returnObj")
    93  	if err != nil {
    94  		return nil, errors.Wrap(err, "SRegion.GetOrder.DoGet")
    95  	}
    96  
    97  	return ret, nil
    98  }