mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 18:16:08 +00:00
[python] Cleanup ThreadPool with atexit rather than __del__ (#5094)
* [python] Cleanup ThreadPool with atexit rather than __del__ This removes the `__del__` function from the generated Python client, and replaces it with a `cleanup` function. When a ThreadPool is created, the cleanup function is registered with the `atexit` module. This fixes #5093, where the API client could hang indefinitely at garbage collection. * Update petstore examples * Test to ensure threadpool is cleaned up * Docs now encourage using the context manager * Regenerate docs * Update samples
This commit is contained in:
committed by
GitHub
parent
d627282e89
commit
15345e1620
@@ -2,6 +2,7 @@
|
||||
{{>partial_header}}
|
||||
from __future__ import absolute_import
|
||||
|
||||
import atexit
|
||||
import datetime
|
||||
from dateutil.parser import parse
|
||||
import json
|
||||
@@ -75,11 +76,19 @@ class ApiClient(object):
|
||||
self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}'
|
||||
self.client_side_validation = configuration.client_side_validation
|
||||
|
||||
def __del__(self):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, 'unregister'):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
@@ -87,6 +96,7 @@ class ApiClient(object):
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
|
||||
@@ -8,14 +8,18 @@ from pprint import pprint
|
||||
{{#hasAuthMethods}}
|
||||
# Defining host is optional and default to {{{basePath}}}
|
||||
configuration.host = "{{{basePath}}}"
|
||||
# Enter a context with an instance of the API client
|
||||
with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration))
|
||||
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
||||
{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/allParams}}
|
||||
{{/hasAuthMethods}}
|
||||
{{^hasAuthMethods}}
|
||||
# Enter a context with an instance of the API client
|
||||
with {{{packageName}}}.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{{packageName}}}.{{{classname}}}()
|
||||
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
||||
{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/allParams}}
|
||||
{{/hasAuthMethods}}
|
||||
|
||||
@@ -8,8 +8,10 @@ from pprint import pprint
|
||||
{{> python_doc_auth_partial}}
|
||||
# Defining host is optional and default to {{{basePath}}}
|
||||
configuration.host = "{{{basePath}}}"
|
||||
# Enter a context with an instance of the API client
|
||||
with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration))
|
||||
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
||||
{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ from pprint import pprint
|
||||
{{> python_doc_auth_partial}}
|
||||
# Defining host is optional and default to {{{basePath}}}
|
||||
configuration.host = "{{{basePath}}}"
|
||||
# Enter a context with an instance of the API client
|
||||
with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration))
|
||||
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
||||
{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import json
|
||||
import atexit
|
||||
import mimetypes
|
||||
from multiprocessing.pool import ThreadPool
|
||||
import os
|
||||
@@ -74,11 +75,19 @@ class ApiClient(object):
|
||||
# Set default User-Agent.
|
||||
self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}'
|
||||
|
||||
def __del__(self):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, 'unregister'):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
@@ -86,6 +95,7 @@ class ApiClient(object):
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
|
||||
@@ -7,12 +7,16 @@ from pprint import pprint
|
||||
{{#hasAuthMethods}}
|
||||
# Defining host is optional and default to {{{basePath}}}
|
||||
configuration.host = "{{{basePath}}}"
|
||||
# Enter a context with an instance of the API client
|
||||
with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration))
|
||||
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
||||
{{/hasAuthMethods}}
|
||||
{{^hasAuthMethods}}
|
||||
# Enter a context with an instance of the API client
|
||||
with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{{packageName}}}.{{{classname}}}()
|
||||
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
||||
{{/hasAuthMethods}}
|
||||
{{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}
|
||||
{{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}
|
||||
|
||||
@@ -54,8 +54,10 @@ from pprint import pprint
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -23,8 +23,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi()
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -36,8 +36,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
|
||||
|
||||
try:
|
||||
@@ -89,8 +91,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = True # bool | Input boolean as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -142,8 +146,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -195,8 +201,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 3.4 # float | Input number as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -248,8 +256,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 'body_example' # str | Input string as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -301,8 +311,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
|
||||
|
||||
try:
|
||||
@@ -351,8 +363,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
query = 'query_example' # str |
|
||||
body = petstore_api.User() # User |
|
||||
|
||||
@@ -405,8 +419,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
@@ -466,8 +482,10 @@ configuration.password = 'YOUR_PASSWORD'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
number = 3.4 # float | None
|
||||
double = 3.4 # float | None
|
||||
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
|
||||
@@ -546,8 +564,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
|
||||
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
|
||||
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
|
||||
@@ -614,8 +634,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
required_string_group = 56 # int | Required String in group parameters
|
||||
required_boolean_group = True # bool | Required Boolean in group parameters
|
||||
required_int64_group = 56 # int | Required Integer in group parameters
|
||||
@@ -675,8 +697,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = {'key': 'param_example'} # dict(str, str) | request body
|
||||
|
||||
try:
|
||||
@@ -726,8 +750,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = 'param_example' # str | field1
|
||||
param2 = 'param2_example' # str | field2
|
||||
|
||||
@@ -781,8 +807,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
pipe = ['pipe_example'] # list[str] |
|
||||
ioutil = ['ioutil_example'] # list[str] |
|
||||
http = ['http_example'] # list[str] |
|
||||
|
||||
@@ -31,8 +31,10 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -35,8 +35,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
@@ -93,8 +95,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | Pet id to delete
|
||||
api_key = 'api_key_example' # str | (optional)
|
||||
|
||||
@@ -155,8 +159,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
status = ['status_example'] # list[str] | Status values that need to be considered for filter
|
||||
|
||||
try:
|
||||
@@ -216,8 +222,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
tags = ['tags_example'] # list[str] | Tags to filter by
|
||||
|
||||
try:
|
||||
@@ -279,8 +287,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to return
|
||||
|
||||
try:
|
||||
@@ -339,8 +349,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
@@ -399,8 +411,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet that needs to be updated
|
||||
name = 'name_example' # str | Updated name of the pet (optional)
|
||||
status = 'status_example' # str | Updated status of the pet (optional)
|
||||
@@ -460,8 +474,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
file = '/path/to/file' # file | file to upload (optional)
|
||||
@@ -522,8 +538,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
required_file = '/path/to/file' # file | file to upload
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
|
||||
@@ -26,8 +26,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
|
||||
|
||||
try:
|
||||
@@ -88,8 +90,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
|
||||
try:
|
||||
# Returns pet inventories by status
|
||||
@@ -138,8 +142,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 56 # int | ID of pet that needs to be fetched
|
||||
|
||||
try:
|
||||
@@ -192,8 +198,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
body = petstore_api.Order() # Order | order placed for purchasing the pet
|
||||
|
||||
try:
|
||||
|
||||
@@ -30,8 +30,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = petstore_api.User() # User | Created user object
|
||||
|
||||
try:
|
||||
@@ -81,8 +83,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = [petstore_api.User()] # list[User] | List of user object
|
||||
|
||||
try:
|
||||
@@ -132,8 +136,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = [petstore_api.User()] # list[User] | List of user object
|
||||
|
||||
try:
|
||||
@@ -185,8 +191,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be deleted
|
||||
|
||||
try:
|
||||
@@ -237,8 +245,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
try:
|
||||
@@ -291,8 +301,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The user name for login
|
||||
password = 'password_example' # str | The password for login in clear text
|
||||
|
||||
@@ -346,8 +358,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
|
||||
try:
|
||||
# Logs out current logged in user session
|
||||
@@ -395,8 +409,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | name that need to be deleted
|
||||
body = petstore_api.User() # User | Updated user object
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import atexit
|
||||
import datetime
|
||||
from dateutil.parser import parse
|
||||
import json
|
||||
@@ -80,11 +81,19 @@ class ApiClient(object):
|
||||
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
|
||||
self.client_side_validation = configuration.client_side_validation
|
||||
|
||||
def __del__(self):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, 'unregister'):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
@@ -92,6 +101,7 @@ class ApiClient(object):
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
|
||||
@@ -53,8 +53,10 @@ from pprint import pprint
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
body = petstore_api.Client() # client.Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -22,8 +22,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi()
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
body = petstore_api.Client() # client.Client | client model
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
|
||||
@@ -36,8 +36,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
xml_item = petstore_api.XmlItem() # xml_item.XmlItem | XmlItem Body
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -89,8 +91,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = True # bool | Input boolean as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -143,8 +147,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -197,8 +203,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.OuterEnum("placed") # outer_enum.OuterEnum | Input enum as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -251,8 +259,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.OuterNumber(3.4) # outer_number.OuterNumber | Input number as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -305,8 +315,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 'body_example' # str | Input string as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -359,8 +371,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass |
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -409,8 +423,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
query = 'query_example' # str |
|
||||
body = petstore_api.User() # user.User |
|
||||
|
||||
@@ -463,8 +479,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.Client() # client.Client | client model
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -517,8 +535,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
@@ -579,8 +599,10 @@ configuration.password = 'YOUR_PASSWORD'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
number = 3.4 # float | None
|
||||
double = 3.4 # float | None
|
||||
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
|
||||
@@ -667,8 +689,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
|
||||
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
|
||||
enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional)
|
||||
@@ -736,8 +760,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
required_string_group = 56 # int | Required String in group parameters
|
||||
required_boolean_group = True # bool | Required Boolean in group parameters
|
||||
required_int64_group = 56 # int | Required Integer in group parameters
|
||||
@@ -805,8 +831,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = {'key': 'param_example'} # {str: (str,)} | request body
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -856,8 +884,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = 'param_example' # str | field1
|
||||
param2 = 'param2_example' # str | field2
|
||||
|
||||
|
||||
@@ -30,8 +30,10 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
|
||||
body = petstore_api.Client() # client.Client | client model
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
|
||||
@@ -34,8 +34,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
body = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -92,8 +94,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | Pet id to delete
|
||||
api_key = 'api_key_example' # str | (optional)
|
||||
|
||||
@@ -162,8 +166,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
status = ['status_example'] # [str] | Status values that need to be considered for filter
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -223,8 +229,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
tags = ['tags_example'] # [str] | Tags to filter by
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -286,8 +294,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to return
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -346,8 +356,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
body = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -406,8 +418,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet that needs to be updated
|
||||
name = 'name_example' # str | Updated name of the pet (optional)
|
||||
status = 'status_example' # str | Updated status of the pet (optional)
|
||||
@@ -475,8 +489,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
|
||||
@@ -548,8 +564,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
required_file = open('/path/to/file', 'rb') # file_type | file to upload
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
|
||||
@@ -25,8 +25,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -87,8 +89,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
|
||||
# example, this endpoint has no required or optional parameters
|
||||
try:
|
||||
@@ -137,8 +141,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 56 # int | ID of pet that needs to be fetched
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -191,8 +197,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
body = petstore_api.Order() # order.Order | order placed for purchasing the pet
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
|
||||
@@ -29,8 +29,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = petstore_api.User() # user.User | Created user object
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -80,8 +82,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = [petstore_api.User()] # [user.User] | List of user object
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -131,8 +135,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = [petstore_api.User()] # [user.User] | List of user object
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -184,8 +190,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be deleted
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -236,8 +244,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -290,8 +300,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The user name for login
|
||||
password = 'password_example' # str | The password for login in clear text
|
||||
|
||||
@@ -345,8 +357,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
|
||||
# example, this endpoint has no required or optional parameters
|
||||
try:
|
||||
@@ -394,8 +408,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | name that need to be deleted
|
||||
body = petstore_api.User() # user.User | Updated user object
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import json
|
||||
import atexit
|
||||
import mimetypes
|
||||
from multiprocessing.pool import ThreadPool
|
||||
import os
|
||||
@@ -79,11 +80,19 @@ class ApiClient(object):
|
||||
# Set default User-Agent.
|
||||
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
|
||||
|
||||
def __del__(self):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, 'unregister'):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
@@ -91,6 +100,7 @@ class ApiClient(object):
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ $ nosetests -v
|
||||
|
||||
import os
|
||||
import time
|
||||
import atexit
|
||||
import weakref
|
||||
import unittest
|
||||
from dateutil.parser import parse
|
||||
|
||||
@@ -199,3 +201,17 @@ class ApiClientTests(unittest.TestCase):
|
||||
model = petstore_api.StringBooleanMap(**model_dict)
|
||||
result = self.api_client.sanitize_for_serialization(model)
|
||||
self.assertEqual(result, model_dict)
|
||||
|
||||
def test_context_manager_closes_threadpool(self):
|
||||
with petstore_api.ApiClient() as client:
|
||||
self.assertIsNotNone(client.pool)
|
||||
pool_ref = weakref.ref(client._pool)
|
||||
self.assertIsNotNone(pool_ref())
|
||||
self.assertIsNone(pool_ref())
|
||||
|
||||
def test_atexit_closes_threadpool(self):
|
||||
client = petstore_api.ApiClient()
|
||||
self.assertIsNotNone(client.pool)
|
||||
self.assertIsNotNone(client._pool)
|
||||
atexit._run_exitfuncs()
|
||||
self.assertIsNone(client._pool)
|
||||
|
||||
@@ -54,8 +54,10 @@ from pprint import pprint
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -23,8 +23,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi()
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -36,8 +36,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
|
||||
|
||||
try:
|
||||
@@ -89,8 +91,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = True # bool | Input boolean as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -142,8 +146,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -195,8 +201,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 3.4 # float | Input number as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -248,8 +256,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 'body_example' # str | Input string as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -301,8 +311,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
|
||||
|
||||
try:
|
||||
@@ -351,8 +363,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
query = 'query_example' # str |
|
||||
body = petstore_api.User() # User |
|
||||
|
||||
@@ -405,8 +419,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
@@ -466,8 +482,10 @@ configuration.password = 'YOUR_PASSWORD'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
number = 3.4 # float | None
|
||||
double = 3.4 # float | None
|
||||
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
|
||||
@@ -546,8 +564,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
|
||||
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
|
||||
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
|
||||
@@ -614,8 +634,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
required_string_group = 56 # int | Required String in group parameters
|
||||
required_boolean_group = True # bool | Required Boolean in group parameters
|
||||
required_int64_group = 56 # int | Required Integer in group parameters
|
||||
@@ -675,8 +697,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = {'key': 'param_example'} # dict(str, str) | request body
|
||||
|
||||
try:
|
||||
@@ -726,8 +750,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = 'param_example' # str | field1
|
||||
param2 = 'param2_example' # str | field2
|
||||
|
||||
@@ -781,8 +807,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
pipe = ['pipe_example'] # list[str] |
|
||||
ioutil = ['ioutil_example'] # list[str] |
|
||||
http = ['http_example'] # list[str] |
|
||||
|
||||
@@ -31,8 +31,10 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -35,8 +35,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
@@ -93,8 +95,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | Pet id to delete
|
||||
api_key = 'api_key_example' # str | (optional)
|
||||
|
||||
@@ -155,8 +159,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
status = ['status_example'] # list[str] | Status values that need to be considered for filter
|
||||
|
||||
try:
|
||||
@@ -216,8 +222,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
tags = ['tags_example'] # list[str] | Tags to filter by
|
||||
|
||||
try:
|
||||
@@ -279,8 +287,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to return
|
||||
|
||||
try:
|
||||
@@ -339,8 +349,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
@@ -399,8 +411,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet that needs to be updated
|
||||
name = 'name_example' # str | Updated name of the pet (optional)
|
||||
status = 'status_example' # str | Updated status of the pet (optional)
|
||||
@@ -460,8 +474,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
file = '/path/to/file' # file | file to upload (optional)
|
||||
@@ -522,8 +538,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
required_file = '/path/to/file' # file | file to upload
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
|
||||
@@ -26,8 +26,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
|
||||
|
||||
try:
|
||||
@@ -88,8 +90,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
|
||||
try:
|
||||
# Returns pet inventories by status
|
||||
@@ -138,8 +142,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 56 # int | ID of pet that needs to be fetched
|
||||
|
||||
try:
|
||||
@@ -192,8 +198,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
body = petstore_api.Order() # Order | order placed for purchasing the pet
|
||||
|
||||
try:
|
||||
|
||||
@@ -30,8 +30,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = petstore_api.User() # User | Created user object
|
||||
|
||||
try:
|
||||
@@ -81,8 +83,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = [petstore_api.User()] # list[User] | List of user object
|
||||
|
||||
try:
|
||||
@@ -132,8 +136,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = [petstore_api.User()] # list[User] | List of user object
|
||||
|
||||
try:
|
||||
@@ -185,8 +191,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be deleted
|
||||
|
||||
try:
|
||||
@@ -237,8 +245,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
try:
|
||||
@@ -291,8 +301,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The user name for login
|
||||
password = 'password_example' # str | The password for login in clear text
|
||||
|
||||
@@ -346,8 +358,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
|
||||
try:
|
||||
# Logs out current logged in user session
|
||||
@@ -395,8 +409,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | name that need to be deleted
|
||||
body = petstore_api.User() # User | Updated user object
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import atexit
|
||||
import datetime
|
||||
from dateutil.parser import parse
|
||||
import json
|
||||
@@ -81,11 +82,19 @@ class ApiClient(object):
|
||||
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
|
||||
self.client_side_validation = configuration.client_side_validation
|
||||
|
||||
def __del__(self):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, 'unregister'):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
@@ -93,6 +102,7 @@ class ApiClient(object):
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
|
||||
@@ -54,8 +54,10 @@ from pprint import pprint
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -23,8 +23,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi()
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -36,8 +36,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
|
||||
|
||||
try:
|
||||
@@ -89,8 +91,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = True # bool | Input boolean as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -142,8 +146,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -195,8 +201,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 3.4 # float | Input number as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -248,8 +256,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 'body_example' # str | Input string as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -301,8 +311,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
|
||||
|
||||
try:
|
||||
@@ -351,8 +363,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
query = 'query_example' # str |
|
||||
body = petstore_api.User() # User |
|
||||
|
||||
@@ -405,8 +419,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
@@ -466,8 +482,10 @@ configuration.password = 'YOUR_PASSWORD'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
number = 3.4 # float | None
|
||||
double = 3.4 # float | None
|
||||
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
|
||||
@@ -546,8 +564,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
|
||||
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
|
||||
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
|
||||
@@ -614,8 +634,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
required_string_group = 56 # int | Required String in group parameters
|
||||
required_boolean_group = True # bool | Required Boolean in group parameters
|
||||
required_int64_group = 56 # int | Required Integer in group parameters
|
||||
@@ -675,8 +697,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = {'key': 'param_example'} # dict(str, str) | request body
|
||||
|
||||
try:
|
||||
@@ -726,8 +750,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = 'param_example' # str | field1
|
||||
param2 = 'param2_example' # str | field2
|
||||
|
||||
@@ -781,8 +807,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
pipe = ['pipe_example'] # list[str] |
|
||||
ioutil = ['ioutil_example'] # list[str] |
|
||||
http = ['http_example'] # list[str] |
|
||||
|
||||
@@ -31,8 +31,10 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
|
||||
body = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -35,8 +35,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
@@ -93,8 +95,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | Pet id to delete
|
||||
api_key = 'api_key_example' # str | (optional)
|
||||
|
||||
@@ -155,8 +159,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
status = ['status_example'] # list[str] | Status values that need to be considered for filter
|
||||
|
||||
try:
|
||||
@@ -216,8 +222,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
tags = ['tags_example'] # list[str] | Tags to filter by
|
||||
|
||||
try:
|
||||
@@ -279,8 +287,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to return
|
||||
|
||||
try:
|
||||
@@ -339,8 +349,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
@@ -399,8 +411,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet that needs to be updated
|
||||
name = 'name_example' # str | Updated name of the pet (optional)
|
||||
status = 'status_example' # str | Updated status of the pet (optional)
|
||||
@@ -460,8 +474,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
file = '/path/to/file' # file | file to upload (optional)
|
||||
@@ -522,8 +538,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
required_file = '/path/to/file' # file | file to upload
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
|
||||
@@ -26,8 +26,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
|
||||
|
||||
try:
|
||||
@@ -88,8 +90,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
|
||||
try:
|
||||
# Returns pet inventories by status
|
||||
@@ -138,8 +142,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 56 # int | ID of pet that needs to be fetched
|
||||
|
||||
try:
|
||||
@@ -192,8 +198,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
body = petstore_api.Order() # Order | order placed for purchasing the pet
|
||||
|
||||
try:
|
||||
|
||||
@@ -30,8 +30,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = petstore_api.User() # User | Created user object
|
||||
|
||||
try:
|
||||
@@ -81,8 +83,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = [petstore_api.User()] # list[User] | List of user object
|
||||
|
||||
try:
|
||||
@@ -132,8 +136,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
body = [petstore_api.User()] # list[User] | List of user object
|
||||
|
||||
try:
|
||||
@@ -185,8 +191,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be deleted
|
||||
|
||||
try:
|
||||
@@ -237,8 +245,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
try:
|
||||
@@ -291,8 +301,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The user name for login
|
||||
password = 'password_example' # str | The password for login in clear text
|
||||
|
||||
@@ -346,8 +358,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
|
||||
try:
|
||||
# Logs out current logged in user session
|
||||
@@ -395,8 +409,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | name that need to be deleted
|
||||
body = petstore_api.User() # User | Updated user object
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import atexit
|
||||
import datetime
|
||||
from dateutil.parser import parse
|
||||
import json
|
||||
@@ -80,11 +81,19 @@ class ApiClient(object):
|
||||
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
|
||||
self.client_side_validation = configuration.client_side_validation
|
||||
|
||||
def __del__(self):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, 'unregister'):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
@@ -92,6 +101,7 @@ class ApiClient(object):
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ $ nosetests -v
|
||||
|
||||
import os
|
||||
import time
|
||||
import atexit
|
||||
import weakref
|
||||
import unittest
|
||||
from dateutil.parser import parse
|
||||
|
||||
@@ -169,3 +171,17 @@ class ApiClientTests(unittest.TestCase):
|
||||
data = [pet]
|
||||
result = self.api_client.sanitize_for_serialization(data)
|
||||
self.assertEqual(result, list_of_pet_dict)
|
||||
|
||||
def test_context_manager_closes_threadpool(self):
|
||||
with petstore_api.ApiClient() as client:
|
||||
self.assertIsNotNone(client.pool)
|
||||
pool_ref = weakref.ref(client._pool)
|
||||
self.assertIsNotNone(pool_ref())
|
||||
self.assertIsNone(pool_ref())
|
||||
|
||||
def test_atexit_closes_threadpool(self):
|
||||
client = petstore_api.ApiClient()
|
||||
self.assertIsNotNone(client.pool)
|
||||
self.assertIsNotNone(client._pool)
|
||||
atexit._run_exitfuncs()
|
||||
self.assertIsNone(client._pool)
|
||||
|
||||
@@ -53,8 +53,10 @@ from pprint import pprint
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
client_client = petstore_api.Client() # client.Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -22,8 +22,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi()
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
client_client = petstore_api.Client() # client.Client | client model
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
|
||||
@@ -20,8 +20,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.DefaultApi()
|
||||
api_instance = petstore_api.DefaultApi(api_client)
|
||||
|
||||
# example, this endpoint has no required or optional parameters
|
||||
try:
|
||||
|
||||
@@ -33,8 +33,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
|
||||
# example, this endpoint has no required or optional parameters
|
||||
try:
|
||||
@@ -83,8 +85,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = True # bool | Input boolean as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -137,8 +141,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
outer_composite_outer_composite = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -191,8 +197,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 3.4 # float | Input number as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -245,8 +253,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 'body_example' # str | Input string as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -299,8 +309,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
file_schema_test_class_file_schema_test_class = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass |
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -349,8 +361,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
query = 'query_example' # str |
|
||||
user_user = petstore_api.User() # user.User |
|
||||
|
||||
@@ -403,8 +417,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
client_client = petstore_api.Client() # client.Client | client model
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -464,8 +480,10 @@ configuration.password = 'YOUR_PASSWORD'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
number = 3.4 # float | None
|
||||
double = 3.4 # float | None
|
||||
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
|
||||
@@ -552,8 +570,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
|
||||
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
|
||||
enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional)
|
||||
@@ -627,8 +647,10 @@ configuration.access_token = 'YOUR_BEARER_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
required_string_group = 56 # int | Required String in group parameters
|
||||
required_boolean_group = True # bool | Required Boolean in group parameters
|
||||
required_int64_group = 56 # int | Required Integer in group parameters
|
||||
@@ -696,8 +718,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
request_body = {'key': 'request_body_example'} # {str: (str,)} | request body
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -747,8 +771,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = 'param_example' # str | field1
|
||||
param2 = 'param2_example' # str | field2
|
||||
|
||||
@@ -802,8 +828,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
pipe = ['pipe_example'] # [str] |
|
||||
ioutil = ['ioutil_example'] # [str] |
|
||||
http = ['http_example'] # [str] |
|
||||
|
||||
@@ -30,8 +30,10 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
|
||||
client_client = petstore_api.Client() # client.Client | client model
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
|
||||
@@ -55,8 +55,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_pet = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -112,8 +114,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | Pet id to delete
|
||||
api_key = 'api_key_example' # str | (optional)
|
||||
|
||||
@@ -202,8 +206,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
status = ['status_example'] # [str] | Status values that need to be considered for filter
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -284,8 +290,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
tags = ['tags_example'] # [str] | Tags to filter by
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -347,8 +355,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to return
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -428,8 +438,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_pet = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -487,8 +499,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet that needs to be updated
|
||||
name = 'name_example' # str | Updated name of the pet (optional)
|
||||
status = 'status_example' # str | Updated status of the pet (optional)
|
||||
@@ -556,8 +570,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
|
||||
@@ -627,8 +643,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
required_file = open('/path/to/file', 'rb') # file_type | file to upload
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
|
||||
@@ -25,8 +25,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -87,8 +89,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
|
||||
# example, this endpoint has no required or optional parameters
|
||||
try:
|
||||
@@ -137,8 +141,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 56 # int | ID of pet that needs to be fetched
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -191,8 +197,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_order = petstore_api.Order() # order.Order | order placed for purchasing the pet
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
|
||||
@@ -29,8 +29,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
user_user = petstore_api.User() # user.User | Created user object
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -80,8 +82,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
user_user = [petstore_api.User()] # [user.User] | List of user object
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -131,8 +135,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
user_user = [petstore_api.User()] # [user.User] | List of user object
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -184,8 +190,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be deleted
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -236,8 +244,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
@@ -290,8 +300,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The user name for login
|
||||
password = 'password_example' # str | The password for login in clear text
|
||||
|
||||
@@ -345,8 +357,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
|
||||
# example, this endpoint has no required or optional parameters
|
||||
try:
|
||||
@@ -394,8 +408,10 @@ import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | name that need to be deleted
|
||||
user_user = petstore_api.User() # user.User | Updated user object
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import json
|
||||
import atexit
|
||||
import mimetypes
|
||||
from multiprocessing.pool import ThreadPool
|
||||
import os
|
||||
@@ -79,11 +80,19 @@ class ApiClient(object):
|
||||
# Set default User-Agent.
|
||||
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
|
||||
|
||||
def __del__(self):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, 'unregister'):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
@@ -91,6 +100,7 @@ class ApiClient(object):
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
|
||||
@@ -54,8 +54,10 @@ from pprint import pprint
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
client = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -23,8 +23,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi()
|
||||
api_instance = petstore_api.AnotherFakeApi(api_client)
|
||||
client = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -21,8 +21,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.DefaultApi()
|
||||
api_instance = petstore_api.DefaultApi(api_client)
|
||||
|
||||
try:
|
||||
api_response = api_instance.foo_get()
|
||||
|
||||
@@ -34,8 +34,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
|
||||
try:
|
||||
# Health check endpoint
|
||||
@@ -84,8 +86,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = True # bool | Input boolean as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -137,8 +141,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
outer_composite = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -190,8 +196,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 3.4 # float | Input number as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -243,8 +251,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
body = 'body_example' # str | Input string as post body (optional)
|
||||
|
||||
try:
|
||||
@@ -296,8 +306,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
file_schema_test_class = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
|
||||
|
||||
try:
|
||||
@@ -346,8 +358,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
query = 'query_example' # str |
|
||||
user = petstore_api.User() # User |
|
||||
|
||||
@@ -400,8 +414,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
client = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
@@ -461,8 +477,10 @@ configuration.password = 'YOUR_PASSWORD'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
number = 3.4 # float | None
|
||||
double = 3.4 # float | None
|
||||
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
|
||||
@@ -541,8 +559,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
|
||||
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
|
||||
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
|
||||
@@ -615,8 +635,10 @@ configuration.access_token = 'YOUR_BEARER_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
required_string_group = 56 # int | Required String in group parameters
|
||||
required_boolean_group = True # bool | Required Boolean in group parameters
|
||||
required_int64_group = 56 # int | Required Integer in group parameters
|
||||
@@ -676,8 +698,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
request_body = {'key': 'request_body_example'} # dict(str, str) | request body
|
||||
|
||||
try:
|
||||
@@ -727,8 +751,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
param = 'param_example' # str | field1
|
||||
param2 = 'param2_example' # str | field2
|
||||
|
||||
@@ -782,8 +808,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
api_instance = petstore_api.FakeApi(api_client)
|
||||
pipe = ['pipe_example'] # list[str] |
|
||||
ioutil = ['ioutil_example'] # list[str] |
|
||||
http = ['http_example'] # list[str] |
|
||||
|
||||
@@ -31,8 +31,10 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
|
||||
client = petstore_api.Client() # Client | client model
|
||||
|
||||
try:
|
||||
|
||||
@@ -35,8 +35,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
@@ -92,8 +94,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | Pet id to delete
|
||||
api_key = 'api_key_example' # str | (optional)
|
||||
|
||||
@@ -153,8 +157,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
status = ['status_example'] # list[str] | Status values that need to be considered for filter
|
||||
|
||||
try:
|
||||
@@ -214,8 +220,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
tags = ['tags_example'] # list[str] | Tags to filter by
|
||||
|
||||
try:
|
||||
@@ -277,8 +285,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to return
|
||||
|
||||
try:
|
||||
@@ -337,8 +347,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
@@ -396,8 +408,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet that needs to be updated
|
||||
name = 'name_example' # str | Updated name of the pet (optional)
|
||||
status = 'status_example' # str | Updated status of the pet (optional)
|
||||
@@ -457,8 +471,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
file = '/path/to/file' # file | file to upload (optional)
|
||||
@@ -519,8 +535,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
required_file = '/path/to/file' # file | file to upload
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
|
||||
@@ -26,8 +26,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
|
||||
|
||||
try:
|
||||
@@ -88,8 +90,10 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
|
||||
|
||||
# Defining host is optional and default to http://petstore.swagger.io:80/v2
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
|
||||
try:
|
||||
# Returns pet inventories by status
|
||||
@@ -138,8 +142,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order_id = 56 # int | ID of pet that needs to be fetched
|
||||
|
||||
try:
|
||||
@@ -192,8 +198,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
api_instance = petstore_api.StoreApi(api_client)
|
||||
order = petstore_api.Order() # Order | order placed for purchasing the pet
|
||||
|
||||
try:
|
||||
|
||||
@@ -30,8 +30,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
user = petstore_api.User() # User | Created user object
|
||||
|
||||
try:
|
||||
@@ -81,8 +83,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
user = [petstore_api.User()] # list[User] | List of user object
|
||||
|
||||
try:
|
||||
@@ -132,8 +136,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
user = [petstore_api.User()] # list[User] | List of user object
|
||||
|
||||
try:
|
||||
@@ -185,8 +191,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be deleted
|
||||
|
||||
try:
|
||||
@@ -237,8 +245,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
try:
|
||||
@@ -291,8 +301,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | The user name for login
|
||||
password = 'password_example' # str | The password for login in clear text
|
||||
|
||||
@@ -346,8 +358,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
|
||||
try:
|
||||
# Logs out current logged in user session
|
||||
@@ -395,8 +409,10 @@ import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
api_instance = petstore_api.UserApi(api_client)
|
||||
username = 'username_example' # str | name that need to be deleted
|
||||
user = petstore_api.User() # User | Updated user object
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import atexit
|
||||
import datetime
|
||||
from dateutil.parser import parse
|
||||
import json
|
||||
@@ -80,11 +81,19 @@ class ApiClient(object):
|
||||
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
|
||||
self.client_side_validation = configuration.client_side_validation
|
||||
|
||||
def __del__(self):
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
if self._pool:
|
||||
self._pool.close()
|
||||
self._pool.join()
|
||||
self._pool = None
|
||||
if hasattr(atexit, 'unregister'):
|
||||
atexit.unregister(self.close)
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
@@ -92,6 +101,7 @@ class ApiClient(object):
|
||||
avoids instantiating unused threadpool for blocking clients.
|
||||
"""
|
||||
if self._pool is None:
|
||||
atexit.register(self.close)
|
||||
self._pool = ThreadPool(self.pool_threads)
|
||||
return self._pool
|
||||
|
||||
|
||||
Reference in New Issue
Block a user