Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Latest commit

 

History

History
200 lines (169 loc) · 7.79 KB

File metadata and controls

200 lines (169 loc) · 7.79 KB

petstore_api.paths.pet.operation

Operation Method Name

Method Name Api Class Notes
update_pet PetApi This api is only for tag=pet
put ApiForPut This api is only for this endpoint
put Pet This api is only for path=/pet

Table of Contents

General Info

Field Value
Summary Update an existing pet
Description
Path "/pet"
HTTP Method put

Arguments

Name Type Description Notes
body typing.Union[pet.PetDictInput, pet.PetDict, pet.PetDictInput, pet.PetDict] required
content_type str optional, default is 'application/json' Selects the schema and serialization of the request body. value must be one of ['application/json', 'application/xml']
security_index typing.Optional[int] default is None Allows one to select a different security definition. If not None, must be one of [0, 1]
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

Return Types

HTTP Status Code Class Description
n/a api_response.ApiResponseWithoutDeserialization When skip_deserialization is True this response is returned
400 ResponseFor400.ApiResponse Invalid ID supplied
404 ResponseFor404.ApiResponse Pet not found
405 ResponseFor405.ApiResponse Validation exception

ResponseFor400

Description

Invalid ID supplied

ResponseFor400 ApiResponse

Name Type Description Notes
response urllib3.HTTPResponse Raw response
body Unset body was not defined
headers Unset headers were not defined

ResponseFor404

Description

Pet not found

ResponseFor404 ApiResponse

Name Type Description Notes
response urllib3.HTTPResponse Raw response
body Unset body was not defined
headers Unset headers were not defined

ResponseFor405

Description

Validation exception

ResponseFor405 ApiResponse

Name Type Description Notes
response urllib3.HTTPResponse Raw response
body Unset body was not defined
headers Unset headers were not defined

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 "http_signature_test" []
1 "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 pprint import pprint
# security_index 0
from petstore_api.components.security_schemes import security_scheme_http_signature_test
# security_index 1
from petstore_api.components.security_schemes import security_scheme_petstore_auth

# security_scheme_info for security_index 0
security_scheme_info: api_configuration.SecuritySchemeInfo = {
    "http_signature_test": security_scheme_http_signature_test.HttpSignatureTest(
        signing_info=petstore_api.signing.HttpSigningConfiguration(
            key_id='my-key-id',
            private_key_path='rsa.pem',
            signing_scheme=petstore_api.signing.SCHEME_HS2019,
            signing_algorithm=petstore_api.signing.ALGORITHM_RSASSA_PSS,
            signed_headers=[
                petstore_api.signing.HEADER_REQUEST_TARGET,
                petstore_api.signing.HEADER_CREATED,
                petstore_api.signing.HEADER_EXPIRES,
                petstore_api.signing.HEADER_HOST,
                petstore_api.signing.HEADER_DATE,
                petstore_api.signing.HEADER_DIGEST,
                'Content-Type',
                'User-Agent'
            ],
            signature_max_validity=datetime.timedelta(minutes=5)
        )

    ),
}


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

security_index_info: api_configuration.SecurityIndexInfo = {
    "security": 0,  # default value
    "paths//pet/put/security": 0,
    # only set one "paths//pet/put/security": 1,
}
used_configuration = api_configuration.ApiConfiguration(
    security_scheme_info=security_scheme_info,
    security_index_info=security_index_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
    body = pet.Pet.validate({
        "id": 1,
        "category": category.Category.validate({
            "id": 1,
            "name": "default-name",
        }),
        "name": "doggie",
        "photo_urls": [
            "photo_urls_example"
        ],
        "tags": [
            tag.Tag.validate({
                "id": 1,
                "name": "name_example",
            })
        ],
        "status": "available",
    })
    try:
        # Update an existing pet
        api_response = api_instance.update_pet(
            body=body,
        )
        pprint(api_response)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->update_pet: %s\n" % e)

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