diff --git a/services/bill/bill.go b/services/bill/bill.go new file mode 100644 index 00000000..fade9975 --- /dev/null +++ b/services/bill/bill.go @@ -0,0 +1,24 @@ +package bill + +import ( + "fmt" + + "github.com/baidubce/bce-sdk-go/bce" + "github.com/baidubce/bce-sdk-go/http" +) + +func (c *Client) GetResourceMonthBill(args *GetResourceMonthBillArgs) (list *GetResourceMonthBillResult, err error) { + err = bce.NewRequestBuilder(c). + WithMethod(http.GET). + WithBody(args). + WithURL(bce.URI_PREFIX+"v1/bill/resource/month"). + WithQueryParamFilter("month", args.Month). + WithQueryParamFilter("productType", args.ProductType). + WithQueryParamFilter("serviceType", args.ServiceType). + WithQueryParamFilter("queryAccountId", args.QueryAccountId). + WithQueryParamFilter("pageNo", fmt.Sprintf("%d", args.PageNo)). + WithQueryParamFilter("pageSize", fmt.Sprintf("%d", args.PageSize)). + WithResult(&list). + Do() + return +} diff --git a/services/bill/client.go b/services/bill/client.go new file mode 100644 index 00000000..6f5a3440 --- /dev/null +++ b/services/bill/client.go @@ -0,0 +1,27 @@ +package bill + +import ( + "github.com/baidubce/bce-sdk-go/bce" +) + +const ( + // DefaultEndpoint -- xx + DefaultEndpoint = "billing.baidubce.com" +) + +// Client used for client +type Client struct { + *bce.BceClient +} + +// NewClient return a client +func NewClient(ak, sk, endPoint string) (ret *Client, err error) { + if len(endPoint) == 0 { + endPoint = DefaultEndpoint + } + client, err := bce.NewBceClientWithAkSk(ak, sk, endPoint) + if err != nil { + return nil, err + } + return &Client{client}, nil +} diff --git a/services/bill/model.go b/services/bill/model.go new file mode 100644 index 00000000..7ce8c880 --- /dev/null +++ b/services/bill/model.go @@ -0,0 +1,63 @@ +package bill + +import "math/big" + +type GetResourceMonthBillArgs struct { + Month string `json:"month"` + ProductType string `json:"ProductType"` + ServiceType string `json:"serviceType"` + QueryAccountId string `json:"queryAccountId"` + PageNo int `json:"pageNo"` + PageSize int `json:"pageSize"` +} + +type GetResourceMonthBillResult struct { + BillMonth string + AccountId string + LoginName string + SubAccountId string + SubLoginName string + OuName string + PageNo int + PageSize int + TotalCount int + Bills []ResourceMonthInstanceBill +} +type ResourceMonthInstanceBill struct { + Vendor string + AccountId string + ServiceType string + ServiceTypeName string + ProductType string + Region string + InstanceId string + OrderId string + OrderType string + OrderTypeDesc string + OrderPurchaseTime string + StartTime string + EndTime string + ConfigurationCH string + Tag string + Duration string + ChargeItem string + ChargeItemDesc string + Amount string + AmountUnit string + UnitPrice string + PricingUnit string + DiscountUnit string + Tex big.Float + OriginPrice big.Float + FinancePrice big.Float + Cash big.Float + Rebate big.Float + CreditCost big.Float + CreditRefund big.Float + Debt big.Float + NoPaidPrice big.Float + CouponPrice big.Float + DiscountCouponPrice big.Float + DiscountPrice big.Float + SysGold big.Float +}