Music shop REST API
The openapi_client package is automatically generated by the OpenAPI Generator project:
- API version: 1.0.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
Python >=3.6
This python library package is generated without supporting files like setup.py or requirements files
To be able to use it, you will need these dependencies in your own package that uses this library:
- urllib3 >= 1.25.3
- python-dateutil
In your own code, to use this library to connect and interact with openapi-client, you can run the following:
import time
import openapi_client
from pprint import pprint
from openapi_client.api import default_api
from openapi_client.model.album_dto import AlbumDTO
from openapi_client.model.cart_line_item_dto import CartLineItemDTO
from openapi_client.model.invoice_line_item_dto import InvoiceLineItemDTO
from openapi_client.model.shopping_cart_dto import ShoppingCartDTO
from openapi_client.model.song_dto import SongDTO
from openapi_client.model.user_data_dto import UserDataDTO
# Defining the host is optional and defaults to http://localhost:8080/musicshop-1.0
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
host = "http://localhost:8080/musicshop-1.0"
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = default_api.DefaultApi(api_client)
cart_uuid = "CartUUID_example" # str | (optional)
album_dto = AlbumDTO(
long_id=1,
title="title_example",
image_url="image_url_example",
price=3.14,
stock=1,
medium_type="CD",
release_date="release_date_example",
album_id=AlbumId(
album_id="album_id_example",
),
label="label_example",
songs=[
SongDTO(
long_id=1,
title="title_example",
price=3.14,
stock=1,
medium_type="CD",
release_date="release_date_example",
genre="genre_example",
artists=[
ArtistDTO(
name="name_example",
),
],
in_album=[
AlbumDTO(),
],
),
],
quantity_to_add_to_cart=1,
) # AlbumDTO | (optional)
try:
api_response = api_instance.add_albums_to_cart(cart_uuid=cart_uuid, album_dto=album_dto)
pprint(api_response)
except openapi_client.ApiException as e:
print("Exception when calling DefaultApi->add_albums_to_cart: %s\n" % e)All URIs are relative to http://localhost:8080/musicshop-1.0
| Class | Method | HTTP request | Description |
|---|---|---|---|
| DefaultApi | add_albums_to_cart | POST /api/albums/addAlbumsToCart | |
| DefaultApi | add_songs_from_album_to_cart | POST /api/albums/addSongsFromAlbumToCart | |
| DefaultApi | add_songs_to_cart | POST /api/albums/addSongsToCart | |
| DefaultApi | buy_product | POST /api/shoppingCart/buyProducts | |
| DefaultApi | buy_products_web | POST /api/shoppingCart/buyProductsWeb | |
| DefaultApi | clear_shopping_cart | GET /api/shoppingCart/clear | |
| DefaultApi | display_shopping_cart | GET /api/shoppingCart/display | |
| DefaultApi | find_album_by_album_id | GET /api/album/{albumId} | |
| DefaultApi | find_albums_by_song_title | GET /api/albums/digital/{songTitle} | |
| DefaultApi | find_albums_by_song_title_physical | GET /api/albums/physical/{songTitle} | |
| DefaultApi | login | POST /api/login | |
| DefaultApi | login_web | POST /api/loginWeb | |
| DefaultApi | remove_line_item_from_cart | POST /api/shoppingCart/removeLineItemFromCart | |
| DefaultApi | welcome | GET /api |
All endpoints do not require authorization.
If the OpenAPI document is large, imports in openapi_client.apis and openapi_client.models may fail with a RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:
Solution 1: Use specific imports for apis and models like:
from openapi_client.api.default_api import DefaultApifrom openapi_client.model.pet import Pet
Solution 2: Before importing the package, adjust the maximum recursion limit as shown below:
import sys
sys.setrecursionlimit(1500)
import openapi_client
from openapi_client.apis import *
from openapi_client.models import *