forked from loafle/openapi-generator-original
86 lines
3.8 KiB
Plaintext
86 lines
3.8 KiB
Plaintext
#!/usr/bin/env python
|
|
# coding: utf-8
|
|
|
|
"""
|
|
{{classname}}.py
|
|
Copyright 2015 Reverb Technologies, Inc.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
"""
|
|
import sys
|
|
import os
|
|
|
|
# python 2 and python 3 compatibility library
|
|
from six import iteritems
|
|
|
|
{{#operations}}
|
|
class {{classname}}(object):
|
|
|
|
def __init__(self, api_client):
|
|
self.api_client = api_client
|
|
|
|
{{#operation}}
|
|
def {{nickname}}(self, {{#requiredParams}}{{paramName}}{{#defaultValue}} = None{{/defaultValue}}, {{/requiredParams}}**kwargs):
|
|
"""
|
|
{{{summary}}}
|
|
{{{notes}}}
|
|
|
|
{{#allParams}}
|
|
:param {{dataType}} {{paramName}}: {{{description}}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
|
|
{{/allParams}}
|
|
|
|
:return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
|
"""
|
|
|
|
all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}]
|
|
|
|
params = locals()
|
|
for key, val in iteritems(params['kwargs']):
|
|
if key not in all_params:
|
|
raise TypeError("Got an unexpected keyword argument '%s' to method {{nickname}}" % key)
|
|
params[key] = val
|
|
del params['kwargs']
|
|
|
|
resource_path = '{{path}}'.replace('{format}', 'json')
|
|
method = '{{httpMethod}}'
|
|
|
|
path_params = dict({{#pathParams}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/pathParams}})
|
|
path_params = {k: v for k, v in iteritems(path_params) if v}
|
|
query_params = dict({{#queryParams}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/queryParams}})
|
|
query_params = {k: v for k, v in iteritems(query_params) if v}
|
|
header_params = dict({{#headerParams}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/headerParams}})
|
|
header_params = {k: v for k, v in iteritems(header_params) if v}
|
|
form_params = dict({{#formParams}}{{^isFile}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/isFile}}{{/formParams}})
|
|
form_params = {k: v for k, v in iteritems(form_params) if v}
|
|
files = dict({{#formParams}}{{#isFile}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/isFile}}{{/formParams}})
|
|
files = {k: v for k, v in iteritems(files) if v}
|
|
body_params = {{#bodyParam}}params.get('{{paramName}}'){{/bodyParam}}{{^bodyParam}}None{{/bodyParam}}
|
|
|
|
accepts = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
|
header_params['Accept'] = ', '.join(accepts)
|
|
|
|
content_types = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
|
header_params['Content-Type'] = content_types[0] if len(content_types) > 0 else 'application/json'
|
|
|
|
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
|
body=body_params, post_params=form_params, files=files,
|
|
response={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}})
|
|
{{#returnType}}
|
|
return response
|
|
{{/returnType}}
|
|
{{/operation}}
|
|
{{/operations}}
|
|
{{newline}}
|