Raw functions
These functions can be considered as low level. They allow to perform requests for which there is no function in Gazu. Except for configuration and authentication, they should be used as a secondary choice.
API configuration
Check if API is up:
gazu.client.is_host_up()
Get currently configured API server hostname:
gazu.client.get_host()
Set API server hostname:
gazu.client.set_host("pipeline-api")
Authentication
Make the client log in:
gazu.client.log_in("user@mail.com", "default")
Make the client log out:
gazu.client.log_out()
Get currently logged user:
gazu.client.get_current_user()
Get API version:
gazu.client.get_api_version()
Raw request functions
Performs a GET request on given path of the API:
gazu.client.get("data/projects")
Performs a POST request on given path of the API:
gazu.client.post("data/projects", {"name": "My new Project"})
Performs a PUT request on given path of the API:
gazu.client.put(
"data/projects/<project-id>",
{"name": "My new Project updated"}
)
Performs a DELETE request on given path of the API:
gazu.client.delete("data/projects/<project-id>")
Multi client
Gazu acts a singleton. If you want several instances of the Kitsu client, you can create them and pass them as parameter when you need it:
source_client = gazu.client.create_client("https://mysource.kitsu")
target_client = gazu.client.create_client("https://mytarget.kitsu")
gazu.client.log_in("user-source@mail.com", "default", client=source_client)
gazu.client.log_in("user-target@mail.com", "default", client=target_client)
gazu.client.get("/", client=source_client)
gazu.client.get("/", client=source_client)
gazu.project.all_open_projects(client=target_client)
gazu.project.all_open_projects(client=target_client)
Files functions
Upload a given file to given path:
gazu.client.upload("thumbnails/projects", "my_file.png")
Download a given file to given path:
gazu.client.download("thumbnails/projects/project-id.png", "my_file.png")
Model functions
These functions assume you know what type of model you want to work on. Models are listed in the available data section. Replace spaces by dashes and put everything in lowercase (ex: Task type -> task-types).
Retrieve all data for a given data type:
gazu.client.fetch_all("projects")
gazu.client.fetch_all("tasks?page=2") # Paginate by using 100 entries per page.
Retrieve one entry for a given data type:
gazu.client.fecth_one("projects", "project-id")
Get first entry of a given list:
gazu.client.fecth_first("projects")
Create an entry for a given data type:
gazu.client.create("projects", {"name": "Cosmos Landromat"})