Skip to content

Latest commit

 

History

History
223 lines (188 loc) · 9.88 KB

File metadata and controls

223 lines (188 loc) · 9.88 KB

petstore_api.paths.pet_pet_id_upload_image.operation

Operation Method Name

Method Name Api Class Notes
upload_image PetApi This api is only for tag=pet
post ApiForPost This api is only for this endpoint
post PetPetIdUploadImage This api is only for path=/pet/{petId}/uploadImage

Table of Contents

General Info

Field Value
Summary uploads an image
Description
Path "/pet/{petId}/uploadImage"
HTTP Method post

Arguments

Name Type Description Notes
body typing.Union[schema.SchemaDictInput, schema.SchemaDict, schemas.Unset] optional, default is unset
path_params PathParametersDictInput, PathParametersDict
content_type str optional, default is 'multipart/form-data' Selects the schema and serialization of the request body. value must be one of ['multipart/form-data']
accept_content_types typing.Tuple[str] default is ("application/json", ) Tells the server the content type(s) that are accepted by the client
security_index typing.Optional[int] default is None Allows one to select a different security definition. If not None, must be one of [0]
server_index typing.Optional[int] default is None Allows one to select a different server. If not None, must be one of [0, 1, 2]
stream bool default is False if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file
timeout typing.Optional[typing.Union[int, typing.Tuple]] default is None the timeout used by the rest client
skip_deserialization bool default is False when True, headers and body will be unset and an instance of api_response.ApiResponseWithoutDeserialization will be returned

RequestBody

Content Type To Schema

Content-Type Schema
"multipart/form-data" content.multipart_form_data.Schema

RequestBody content MultipartFormData Schema

type: schemas.Schema
validate method
Input Type Return Type Notes
SchemaDictInput, SchemaDict SchemaDict
RequestBody content MultipartFormData Schema SchemaDictInput
type: typing.Mapping[str, schemas.INPUT_TYPES_ALL]
Key Type Description Notes
additionalMetadata str Additional data to pass to server [optional]
file bytes, io.FileIO, io.BufferedReader file to upload [optional]
any_string_name dict, schemas.immutabledict, list, tuple, decimal.Decimal, float, int, str, datetime.date, datetime.datetime, uuid.UUID, bool, None, bytes, io.FileIO, io.BufferedReader, schemas.FileIO any string name can be used but the value must be the correct type [optional]
RequestBody content MultipartFormData Schema SchemaDict
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]

__new__ method
Keyword Argument Type Description Notes
additionalMetadata str, schemas.Unset Additional data to pass to server [optional]
file bytes, io.FileIO, io.BufferedReader, schemas.Unset file to upload [optional]
kwargs schemas.immutabledict, tuple, float, int, str, bool, None, bytes, schemas.FileIO any string name can be used but the value must be the correct type [optional] typed value is accessed with the get_additional_property_ method
properties
Property Type Description Notes
additionalMetadata str, schemas.Unset Additional data to pass to server [optional]
file bytes, io.FileIO, schemas.Unset file to upload [optional]
methods
Method Input Type Return Type Notes
from_dict_ SchemaDictInput, SchemaDict SchemaDict a constructor
get_additional_property_ str schemas.immutabledict, tuple, float, int, str, bool, None, bytes, schemas.FileIO, schemas.Unset provides type safety for additional properties

path_params

PathParameters

type: schemas.Schema

validate method

Input Type Return Type Notes
PathParametersDictInput, PathParametersDict PathParametersDict

PathParameters PathParametersDictInput

type: typing.TypedDict
Key Type Description Notes
petId int

PathParameters PathParametersDict

base class: schemas.immutabledict[str, int]

__new__ method
Keyword Argument Type Description Notes
petId int
properties
Property Type Description Notes
petId int
methods
Method Input Type Return Type Notes
from_dict_ PathParametersDictInput, PathParametersDict PathParametersDict a constructor

Return Types

HTTP Status Code Class Description
n/a api_response.ApiResponseWithoutDeserialization When skip_deserialization is True this response is returned
200 SuccessWithJsonApiResponse.ApiResponse successful operation

Security

Set auth info by setting ApiConfiguration.security_scheme_info to a dict where the key is the below security scheme quoted name, and the value is an instance of the linked component security scheme class. Select the security index by setting ApiConfiguration.security_index_info or by passing in security_index into the endpoint method. See how to do this in the code sample.

  • these securities are specific to this to this endpoint
Security Index Security Scheme to Scope Names
0 "petstore_auth" [write:pets, read:pets]

Servers

Set the available servers by defining your used servers in ApiConfiguration.server_info Then select your server by setting a server index in ApiConfiguration.server_index_info or by passing server_index in to the endpoint method.

server_index Class Description
0 Server0 petstore server
1 Server1 The local server
2 Server2 staging server with no variables

Code Sample

import petstore_api
from petstore_api.configurations import api_configuration
from petstore_api.apis.tags import pet_api
from petstore_api.paths.pet_pet_id_upload_image.post import operation
from pprint import pprint
# security_index 0
from petstore_api.components.security_schemes import security_scheme_petstore_auth

# security_scheme_info for security_index 0
security_scheme_info: api_configuration.SecuritySchemeInfo = {
    "petstore_auth": security_scheme_petstore_auth.PetstoreAuth(
    ),
}

used_configuration = api_configuration.ApiConfiguration(
    security_scheme_info=security_scheme_info,
)
# Enter a context with an instance of the API client
with petstore_api.ApiClient(used_configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)

    # example passing only required values which don't have defaults set
    path_params: operation.PathParametersDictInput = {
        'petId': 1,
    }
    try:
        # uploads an image
        api_response = api_instance.upload_image(
            path_params=path_params,
        )
        pprint(api_response)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->upload_image: %s\n" % e)

    # example passing only optional values
    path_params = {
        'petId': 1,
    }
    body = {
        "additional_metadata": "additional_metadata_example",
        "file": open('/path/to/file', 'rb'),
    }
    try:
        # uploads an image
        api_response = api_instance.upload_image(
            path_params=path_params,
            body=body,
        )
        pprint(api_response)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->upload_image: %s\n" % e)

[Back to top] [Back to PetApi API] [Back to Endpoints] [Back to README]