|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +BillingApi.py |
| 5 | +Copyright 2016 SmartBear Software |
| 6 | +
|
| 7 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + you may not use this file except in compliance with the License. |
| 9 | + You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | + Unless required by applicable law or agreed to in writing, software |
| 14 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + See the License for the specific language governing permissions and |
| 17 | + limitations under the License. |
| 18 | +""" |
| 19 | + |
| 20 | +from __future__ import absolute_import |
| 21 | + |
| 22 | +import sys |
| 23 | +import os |
| 24 | +import re |
| 25 | + |
| 26 | +# python 2 and python 3 compatibility library |
| 27 | +from six import iteritems |
| 28 | + |
| 29 | +from ..configuration import Configuration |
| 30 | +from ..api_client import ApiClient |
| 31 | + |
| 32 | + |
| 33 | +class BillingApi(object): |
| 34 | + """ |
| 35 | + NOTE: This class is auto generated by the swagger code generator program. |
| 36 | + Do not edit the class manually. |
| 37 | + Ref: https://github.com/swagger-api/swagger-codegen |
| 38 | + """ |
| 39 | + |
| 40 | + def __init__(self, api_client=None): |
| 41 | + config = Configuration() |
| 42 | + if api_client: |
| 43 | + self.api_client = api_client |
| 44 | + else: |
| 45 | + if not config.api_client: |
| 46 | + config.api_client = ApiClient() |
| 47 | + self.api_client = config.api_client |
| 48 | + |
| 49 | + def get_billing_reports_billableusage(self, start_date, end_date, **kwargs): |
| 50 | + """ |
| 51 | + Get a report of the billable usages (e.g. licenses and devices utilized) for a given period. |
| 52 | + |
| 53 | +
|
| 54 | + This method makes a synchronous HTTP request by default. To make an |
| 55 | + asynchronous HTTP request, please define a `callback` function |
| 56 | + to be invoked when receiving the response. |
| 57 | + >>> def callback_function(response): |
| 58 | + >>> pprint(response) |
| 59 | + >>> |
| 60 | + >>> thread = api.get_billing_reports_billableusage(start_date, end_date, callback=callback_function) |
| 61 | +
|
| 62 | + :param callback function: The callback function |
| 63 | + for asynchronous request. (optional) |
| 64 | + :param datetime start_date: The period start date. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss.SSSZ (required) |
| 65 | + :param datetime end_date: The period end date. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss.SSSZ (required) |
| 66 | + :return: BillingUsageReport |
| 67 | + If the method is called asynchronously, |
| 68 | + returns the request thread. |
| 69 | + """ |
| 70 | + |
| 71 | + all_params = ['start_date', 'end_date'] |
| 72 | + all_params.append('callback') |
| 73 | + |
| 74 | + params = locals() |
| 75 | + for key, val in iteritems(params['kwargs']): |
| 76 | + if key not in all_params: |
| 77 | + raise TypeError( |
| 78 | + "Got an unexpected keyword argument '%s'" |
| 79 | + " to method get_billing_reports_billableusage" % key |
| 80 | + ) |
| 81 | + params[key] = val |
| 82 | + del params['kwargs'] |
| 83 | + |
| 84 | + # verify the required parameter 'start_date' is set |
| 85 | + if ('start_date' not in params) or (params['start_date'] is None): |
| 86 | + raise ValueError("Missing the required parameter `start_date` when calling `get_billing_reports_billableusage`") |
| 87 | + # verify the required parameter 'end_date' is set |
| 88 | + if ('end_date' not in params) or (params['end_date'] is None): |
| 89 | + raise ValueError("Missing the required parameter `end_date` when calling `get_billing_reports_billableusage`") |
| 90 | + |
| 91 | + |
| 92 | + resource_path = '/api/v2/billing/reports/billableusage'.replace('{format}', 'json') |
| 93 | + path_params = {} |
| 94 | + |
| 95 | + query_params = {} |
| 96 | + if 'start_date' in params: |
| 97 | + query_params['startDate'] = params['start_date'] |
| 98 | + if 'end_date' in params: |
| 99 | + query_params['endDate'] = params['end_date'] |
| 100 | + |
| 101 | + header_params = {} |
| 102 | + |
| 103 | + form_params = [] |
| 104 | + local_var_files = {} |
| 105 | + |
| 106 | + body_params = None |
| 107 | + |
| 108 | + # HTTP header `Accept` |
| 109 | + header_params['Accept'] = self.api_client.\ |
| 110 | + select_header_accept(['application/json']) |
| 111 | + if not header_params['Accept']: |
| 112 | + del header_params['Accept'] |
| 113 | + |
| 114 | + # HTTP header `Content-Type` |
| 115 | + header_params['Content-Type'] = self.api_client.\ |
| 116 | + select_header_content_type(['application/json']) |
| 117 | + |
| 118 | + # Authentication setting |
| 119 | + auth_settings = ['PureCloud Auth'] |
| 120 | + |
| 121 | + response = self.api_client.call_api(resource_path, 'GET', |
| 122 | + path_params, |
| 123 | + query_params, |
| 124 | + header_params, |
| 125 | + body=body_params, |
| 126 | + post_params=form_params, |
| 127 | + files=local_var_files, |
| 128 | + response_type='BillingUsageReport', |
| 129 | + auth_settings=auth_settings, |
| 130 | + callback=params.get('callback')) |
| 131 | + return response |
0 commit comments