|
| 1 | +# coding=utf8 |
| 2 | + |
| 3 | +# Copyright 2018 JDCLOUD.COM |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +# NOTE: This class is auto generated by the jdcloud code generator program. |
| 18 | + |
| 19 | +from argparse import RawTextHelpFormatter |
| 20 | +from jdcloud_cli.cement.ext.ext_argparse import expose |
| 21 | +from jdcloud_cli.controllers.base_controller import BaseController |
| 22 | +from jdcloud_cli.client_factory import ClientFactory |
| 23 | +from jdcloud_cli.parameter_builder import collect_user_args, collect_user_headers |
| 24 | +from jdcloud_cli.printer import Printer |
| 25 | +from jdcloud_cli.skeleton import Skeleton |
| 26 | + |
| 27 | + |
| 28 | +class BillingController(BaseController): |
| 29 | + class Meta: |
| 30 | + label = 'billing' |
| 31 | + help = '计费' |
| 32 | + description = ''' |
| 33 | + billing cli 子命令,计费系统API接口。 |
| 34 | + OpenAPI文档地址为:https://docs.jdcloud.com/cn/xxx/api/overview |
| 35 | + ''' |
| 36 | + stacked_on = 'base' |
| 37 | + stacked_type = 'nested' |
| 38 | + |
| 39 | + @expose( |
| 40 | + arguments=[ |
| 41 | + (['--region-id'], dict(help="""(string) Region ID """, dest='regionId', required=False)), |
| 42 | + (['--start-time'], dict(help="""(string) 账期开始时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss """, dest='startTime', required=True)), |
| 43 | + (['--end-time'], dict(help="""(string) 账期结束时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss """, dest='endTime', required=True)), |
| 44 | + (['--app-code'], dict(help="""(string) 产品线代码 """, dest='appCode', required=False)), |
| 45 | + (['--service-code'], dict(help="""(string) 产品代码 """, dest='serviceCode', required=False)), |
| 46 | + (['--resource-ids'], dict(help="""(array: string) 资源单id列表,最多支持传入500个 """, dest='resourceIds', required=False)), |
| 47 | + (['--tags'], dict(help="""(array: object) 标签 """, dest='tags', required=False)), |
| 48 | + (['--page-index'], dict(help="""(int) pageIndex 分页,默认从1开始 """, dest='pageIndex', type=int, required=False)), |
| 49 | + (['--page-size'], dict(help="""(int) pageSize 每页查询数据条数,最多支持1000条 """, dest='pageSize', type=int, required=False)), |
| 50 | + (['--input-json'], dict(help='(json) 以json字符串或文件绝对路径形式作为输入参数。\n字符串方式举例:--input-json \'{"field":"value"}\';\n文件格式举例:--input-json file:///xxxx.json', dest='input_json', required=False)), |
| 51 | + (['--headers'], dict(help="""(json) 用户自定义Header,举例:'{"x-jdcloud-security-token":"abc","test":"123"}'""", dest='headers', required=False)), |
| 52 | + ], |
| 53 | + formatter_class=RawTextHelpFormatter, |
| 54 | + help=''' 查询账单资源汇总数据 ''', |
| 55 | + description=''' |
| 56 | + 查询账单资源汇总数据。 |
| 57 | +
|
| 58 | + 示例: jdc billing query-bill-summary --start-time xxx --end-time xxx |
| 59 | + ''', |
| 60 | + ) |
| 61 | + def query_bill_summary(self): |
| 62 | + client_factory = ClientFactory('billing') |
| 63 | + client = client_factory.get(self.app) |
| 64 | + if client is None: |
| 65 | + return |
| 66 | + |
| 67 | + try: |
| 68 | + from jdcloud_sdk.services.billing.apis.QueryBillSummaryRequest import QueryBillSummaryRequest |
| 69 | + params_dict = collect_user_args(self.app) |
| 70 | + headers = collect_user_headers(self.app) |
| 71 | + req = QueryBillSummaryRequest(params_dict, headers) |
| 72 | + resp = client.send(req) |
| 73 | + Printer.print_result(resp) |
| 74 | + except ImportError: |
| 75 | + print('{"error":"This api is not supported, please use the newer version"}') |
| 76 | + except Exception as e: |
| 77 | + print(e) |
| 78 | + |
| 79 | + @expose( |
| 80 | + arguments=[ |
| 81 | + (['--region-id'], dict(help="""(string) Region ID """, dest='regionId', required=False)), |
| 82 | + (['--start-time'], dict(help="""(string) 账期开始时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss """, dest='startTime', required=True)), |
| 83 | + (['--end-time'], dict(help="""(string) 账期结束时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss """, dest='endTime', required=True)), |
| 84 | + (['--app-code'], dict(help="""(string) 产品线代码 """, dest='appCode', required=False)), |
| 85 | + (['--service-code'], dict(help="""(string) 产品代码 """, dest='serviceCode', required=False)), |
| 86 | + (['--billing-type'], dict(help="""(int) 计费类型 1、按配置 2、按用量 3、包年包月 4、按次 """, dest='billingType', type=int, required=False)), |
| 87 | + (['--resource-ids'], dict(help="""(array: string) 资源单id列表,最多支持传入500个 """, dest='resourceIds', required=False)), |
| 88 | + (['--tags'], dict(help="""(array: object) 标签 """, dest='tags', required=False)), |
| 89 | + (['--page-index'], dict(help="""(int) pageIndex 分页,默认从1开始 """, dest='pageIndex', type=int, required=False)), |
| 90 | + (['--page-size'], dict(help="""(int) pageSize 每页查询数据条数,最多支持1000条 """, dest='pageSize', type=int, required=False)), |
| 91 | + (['--input-json'], dict(help='(json) 以json字符串或文件绝对路径形式作为输入参数。\n字符串方式举例:--input-json \'{"field":"value"}\';\n文件格式举例:--input-json file:///xxxx.json', dest='input_json', required=False)), |
| 92 | + (['--headers'], dict(help="""(json) 用户自定义Header,举例:'{"x-jdcloud-security-token":"abc","test":"123"}'""", dest='headers', required=False)), |
| 93 | + ], |
| 94 | + formatter_class=RawTextHelpFormatter, |
| 95 | + help=''' 查询账单明细数据 ''', |
| 96 | + description=''' |
| 97 | + 查询账单明细数据。 |
| 98 | +
|
| 99 | + 示例: jdc billing query-bill-detail --start-time xxx --end-time xxx |
| 100 | + ''', |
| 101 | + ) |
| 102 | + def query_bill_detail(self): |
| 103 | + client_factory = ClientFactory('billing') |
| 104 | + client = client_factory.get(self.app) |
| 105 | + if client is None: |
| 106 | + return |
| 107 | + |
| 108 | + try: |
| 109 | + from jdcloud_sdk.services.billing.apis.QueryBillDetailRequest import QueryBillDetailRequest |
| 110 | + params_dict = collect_user_args(self.app) |
| 111 | + headers = collect_user_headers(self.app) |
| 112 | + req = QueryBillDetailRequest(params_dict, headers) |
| 113 | + resp = client.send(req) |
| 114 | + Printer.print_result(resp) |
| 115 | + except ImportError: |
| 116 | + print('{"error":"This api is not supported, please use the newer version"}') |
| 117 | + except Exception as e: |
| 118 | + print(e) |
| 119 | + |
| 120 | + @expose( |
| 121 | + arguments=[ |
| 122 | + (['--region-id'], dict(help="""(string) NA """, dest='regionId', required=False)), |
| 123 | + (['--cmd'], dict(help="""(int) 操作类型 1:创建 2:续费 3:升配 4:删除 """, dest='cmd', type=int, required=True)), |
| 124 | + (['--order-list'], dict(help="""(array: orderPriceProtocol) 计算价格的订单 """, dest='orderList', required=False)), |
| 125 | + (['--operate-time'], dict(help="""(string) 操作时间,遵循ISO8601标准,使用UTC时间,格式为:YYYY-MM-DDTHH:mm:ssZ """, dest='operateTime', required=False)), |
| 126 | + (['--promotion-info'], dict(help="""(string) 1:折扣(不需要传) 2:免费活动3:付费活动 4:推荐码 5:会员价 [{"promotionType":1,"activityCode":123},{"promotionType":2,"activityCode":}] """, dest='promotionInfo', required=False)), |
| 127 | + (['--client-type'], dict(help="""(int) 客户端:1.PC端;2.移动端; """, dest='clientType', type=int, required=False)), |
| 128 | + (['--package-count'], dict(help="""(int) 批量购买时数量 """, dest='packageCount', type=int, required=True)), |
| 129 | + (['--process-type'], dict(help="""(int) 临时升配时必传,3-临时升配 """, dest='processType', type=int, required=False)), |
| 130 | + (['--input-json'], dict(help='(json) 以json字符串或文件绝对路径形式作为输入参数。\n字符串方式举例:--input-json \'{"field":"value"}\';\n文件格式举例:--input-json file:///xxxx.json', dest='input_json', required=False)), |
| 131 | + (['--headers'], dict(help="""(json) 用户自定义Header,举例:'{"x-jdcloud-security-token":"abc","test":"123"}'""", dest='headers', required=False)), |
| 132 | + ], |
| 133 | + formatter_class=RawTextHelpFormatter, |
| 134 | + help=''' 查询计费价格信息 ''', |
| 135 | + description=''' |
| 136 | + 查询计费价格信息。 |
| 137 | +
|
| 138 | + 示例: jdc billing calculate-total-price --cmd 0 --package-count 0 |
| 139 | + ''', |
| 140 | + ) |
| 141 | + def calculate_total_price(self): |
| 142 | + client_factory = ClientFactory('billing') |
| 143 | + client = client_factory.get(self.app) |
| 144 | + if client is None: |
| 145 | + return |
| 146 | + |
| 147 | + try: |
| 148 | + from jdcloud_sdk.services.billing.apis.CalculateTotalPriceRequest import CalculateTotalPriceRequest |
| 149 | + params_dict = collect_user_args(self.app) |
| 150 | + headers = collect_user_headers(self.app) |
| 151 | + req = CalculateTotalPriceRequest(params_dict, headers) |
| 152 | + resp = client.send(req) |
| 153 | + Printer.print_result(resp) |
| 154 | + except ImportError: |
| 155 | + print('{"error":"This api is not supported, please use the newer version"}') |
| 156 | + except Exception as e: |
| 157 | + print(e) |
| 158 | + |
| 159 | + @expose( |
| 160 | + arguments=[ |
| 161 | + (['--api'], dict(help="""(string) api name """, choices=['query-bill-summary','query-bill-detail','calculate-total-price',], required=True)), |
| 162 | + ], |
| 163 | + formatter_class=RawTextHelpFormatter, |
| 164 | + help=''' 生成单个API接口的json骨架空字符串 ''', |
| 165 | + description=''' |
| 166 | + 生成单个API接口的json骨架空字符串。 |
| 167 | +
|
| 168 | + 示例: jdc nc generate-skeleton --api describeContainer ''', |
| 169 | + ) |
| 170 | + def generate_skeleton(self): |
| 171 | + skeleton = Skeleton('billing', self.app.pargs.api) |
| 172 | + skeleton.show() |
0 commit comments