Exemple #1
0
class SetCredit(resource2.Resource):
    base_path = "%(domain_id)s/partner/account-mgr/credit"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    # Customer ID.
    customerId = resource2.Body('customerId')
    # New budget, which can be accurate to two decimal places.
    adjustmentAmount = resource2.Body('adjustmentAmount')
    # Unit
    measureId = resource2.Body('measureId', type=int)
    # Whether to unfreeze the account when setting the customer budget.0: No 1: Yes
    cancel_partner_frozen = resource2.Body('cancelPartnerFrozen')
    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')

    def create(self, session, prepend_key=True):
        endpoint_override = self.service.get_endpoint_override()
        request = self._prepare_request(requires_id=False,
                                        prepend_key=prepend_key)
        response = session.post(request.uri,
                                endpoint_filter=self.service,
                                endpoint_override=endpoint_override,
                                json=request.body,
                                headers=request.headers)
        if (response.status_code == 204):
            return self
        self._translate_response(response)
        return self
Exemple #2
0
class QueryCredit(resource2.Resource):
    base_path = "%(domain_id)s/partner/account-mgr/credit"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters('customer_id')

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    # customer ID
    customer_id = resource2.Body('customer_id')

    # response
    creditAmount = resource2.Body('creditAmount')
    # New budget, which can be accurate to two decimal places.
    usedAmount = resource2.Body('usedAmount')
    # Unit
    measureId = resource2.Body('measureId', type=int)
    # currency
    currency = resource2.Body('currency')
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
Exemple #3
0
class QueryRefundOrderAmount(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/orders/refund-order"
    service = bss_intl_service.BssIntlService()
    allow_get = True

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    order_id = resource2.Body('order_id')

    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    resource_info_list = resource2.Body('resource_info_list', type=list)
    total_count = resource2.Body('total_count', type=int)

    def get(self, session, requires_id=False):
        request = self._prepare_request(requires_id=False)
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        xstr = lambda s: '' if s is None else str(s)
        query_dict = {'order_id': xstr(self.order_id)}
        query_str = urlencode(query_dict, doseq=True)
        url = request.uri + "?" + query_str
        response = session.get(url,
                               endpoint_filter=self.service,
                               microversion=service.microversion,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self
Exemple #4
0
class SendVerificationcode(resource2.Resource):
    base_path = "%(domain_id)s/partner/common-mgr/verificationcode"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    # User domain ID
    domain_id = resource2.URI('domain_id')

    # request
    receiverType = resource2.Body('receiverType', type=int)
    timeout = resource2.Body('timeout', type=int)
    # Email address.
    email = resource2.Body('email')
    mobilePhone = resource2.Body('mobilePhone')
    countryCode = resource2.Body('countryCode')
    # language
    lang = resource2.Body('lang')
    scene = resource2.Body('scene')
    # Customer ID.
    customerId = resource2.Body('customerId')

    def create(self, session, prepend_key=True):
        endpoint_override = self.service.get_endpoint_override()
        request = self._prepare_request(requires_id=False,
                                        prepend_key=prepend_key)
        response = session.post(request.uri,
                                endpoint_filter=self.service,
                                endpoint_override=endpoint_override,
                                json=request.body,
                                headers=request.headers)
        if (response.status_code == 204):
            return self
        self._translate_response(response)
        return self
class QueryCustomerPeriodResourcesList(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/resources/detail"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters(
        'resource_ids', 'order_id', 'only_main_resource', 'status_list',
        'page_no','page_size')


    # User domain ID
    domain_id = resource2.URI('domain_id')


    # request
    # Resource IDs
    resource_ids = resource2.Body('resource_ids')
    order_id = resource2.Body('order_id')
    only_main_resource = resource2.Body('only_main_resource', type=int)
    status_list = resource2.Body('status_list')
    page_no = resource2.Body('page_no', type=int)
    page_size = resource2.Body('page_size', type=int)

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    data = resource2.Body('data', type=list)
    total_count = resource2.Body('total_count', type=int)
Exemple #6
0
class CancelOrder(resource2.Resource):
    base_path = "%(domain_id)s/customer/order-mgr/orders/actions"
    service = bss_intl_service.BssIntlService()
    allow_create = True
    put_create = True

    # User domain ID
    domain_id = resource2.URI('domain_id')
    action_id = resource2.URI('action_id')

    # request
    # Order ID.
    orderId = resource2.Body('orderId')
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')

    def create(self, session, prepend_key=True, **parms):
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        request = self._prepare_request(requires_id=False,
                                        prepend_key=prepend_key)
        response = session.put(request.uri,
                               endpoint_filter=self.service,
                               endpoint_override=endpoint_override,
                               json=request.body,
                               headers=request.headers,
                               microversion=service.microversion,
                               params={"action_id": self.action_id})
        self._translate_response(response)
        return self
Exemple #7
0
class CreateCustomer(resource2.Resource):
    base_path = "%(domain_id)s/partner/customer-mgr/customer"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    # User domain ID
    domain_id = resource2.URI('domain_id')

    # request
    # Account name.
    domainName = resource2.Body('domainName')
    # Email address.
    email = resource2.Body('email')
    mobilePhone = resource2.Body('mobilePhone')
    countryCode = resource2.Body('countryCode')
    # Verification code.
    verificationCode = resource2.Body('verificationCode')
    # Unique ID of the user on the third-party system, which is assigned by the partner.
    xAccountId = resource2.Body('xAccountId')
    # Platform ID assigned by Huawei to a partner.
    xAccountType = resource2.Body('xAccountType')
    password = resource2.Body('password')
    # Two-letter ID representing the country/region of the customer.
    domainArea = resource2.Body('domainArea')
    # Indicates whether to disable the marketing message sending function.
    isCloseMarketMs = resource2.Body('isCloseMarketMs')
    # response
    domainId = resource2.Body('domainId')
    # Account name.
    domainName = resource2.Body('domainName')
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
Exemple #8
0
class QueryResourceStatusByOrderId(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/orders-resource/%(order_id)s"
    service = bss_intl_service.BssIntlService()
    allow_get = True

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    order_id = resource2.URI('order_id')
    offset = resource2.Body('offset')
    limit = resource2.Body('limit')

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Number of records that match the query conditions.
    totalSize = resource2.Body('totalSize')
    resources = resource2.Body('resources')

    def get(self, session, requires_id=False):
        request = self._prepare_request(requires_id=False)
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        xstr = lambda s: '' if s is None else str(s)
        query_dict = {'offset': xstr(self.offset), 'limit': xstr(self.limit)}
        query_str = urlencode(query_dict, doseq=True)
        url = request.uri + "?" + query_str
        response = session.get(url,
                               endpoint_filter=self.service,
                               microversion=service.microversion,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self
Exemple #9
0
class PayPeriodOrder(resource2.Resource):
    base_path = "%(domain_id)s/customer/order-mgr/order/pay"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    # User domain ID
    domain_id = resource2.URI('domain_id')

    # request
    # Order ID.
    orderId = resource2.Body('orderId')
    # Payment account type.
    payAccountType = resource2.Body('payAccountType', type=int)
    # partner account ID
    bpId = resource2.Body('bpId')
    # This parameter is reserved.
    couponIds = resource2.Body('couponIds', type=list)

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Payment sequence number corresponding to the order.
    tradeNo = resource2.Body('tradeNo')
    # Information about the resources whose quota or capacity is insufficient.
    quotaInfos = resource2.Body('quotaInfos', type=list)
    # Information about the enterprise project whose fund is insufficient.
    enterpriseProjectAuthResult = resource2.Body('enterpriseProjectAuthResult',
                                                 type=list)
class IndividualRealnameAuth(resource2.Resource):
    base_path = "%(domain_id)s/partner/customer-mgr/realname-auth/individual"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    # User domain ID
    domain_id = resource2.URI('domain_id')

    # request
    # Customer ID.
    customerId = resource2.Body('customerId')
    # Authentication method.
    identifyType = resource2.Body('identifyType')
    # Certificate type.
    verifiedType = resource2.Body('verifiedType')
    # Attachment URL for individual certificate authentication. The URL must be entered in sequence.
    verifiedFileURL = resource2.Body('verifiedFileURL', type=list)
    # Real-name authentication name.
    name = resource2.Body('name')
    # Enterprise certificate number.
    verifiedNumber = resource2.Body('verifiedNumber')
    # Change type.
    changeType = resource2.Body('changeType')
    # Platform ID assigned by Huawei to a partner.
    xaccountType = resource2.Body('xaccountType')
    bankCardInfo = resource2.Body('bankCardInfo')
    # response
    # Whether to transfer to manual review.
    isReview = resource2.Body('isReview')
    # Error list.
    failCheckItems = resource2.Body('failCheckItems', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
Exemple #11
0
class SetCredit(resource2.Resource):
    base_path = "%(domain_id)s/partner/account-mgr/credit"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    # Customer ID.
    customerId = resource2.Body('customerId')
    adjustmentAmount = resource2.Body('adjustmentAmount')
    measureId = resource2.Body('measureId', type=int)
    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')

    def create(self, session, prepend_key=True):
        endpoint_override = self.service.get_endpoint_override()
        request = self._prepare_request(requires_id=False,
                                        prepend_key=prepend_key)
        response = session.post(request.uri,
                                endpoint_filter=self.service,
                                endpoint_override=endpoint_override,
                                json=request.body,
                                headers=request.headers)
        if (response.status_code == 204):
            return self
        self._translate_response(response)
        return self
class QueryCustomerList(resource2.Resource):
    base_path = "%(domain_id)s/partner/customer-mgr/query"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    # User domain ID
    domain_id = resource2.URI('domain_id')

    # request
    # Account name.
    domainName = resource2.Body('domainName')
    # Real-name authentication name.
    name = resource2.Body('name')
    # Page to be queried.
    offset = resource2.Body('offset', type=int)
    # Number of records on each page.
    limit = resource2.Body('limit', type=int)
    # Tag. Fuzzy search is supported.
    label = resource2.Body('label')
    cooperationType = resource2.Body('cooperationType')
    #  Start time of the association time range (UTC time).The value is in "yyyy-MM-dd 'T' HH:mm:ss 'Z'" format, such as 2019-05-06T08:05:01Z.
    cooperationTimeStart = resource2.Body('cooperationTimeStart')
    # End time of the association time range (UTC time). The value is in "yyyy-MM-dd 'T' HH:mm:ss 'Z'" format, such as 2019-05-06T08:05:01Z.
    cooperationTimeEnd = resource2.Body('cooperationTimeEnd')
    # response
    # Total number of records.
    count = resource2.Body('count')
    # Customer list.
    customerInfoList = resource2.Body('customerInfoList', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Whether to freeze the account. 0: No 1: Yes
    isFrozen = resource2.Body('isFrozen')
class RenewSubscriptionByResourceId(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/resources/renew"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    domain_id = resource2.URI('domain_id')

    # request
    # Resource IDs.
    resource_ids = resource2.Body('resource_ids', type=list)
    # Period type.
    period_type = resource2.Body('period_type', type=int)
    # Number of periods.
    period_num = resource2.Body('period_num', type=int)
    # Expiration policy.
    expire_mode = resource2.Body('expire_mode', type=int)
    # Whether enable automatic payment.
    isAutoPay = resource2.Body('isAutoPay', type=int)

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # List of order IDs generated when resource subscription is renewed.
    order_ids = resource2.Body('order_ids', type=list)
    # List of resources that cannot be renewed due to expiration.
    expired_resource_ids=resource2.Body('expiredResourceIds', type=list)
class QueryResourceUsageDetails(resource2.Resource):
    base_path = "%(domain_id)s/customer/account-mgr/bill/res-records"
    service = bss_intl_service.BssIntlService()
    allow_get = True

    # User domain ID
    domain_id = resource2.URI('domain_id')
    # request
    # Expenditure month.
    cycle = resource2.Body('cycle')
    # Cloud service type code.
    cloudServiceTypeCode = resource2.Body('cloudServiceTypeCode')
    # Resource type code. For example, the VM resource type code of ECS is hws.resource.type.vm.
    resourceTypeCode = resource2.Body('resourceTypeCode')
    # Cloud service region code, for example, cn-north-1.
    regionCode = resource2.Body('regionCode')
    resInstanceId = resource2.Body('resInstanceId')
    # Billing mode.
    payMethod = resource2.Body('payMethod')
    # Enterprise project ID.
    enterpriseProjectId = resource2.Body('enterpriseProjectId')
    offset = resource2.Body('offset')
    limit = resource2.Body('limit')

    # response
    # currency
    currency = resource2.Body('currency')
    totalCount = resource2.Body('totalCount')
    monthlyRecords = resource2.Body('monthlyRecords', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')

    def get(self, session, requires_id=False):
        request = self._prepare_request(requires_id=False)
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        xstr = lambda s: '' if s is None else str(s)
        query_dict = {
            'cycle': xstr(self.cycle),
            'cloudServiceTypeCode': xstr(self.cloudServiceTypeCode),
            'resourceTypeCode': xstr(self.resourceTypeCode),
            'regionCode': xstr(self.regionCode),
            'resInstanceId': xstr(self.resInstanceId),
            'payMethod': xstr(self.payMethod),
            'enterpriseProjectId': xstr(self.enterpriseProjectId),
            'offset': xstr(self.offset),
            'limit': xstr(self.limit)
        }
        query_str = urlencode(query_dict, doseq=True)
        url = request.uri + "?" + query_str
        response = session.get(url,
                               endpoint_filter=self.service,
                               microversion=service.microversion,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self
Exemple #15
0
class QueryOrderList(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/orders/detail"
    service = bss_intl_service.BssIntlService()
    allow_get = True

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    order_id = resource2.Body('order_id')
    customer_id = resource2.Body('customer_id')
    create_time_begin = resource2.Body('create_time_begin')
    create_time_end = resource2.Body('create_time_end')
    service_type = resource2.Body('service_type')
    #  0: The account name, mobile number, or email address does not exist.
    #  1: The account name, mobile number, or email address already exists.
    status = resource2.Body('status')
    order_type = resource2.Body('order_type')
    page_size = resource2.Body('page_size')
    page_index = resource2.Body('page_index')
    sort = resource2.Body('sort')
    payment_time_begin = resource2.Body('payment_time_begin')
    payment_time_end = resource2.Body('payment_time_end')

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    data = resource2.Body('data')

    def get(self, session, requires_id=False):
        request = self._prepare_request(requires_id=False)
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        xstr = lambda s: '' if s is None else str(s)
        query_dict = {
            'order_id': xstr(self.order_id),
            'customer_id': xstr(self.customer_id),
            'create_time_begin': xstr(self.create_time_begin),
            'create_time_end': xstr(self.create_time_end),
            'status': xstr(self.status),
            'order_type': xstr(self.order_type),
            'service_type': xstr(self.service_type),
            'page_size': xstr(self.page_size),
            'page_index': xstr(self.page_index),
            'sort': xstr(self.sort),
            'payment_time_begin': xstr(self.payment_time_begin),
            'payment_time_end': xstr(self.payment_time_end)
        }
        query_str = urlencode(query_dict, doseq=True)
        url = request.uri + "?" + query_str
        response = session.get(url,
                               endpoint_filter=self.service,
                               microversion=service.microversion,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self
Exemple #16
0
class QueryOrderList(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/orders/detail"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True
    _query_mapping = resource2.QueryParameters(
        'order_id', 'customer_id', 'create_time_begin', 'create_time_end',
        'status', 'order_type', 'service_type', 'page_size', 'page_index',
        'sort', 'payment_time_begin', 'payment_time_end')

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    order_id = resource2.Body('order_id')
    customer_id = resource2.Body('customer_id')
    create_time_begin = resource2.Body('create_time_begin')
    create_time_end = resource2.Body('create_time_end')
    service_type = resource2.Body('service_type')
    #  0: The account name, mobile number, or email address does not exist.
    #  1: The account name, mobile number, or email address already exists.
    status = resource2.Body('status')
    order_type = resource2.Body('order_type')
    page_size = resource2.Body('page_size')
    page_index = resource2.Body('page_index')
    sort = resource2.Body('sort')
    payment_time_begin = resource2.Body('payment_time_begin')
    payment_time_end = resource2.Body('payment_time_end')

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    data = resource2.Body('data')

    def list(cls, session, **params):
        query_params = cls._query_mapping._transpose(params)
        uri = cls.get_list_uri(params)
        service = cls.get_service_filter(cls, session)
        endpoint_override = cls.service.get_endpoint_override()

        resp = session.get(uri,
                           endpoint_filter=cls.service,
                           microversion=service.microversion,
                           endpoint_override=endpoint_override,
                           headers={"Accept": "application/json"},
                           params=query_params)

        response_json = resp.json()
        if not response_json:
            return

        value = cls.existing(**response_json)
        return value
class ChangeEnterpriseRealnameAuth(resource2.Resource):
    base_path = "%(domain_id)s/partner/customer-mgr/realname-auth/enterprise"
    service = bss_intl_service.BssIntlService()
    allow_create = True
    put_create = True

    # User domain ID
    domain_id = resource2.URI('domain_id')
    # request
    # Customer ID.
    customerId = resource2.Body('customerId')
    # Authentication method.
    identifyType = resource2.Body('identifyType')
    # Enterprise certificate type.
    certificateType = resource2.Body('certificateType')
    # URL of the certificate attachment file used for enterprise certificate authentication.
    verifiedFileURL = resource2.Body('verifiedFileURL')
    # Organization name.
    corpName = resource2.Body('corpName')
    # Enterprise certificate number.
    verifiedNumber = resource2.Body('verifiedNumber')
    # Registration country entered for real-name authentication.
    regCountry = resource2.Body('regCountry')
    # Enterprise registration address for real-name authentication.
    regAddress = resource2.Body('regAddress')
    # Change type.
    changeType = resource2.Body('changeType')
    # Platform ID assigned by Huawei to a partner.
    xaccountType = resource2.Body('xaccountType')
    # Enterprise person information.
    enterprisePerson = resource2.Body('enterprisePerson')

    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Whether to transfer to manual review.
    isReview = resource2.Body('isReview')
    # Error list.
    failCheckItems = resource2.Body('failCheckItems', type=list)

    def create(self, session, prepend_key=True):
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        request = self._prepare_request(requires_id=False,
                                        prepend_key=prepend_key)
        response = session.put(request.uri,
                               endpoint_filter=self.service,
                               endpoint_override=endpoint_override,
                               json=request.body,
                               headers=request.headers,
                               microversion=service.microversion)
        self._translate_response(response)
        return self
class QueryPartnerMonthlyBills(resource2.Resource):
    base_path = "%(domain_id)s/partner/account-mgr/postpaid-bill-summary"
    service = bss_intl_service.BssIntlService()
    allow_get = True

    # User domain ID
    domain_id = resource2.URI('domain_id')

    # request
    consume_month = resource2.Body('consume_month')

    # response
    billCycle = resource2.Body('billCycle')
    # Transaction amount/unsubscription amount/refund amount of the customer, including the vouchers, flexi-purchase coupons, reserved flexi-purchase coupons, and stored-value cards.
    creditDebtAmount = resource2.Body('creditDebtAmount')
    # Consumption amount of a cloud service, including the amount of cash coupons.
    consumeAmount = resource2.Body('consumeAmount')
    # Write-off amount (negative value), which is calculated based on the special commercial discount of the partner.
    writeoffdebt = resource2.Body('writeoffdebt')
    # Unsubscription amount (negative value), which is calculated based on the special commercial discount of the partner.
    unsubscribeAmount = resource2.Body('unsubscribeAmount')
    # Unit
    measureId = resource2.Body('measureId')
    # currency
    currency = resource2.Body('currency')
    # Tax amount, which is the tax amount in the creditDebtAmount field.
    taxAmount = resource2.Body('taxAmount')
    # Bill amount that is not settled, which is calculated based on the special commercial discount of the partner.
    unclearedAmount = resource2.Body('unclearedAmount')
    # Due date for bills.
    dueDate = resource2.Body('dueDate')
    # Bill list.
    billList = resource2.Body('billList')

    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')

    def get(self, session, requires_id=False):
        request = self._prepare_request(requires_id=False)
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        query_dict = {'consume_month': self.consume_month}
        query_str = urlencode(query_dict, doseq=True)
        url = request.uri + "?" + query_str
        response = session.get(url,
                               endpoint_filter=self.service,
                               microversion=service.microversion,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self
Exemple #19
0
class Version(resource.Resource):
    resource_key = 'version'
    resources_key = 'versions'
    base_path = '/'
    service = bss_intl_service.BssIntlService(
        version=bss_intl_service.BssIntlService.UNVERSIONED)

    # capabilities
    allow_list = True

    # Properties
    links = resource.Body('links')
    status = resource.Body('status')
class QueryMonthlyExpenditureSummary(resource2.Resource):
    base_path = "%(domain_id)s/customer/account-mgr/bill/monthly-sum"
    service = bss_intl_service.BssIntlService()
    allow_get = True

    # User domain ID
    domain_id = resource2.URI('domain_id')
    # request
    # Expenditure month.
    cycle = resource2.Body('cycle')
    # Cloud service type code. For example, the cloud service type code of ECS is hws.service.type.ec2.
    cloud_service_type_code = resource2.Body('cloud_service_type_code')
    account_type = resource2.Body('type')
    # Enterprise project ID.
    enterpriseProjectId = resource2.Body('enterpriseProjectId')

    # response
    # currency
    currency = resource2.Body('currency')
    # Number of result sets.
    total_count = resource2.Body('total_count')
    # Record information.
    bill_sums = resource2.Body('bill_sums', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')

    def get(self, session, requires_id=False):
        request = self._prepare_request(requires_id=False)
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        xstr = lambda s: '' if s is None else str(s)
        query_dict = {
            'cycle': xstr(self.cycle),
            'cloud_service_type_code': xstr(self.cloud_service_type_code),
            'type': xstr(self.account_type),
            'enterpriseProjectId': xstr(self.enterpriseProjectId)
        }
        query_str = urlencode(query_dict, doseq=True)
        url = request.uri + "?" + query_str
        response = session.get(url,
                               endpoint_filter=self.service,
                               microversion=service.microversion,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self
Exemple #21
0
class QueryMonthlyExpenditureSummary(resource2.Resource):
    base_path = "%(domain_id)s/customer/account-mgr/bill/monthly-sum"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters('cycle', 'cloud_service_type_code', 'type', 'enterpriseProjectId')


    # User domain ID
    domain_id = resource2.URI('domain_id')
    # request
    # Expenditure month.
    cycle = resource2.Body('cycle')
    # Cloud service type code. For example, the cloud service type code of ECS is hws.service.type.ec2.
    cloud_service_type_code = resource2.Body('cloud_service_type_code')
    account_type = resource2.Body('type')
    # Enterprise project ID.
    enterpriseProjectId = resource2.Body('enterpriseProjectId')

    # response
    # currency
    currency = resource2.Body('currency')
    # Number of result sets.
    total_count = resource2.Body('total_count')
    # Record information.
    bill_sums = resource2.Body('bill_sums', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Total amount (tax included).
    total_amount = resource2.Body('total_amount')
    # Total debt.
    debt_amount = resource2.Body('debt_amount')
    # Cash coupon amount.
    coupon_amount = resource2.Body('coupon_amount')
    # Flexi-purchase coupon amount (reserved).
    cashcoupon_amount = resource2.Body('cashcoupon_amount')
    # Stored-value card amount (reserved).
    storedcard_amount = resource2.Body('storedcard_amount')
    # Balance in the cash account.
    debit_amount = resource2.Body('debit_amount')
    # Balance in the credit account.
    credit_amount = resource2.Body('credit_amount')
    # Unit
    measure_id = resource2.Body('measure_id')
Exemple #22
0
class QueryOrderDetail(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/orders/%(order_id)s"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters('offset', 'limit')

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    order_id = resource2.URI('order_id')
    offset = resource2.Body('offset')
    limit = resource2.Body('limit')

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Total number of records.
    count = resource2.Body('count')
    # Order details.
    orderInfo = resource2.Body('orderInfo')
    # ID of the primary order item mapping the order item.
    orderlineItems = resource2.Body('orderlineItems')

    def list(cls, session, **params):
        query_params = cls._query_mapping._transpose(params)
        uri = cls.get_list_uri(params)
        service = cls.get_service_filter(cls, session)
        endpoint_override = cls.service.get_endpoint_override()

        resp = session.get(uri,
                           endpoint_filter=cls.service,
                           microversion=service.microversion,
                           endpoint_override=endpoint_override,
                           headers={"Accept": "application/json"},
                           params=query_params)

        response_json = resp.json()
        if not response_json:
            return

        value = cls.existing(**response_json)
        return value
Exemple #23
0
class QueryCustomerPeriodResourcesList(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/resources/detail"
    service = bss_intl_service.BssIntlService()
    allow_get = True

    # User domain ID
    domain_id = resource2.URI('domain_id')

    # request
    # Resource IDs
    resource_ids = resource2.Body('resource_ids')
    order_id = resource2.Body('order_id')
    only_main_resource = resource2.Body('only_main_resource', type=int)
    status_list = resource2.Body('status_list')
    page_no = resource2.Body('page_no', type=int)
    page_size = resource2.Body('page_size', type=int)

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    data = resource2.Body('data', type=list)
    total_count = resource2.Body('total_count', type=int)

    def get(self, session, requires_id=False):
        request = self._prepare_request(requires_id=False)
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        xstr = lambda s: '' if s is None else str(s)
        query_dict = {
            'resource_ids': xstr(self.resource_ids),
            'order_id': xstr(self.order_id),
            'only_main_resource': xstr(self.only_main_resource),
            'status_list': xstr(self.status_list),
            'page_no': xstr(self.page_no),
            'page_size': xstr(self.page_size)
        }
        query_str = urlencode(query_dict, doseq=True)
        url = request.uri + "?" + query_str
        response = session.get(url,
                               endpoint_filter=self.service,
                               microversion=service.microversion,
                               endpoint_override=endpoint_override)
        self._translate_response(response)
        return self
class UnfreezeCustomer(resource2.Resource):
    base_path = "%(domain_id)s/partner/customer-mgr/unfrozens"
    service = bss_intl_service.BssIntlService()
    allow_create = True

    # User domain ID
    domain_id = resource2.URI('domain_id')
    # request
    customerIds = resource2.Body('customerIds', type=list)
    reason = resource2.Body('reason')
    # response
    failNum = resource2.Body('failNum')
    successNum = resource2.Body('successNum')
    failDetail = resource2.Body('failDetail', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
class QueryRealnameAuth(resource2.Resource):
    base_path = "%(domain_id)s/partner/customer-mgr/realname-auth/result"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True
    _query_mapping = resource2.QueryParameters('customerId')

    # User domain ID
    domain_id = resource2.URI('domain_id')
    # request
    # Customer ID.
    customerId = resource2.Body('customerId')

    reviewResult = resource2.Body('reviewResult')
    opinion = resource2.Body('opinion', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
Exemple #26
0
class QueryResourceStatusByOrderId(resource2.Resource):
    base_path = "%(domain_id)s/common/order-mgr/orders-resource/%(order_id)s"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters('offset', 'limit')

    # request
    # User domain ID
    domain_id = resource2.URI('domain_id')
    order_id = resource2.URI('order_id')
    offset = resource2.Body('offset')
    limit = resource2.Body('limit')

    # response
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Number of records that match the query conditions.
    totalSize = resource2.Body('totalSize')
    resources = resource2.Body('resources')

    def list(cls, session, **params):
        query_params = cls._query_mapping._transpose(params)
        uri = cls.get_list_uri(params)
        service = cls.get_service_filter(cls, session)
        endpoint_override = cls.service.get_endpoint_override()

        resp = session.get(uri,
                           endpoint_filter=cls.service,
                           microversion=service.microversion,
                           endpoint_override=endpoint_override,
                           headers={"Accept": "application/json"},
                           params=query_params)

        response_json = resp.json()
        if not response_json:
            return

        value = cls.existing(**response_json)
        return value
Exemple #27
0
class UnsubscribePeriodOrder(resource2.Resource):
    base_path = "%(domain_id)s/customer/order-mgr/orders/%(order_id)s"
    service = bss_intl_service.BssIntlService()

    allow_delete = True

    # User domain ID
    domain_id = resource2.URI('domain_id')
    order_id = resource2.URI('order_id')

    # request
    unsub_type = resource2.Body('unsub_type')
    unsubscribe_reason_type = resource2.Body('unsubscribe_reason_type')
    unsubscribe_reason = resource2.Body('unsubscribe_reason')

    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # New order ID generated for the unsubscription.
    unsub_order_ids = resource2.Body('unsub_order_ids')

    def delete(self, session, params=None, has_body=True):
        endpoint_override = self.service.get_endpoint_override()
        service = self.get_service_filter(self, session)
        request = self._prepare_request(requires_id=False, prepend_key=True)
        xstr = lambda s: '' if s is None else str(s)
        query_dict = {
            'unsub_type': self.unsub_type,
            'unsubscribe_reason_type': xstr(self.unsubscribe_reason_type),
            "unsubscribe_reason": xstr(self.unsubscribe_reason)
        }
        query_str = urlencode(query_dict, doseq=True)
        url = request.uri + '?' + query_str
        response = session.delete(url,
                                  endpoint_filter=self.service,
                                  microversion=service.microversion,
                                  endpoint_override=endpoint_override,
                                  headers=request.headers,
                                  params=params)
        self._translate_response(response)
        return self
Exemple #28
0
class QueryResourceUsageRecord(resource2.Resource):
    base_path = "%(domain_id)s/customer/account-mgr/bill/res-fee-records"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters(
        'startTime', 'endTime', 'cloudServiceTypeCode', 'regionCode',
    'orderId','payMethod','resourceId','enterpriseProjectId','offset','limit')

    # User domain ID
    domain_id = resource2.URI('domain_id')
    # request
    startTime = resource2.Body('startTime')
    endTime = resource2.Body('endTime')
    # Cloud service type code.
    cloudServiceTypeCode = resource2.Body('cloudServiceTypeCode')
    # Cloud service region code, for example, cn-north-1.
    regionCode = resource2.Body('regionCode')
    # Order ID.
    orderId = resource2.Body('orderId')
    # Billing mode.
    payMethod = resource2.Body('payMethod')
    # Queries resource IDs in batches.
    resourceId = resource2.Body('resourceId')
    # Enterprise project ID.
    enterpriseProjectId = resource2.Body('enterpriseProjectId')
    offset = resource2.Body('offset')
    limit = resource2.Body('limit')

    # response
    # currency
    currency = resource2.Body('currency')
    totalCount = resource2.Body('totalCount')
    # Resource usage record.
    feeRecords = resource2.Body('feeRecords', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Official website price
    official_amount  = resource2.Body('officialAmount')
Exemple #29
0
class QueryPartnerMonthlyBills(resource2.Resource):
    base_path = "%(domain_id)s/partner/account-mgr/postpaid-bill-summary"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters(
        'consume_month')

    # User domain ID
    domain_id = resource2.URI('domain_id')

    # request
    consume_month = resource2.Body('consume_month')

    # response
    billCycle = resource2.Body('billCycle')
    # Transaction amount/unsubscription amount/refund amount of the customer, including the vouchers, flexi-purchase coupons, reserved flexi-purchase coupons, and stored-value cards.
    creditDebtAmount = resource2.Body('creditDebtAmount')
    # Consumption amount of a cloud service, including the amount of cash coupons.
    consumeAmount = resource2.Body('consumeAmount')
    # Write-off amount (negative value), which is calculated based on the special commercial discount of the partner.
    writeoffdebt = resource2.Body('writeoffdebt')
    # Unsubscription amount (negative value), which is calculated based on the special commercial discount of the partner.
    unsubscribeAmount = resource2.Body('unsubscribeAmount')
    # Unit
    measureId = resource2.Body('measureId')
    # currency
    currency = resource2.Body('currency')
    # Tax amount, which is the tax amount in the creditDebtAmount field.
    taxAmount = resource2.Body('taxAmount')
    # Bill amount that is not settled, which is calculated based on the special commercial discount of the partner.
    unclearedAmount = resource2.Body('unclearedAmount')
    # Due date for bills.
    dueDate = resource2.Body('dueDate')
    # Bill list.
    billList = resource2.Body('billList')

    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
Exemple #30
0
class QueryResourceUsageDetails(resource2.Resource):
    base_path = "%(domain_id)s/customer/account-mgr/bill/res-records"
    service = bss_intl_service.BssIntlService()
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters(
        'cycle', 'cloudServiceTypeCode', 'resourceTypeCode', 'regionCode',
    'resInstanceId','payMethod','enterpriseProjectId','offset','limit')


    # User domain ID
    domain_id = resource2.URI('domain_id')
    # request
    # Expenditure month.
    cycle = resource2.Body('cycle')
    # Cloud service type code.
    cloudServiceTypeCode = resource2.Body('cloudServiceTypeCode')
    # Resource type code. For example, the VM resource type code of ECS is hws.resource.type.vm.
    resourceTypeCode = resource2.Body('resourceTypeCode')
    # Cloud service region code, for example, cn-north-1.
    regionCode = resource2.Body('regionCode')
    resInstanceId = resource2.Body('resInstanceId')
    # Billing mode.
    payMethod = resource2.Body('payMethod')
    # Enterprise project ID.
    enterpriseProjectId = resource2.Body('enterpriseProjectId')
    offset = resource2.Body('offset')
    limit = resource2.Body('limit')

    # response
    # currency
    currency = resource2.Body('currency')
    totalCount = resource2.Body('totalCount')
    monthlyRecords = resource2.Body('monthlyRecords', type=list)
    #  Status code.
    error_code = resource2.Body('error_code')
    # Error description.
    error_msg = resource2.Body('error_msg')
    # Official website price
    official_amount  = resource2.Body('officialAmount')