Package: apimaticswaggerpetstore
Getting startedThis is a sample server Petstore server.  You can find out more about Swagger athttp://swagger.ioor onirc.freenode.net, #swagger.  For this sample, you can use the api keyspecial-keyto test the authorization filters.How to BuildYou must have Python2 >=2.7.9or Python3 >=3.4installed on your system to install and run this SDK. This SDK package depends on other Python packages like nose, jsonpickle etc.
These dependencies are defined in therequirements.txtfile that comes with the SDK.
To resolve these dependencies, you can use the PIP Dependency manager. Install it by following steps athttps://pip.pypa.io/en/stable/installing/.Python and PIP executables should be defined in your PATH. Open command prompt and typepip --version.
This should display the version of the PIP Dependency Manager installed if your installation was successful and the paths are properly defined.Using command line, navigate to the directory containing the generated files (includingrequirements.txt) for the SDK.Run the commandpip install -r requirements.txt. This should install all the required dependencies.How to UseThe following section explains how to use the Apimaticswaggerpetstore SDK package in a new project.1. Open Project in an IDEOpen up a Python IDE like PyCharm. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.Click onOpenin PyCharm to browse to your generated SDK directory and then clickOK.The project files will be displayed in the side bar as follows:2. Add a new Test ProjectCreate a new directory by right clicking on the solution name as shown below:Name the directory as "test"Add a python file to this project with the name "testsdk"Name it "testsdk"In your python file you will be required to import the generated python library using the following code linesfromapimaticswaggerpetstore.apimaticswaggerpetstore_clientimportApimaticswaggerpetstoreClientAfter this you can write code to instantiate an API client object, get a controller object and  make API calls. Sample code is given in the subsequent sections.3. Run the Test ProjectTo run the file within your test project, right click on your Python file inside your Test project and click onRunHow to TestYou can test the generated SDK and the server with automatically generated test
cases. unittest is used as the testing framework and nose is used as the test
runner. You can run the tests as follows:From terminal/cmd navigate to the root directory of the SDK.Invokepip install -r test-requirements.txtInvokenosetestsInitializationAuthenticationIn order to setup authentication and initialization of the API client, you need the following information.ParameterDescriptiono_auth_client_idOAuth 2 Client IDo_auth_redirect_uriOAuth 2 Redirection endpoint or Callback UriAPI client can be initialized as following.# Configuration parameters and credentialso_auth_client_id='o_auth_client_id'# OAuth 2 Client IDo_auth_redirect_uri='o_auth_redirect_uri'# OAuth 2 Redirection endpoint or Callback Uriclient=ApimaticswaggerpetstoreClient(o_auth_client_id,o_auth_redirect_uri)Class ReferenceList of ControllersPetControllerStoreControllerUserControllerPetControllerGet controller instanceAn instance of thePetControllerclass can be accessed from the API Client.pet_controller=client.petupload_fileuploads an imagedefupload_file(self,pet_id,additional_metadata=None,file=None)ParametersParameterTagsDescriptionpetIdRequiredID of pet to updateadditionalMetadataOptionalAdditional data to pass to serverfileOptionalfile to uploadExample Usagepet_id=130additional_metadata='additionalMetadata'file=open("pathtofile",'rb')result=pet_controller.upload_file(pet_id,additional_metadata,file)add_petAdd a new pet to the storedefadd_pet(self,body)ParametersParameterTagsDescriptionbodyRequiredPet object that needs to be added to the storeExample Usagebody=Pet()pet_controller.add_pet(body)ErrorsError CodeError Description405Invalid inputupdate_petUpdate an existing petdefupdate_pet(self,body)ParametersParameterTagsDescriptionbodyRequiredPet object that needs to be added to the storeExample Usagebody=Pet()pet_controller.update_pet(body)ErrorsError CodeError Description400Invalid ID supplied404Pet not found405Validation exceptionfind_pets_by_statusMultiple status values can be provided with comma separated stringsdeffind_pets_by_status(self,status)ParametersParameterTagsDescriptionstatusRequiredCollectionStatus values that need to be considered for filterExample Usagestatus=[Status2Enum.AVAILABLE]result=pet_controller.find_pets_by_status(status)ErrorsError CodeError Description400Invalid status valuefind_pets_by_tagsMultiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.deffind_pets_by_tags(self,tags)ParametersParameterTagsDescriptiontagsRequiredCollectionTags to filter byExample Usagetags=['tags']result=pet_controller.find_pets_by_tags(tags)ErrorsError CodeError Description400Invalid tag valueget_pet_by_idReturns a single petdefget_pet_by_id(self,pet_id)ParametersParameterTagsDescriptionpetIdRequiredID of pet to returnExample Usagepet_id=130result=pet_controller.get_pet_by_id(pet_id)ErrorsError CodeError Description400Invalid ID supplied404Pet not foundupdate_pet_with_formUpdates a pet in the store with form datadefupdate_pet_with_form(self,pet_id,name=None,status=None)ParametersParameterTagsDescriptionpetIdRequiredID of pet that needs to be updatednameOptionalUpdated name of the petstatusOptionalUpdated status of the petExample Usagepet_id=130name='name'status='status'pet_controller.update_pet_with_form(pet_id,name,status)ErrorsError CodeError Description405Invalid inputdelete_petDeletes a petdefdelete_pet(self,pet_id,api_key=None)ParametersParameterTagsDescriptionpetIdRequiredPet id to deleteapiKeyOptionalTODO: Add a parameter descriptionExample Usagepet_id=130api_key='api_key'pet_controller.delete_pet(pet_id,api_key)ErrorsError CodeError Description400Invalid ID supplied404Pet not foundBack to List of ControllersStoreControllerGet controller instanceAn instance of theStoreControllerclass can be accessed from the API Client.store_controller=client.storecreate_place_orderPlace an order for a petdefcreate_place_order(self,body)ParametersParameterTagsDescriptionbodyRequiredorder placed for purchasing the petExample Usagebody=Order()result=store_controller.create_place_order(body)ErrorsError CodeError Description400Invalid Orderget_order_by_idFor valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptionsdefget_order_by_id(self,order_id)ParametersParameterTagsDescriptionorderIdRequiredID of pet that needs to be fetchedExample Usageorder_id=130result=store_controller.get_order_by_id(order_id)ErrorsError CodeError Description400Invalid ID supplied404Order not founddelete_orderFor valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errorsdefdelete_order(self,order_id)ParametersParameterTagsDescriptionorderIdRequiredID of the order that needs to be deletedExample Usageorder_id=130store_controller.delete_order(order_id)ErrorsError CodeError Description400Invalid ID supplied404Order not foundget_inventoryReturns a map of status codes to quantitiesdefget_inventory(self)Example Usageresult=store_controller.get_inventory()Back to List of ControllersUserControllerGet controller instanceAn instance of theUserControllerclass can be accessed from the API Client.user_controller=client.usercreate_users_with_array_inputCreates list of users with given input arraydefcreate_users_with_array_input(self,body)ParametersParameterTagsDescriptionbodyRequiredCollectionList of user objectExample Usagebody=[User()]user_controller.create_users_with_array_input(body)ErrorsError CodeError Description0successful operationcreate_users_with_list_inputCreates list of users with given input arraydefcreate_users_with_list_input(self,body)ParametersParameterTagsDescriptionbodyRequiredCollectionList of user objectExample Usagebody=[User()]user_controller.create_users_with_list_input(body)ErrorsError CodeError Description0successful operationget_user_by_nameGet user by user namedefget_user_by_name(self,username)ParametersParameterTagsDescriptionusernameRequiredThe name that needs to be fetched. Use user1 for testing.Example Usageusername='username'result=user_controller.get_user_by_name(username)ErrorsError CodeError Description400Invalid username supplied404User not foundupdate_userThis can only be done by the logged in user.defupdate_user(self,username,body)ParametersParameterTagsDescriptionusernameRequiredname that need to be updatedbodyRequiredUpdated user objectExample Usageusername='username'body=User()user_controller.update_user(username,body)ErrorsError CodeError Description400Invalid user supplied404User not founddelete_userThis can only be done by the logged in user.defdelete_user(self,username)ParametersParameterTagsDescriptionusernameRequiredThe name that needs to be deletedExample Usageusername='username'user_controller.delete_user(username)ErrorsError CodeError Description400Invalid username supplied404User not foundget_login_userLogs user into the systemdefget_login_user(self,username,password)ParametersParameterTagsDescriptionusernameRequiredThe user name for loginpasswordRequiredThe password for login in clear textExample Usageusername='username'password='password'result=user_controller.get_login_user(username,password)ErrorsError CodeError Description400Invalid username/password suppliedget_logout_userLogs out current logged in user sessiondefget_logout_user(self)Example Usageuser_controller.get_logout_user()ErrorsError CodeError Description0successful operationcreate_userThis can only be done by the logged in user.defcreate_user(self,body)ParametersParameterTagsDescriptionbodyRequiredCreated user objectExample Usagebody=User()user_controller.create_user(body)ErrorsError CodeError Description0successful operationBack to List of Controllers