handlebars.htmlDocs2.sample_python.mustache Maven / Gradle / Ivy
from __future__ import print_statement
import time
import {{{pythonPackageName}}}
from {{{pythonPackageName}}}.rest import ApiException
from pprint import pprint
{{#hasAuthMethods}}{{#authMethods}}{{#is this 'basic'}}
# Configure HTTP basic authorization: {{{name}}}
{{{pythonPackageName}}}.configuration.username = 'YOUR_USERNAME'
{{{pythonPackageName}}}.configuration.password = 'YOUR_PASSWORD'{{/is}}{{#is this 'api-key'}}
# Configure API key authorization: {{{name}}}
{{{pythonPackageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# {{{pythonPackageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/is}}{{#is this 'oauth'}}
# Configure OAuth2 access token for authorization: {{{name}}}
{{{pythonPackageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/is}}{{/authMethods}}
{{/hasAuthMethods}}
# create an instance of the API class
api_instance = {{{pythonPackageName}}}.{{{classname}}}()
{{#parameters}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{unescapedDescription}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
{{/parameters}}
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationIdSnakeCase}}}({{#parameters}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#has this 'more'}}, {{/has}}{{/parameters}}){{#returnType}}
pprint(api_response){{/returnType}}
except ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
© 2015 - 2024 Weber Informatics LLC | Privacy Policy