Sweego API
Project description
sweego
The sweego package is automatically generated by the OpenAPI Generator project:
- Generator version: 7.6.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit OpenAPI Generator Python
Requirements.
Python 3.7+
Getting Started
Install
pip install sweego
Use
In your own code, to use this library to connect and interact with sweego, you can run the following:
# Import base API
from sweego.api_client import ApiClient;
# Import auth API
from sweego.api.auth_api import AuthApi;
# Import an endpoint API
from sweego.api.<ENDPOINT> import <ENDPOINT>;
Auth
Below are example on how to use authentication with provided sdk
Bearer Token
- Type: Bearer authentication
- Bearer parameter name: Authentication
- Location: HTTP header
Retrieve access token
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from typing import List;
from pprint import pprint;
from sweego.configuration import Configuration as ApiConfig;
from sweego.api.auth_api import AuthApi;
from sweego.api_client import ApiClient;
from sweego.rest import ApiException;
from sweego import ResponseCreateTokenAuthTokenPost;
# Define api host
configuration = ApiConfig (
host = "https://api.sweego.io"
);
# Enter a context with an instance of the API client
with ApiClient ( configuration ) as api_client:
# Create an instance of the API class
api_instance: AuthApi = AuthApi (
api_client = api_client
);
# Define base auth requirements
grant_type: str = 'password'
username: str = '<USERNAME>'
password: str = '<PASSWORD>'
client_id: str = 'front_web'
try:
# Query auth token
api_response: ResponseCreateTokenAuthTokenPost = api_instance.create_token_auth_token_post (
grant_type = grant_type,
username = username,
password = password,
client_id = client_id
);
print ( "Auth response:\n" );
pprint (
object = api_response.actual_instance,
indent = 4
);
print ( "\n--------------------\n" );
# Assign bearer token to authorization header
api_client.default_headers [ 'Authorization' ] = "Bearer {bearer}".format (
bearer = api_response.actual_instance.access_token
);
except ApiException as err:
print (
"Exception when querying : {err}".format (
err = err
),
file = sys.stderr
);
Refresh token
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from typing import List;
from pprint import pprint;
from sweego.configuration import Configuration as ApiConfig;
from sweego.api.auth_api import AuthApi;
from sweego.api_client import ApiClient;
from sweego.rest import ApiException;
from sweego import ResponseCreateTokenAuthTokenPost;
# Define api host
configuration = ApiConfig (
host = "https://api.sweego.io"
);
# Enter a context with an instance of the API client
with ApiClient ( configuration ) as api_client:
# Create an instance of the API class
api_instance: AuthApi = AuthApi (
api_client = api_client
);
# Define base auth requirements
grant_type: str = 'refresh_token'
refresh_token = '<REFRESH_TOKEN>'
client_id: str = 'front_web'
try:
# Query auth token
api_response: ResponseCreateTokenAuthTokenPost = api_instance.create_token_auth_token_post (
grant_type = grant_type,
refresh_token = refresh_token
client_id = client_id
);
print ( "Auth response:\n" );
pprint (
object = api_response.actual_instance,
indent = 4
);
print ( "\n--------------------\n" );
# Assign bearer token to api client authorization header
api_client.default_headers [ 'Authorization' ] = "Bearer {bearer}".format (
bearer = api_response.actual_instance.access_token
);
except ApiException as err:
print (
"Exception when querying : {err}".format (
err = err
),
file = sys.stderr
);
API Key
- Type: API key
- API key parameter name: Api-Key
- Location: HTTP header
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os;
import sys;
from typing import List;
from pprint import pprint;
from sweego.configuration import Configuration as ApiConfig;
from sweego.api.auth_api import AuthApi;
from sweego.api_client import ApiClient;
from sweego.rest import ApiException;
from sweego.models.client_webhook import ClientWebhook as ClientWebhookModel;
from sweego.api.webhook_api import WebhookApi;
# Define api host
configuration = ApiConfig (
host = "https://api.sweego.io"
);
# Enter a context with an instance of the API client
with ApiClient ( configuration ) as api_client:
# Create an instance of the API class
api_instance: AuthApi = AuthApi (
api_client = api_client
);
# Define api key to use
api_key: str = '<API_KEY>';
try:
# Assign key to api client header
api_client.default_headers [ 'Api-Key' ] = api_key;
# Every api is in nana object -> check lib
except ApiException as err:
print (
"Exception when querying : {err}".format (
err = err
),
file = sys.stderr
);
Endpoints principles
Every endpoint on the base API will be translated as a unique api object. To be able to use these api objec you will need to initiate them using the api_client defined above (create api client)
For example, if you want to use "/webhooks" endpoint :
# Following an auth
from sweego.models.client_webhook import ClientWebhook as ClientWebhookModel;
from sweego.api.webhook_api import WebhookApi;
try:
# Create a Webhook API instance
webhook_api: WebhookApi = WebhookApi (
api_client = api_client
);
# Query client wehooks list
client_webhooks: List [ ClientWebhookModel ] = webhook_api.get_webhooks_clients_uuid_client_webhooks_get (
uuid_client = api_response.actual_instance.sweego_client_id
);
# Print Result
for webhook in client_webhooks:
pprint (
object = webhook.dict(),
indent = 4
);
except ApiException as err:
print (
"Exception when querying : {err}".format (
err = err
),
file = sys.stderr
);
Every API object is located in sweego.api namespace
Error Handling
sweego.exceptions contains a set of specific exceptions class
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sweego-0.0.1.tar.gz.
File metadata
- Download URL: sweego-0.0.1.tar.gz
- Upload date:
- Size: 178.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be536c18f25acc80b9854be7f2d117b143d71804ec4a209bacda844c077178bd
|
|
| MD5 |
0ed9004ca16e0ffa84d81d67774f7a1b
|
|
| BLAKE2b-256 |
22cee8ca8bc8493a2bd0054e30b8457539de5dc50d2bb9a2aed6860c6e44d1cd
|
File details
Details for the file sweego-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sweego-0.0.1-py3-none-any.whl
- Upload date:
- Size: 637.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f378066518d334fe769b01ebc6a5dc5a622b3518b571e4f200262c50936ee05
|
|
| MD5 |
48c42187101f48b416e3e875a5dea94f
|
|
| BLAKE2b-256 |
69c19782fe60de4365187a252840cb1752a1247429cc7fa2bfb58abe91e558f5
|