Skip to content

open-needs/open-needs-sdk

Repository files navigation

open-needs-sdk

REST API client of Open-Needs Server.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 0.1.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

For more information, please visit https://github.com/open-needs

Requirements.

Python >=3.6

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import on_sdk

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import on_sdk

Getting Started

Please follow the installation procedure and then run the following:

import time
import on_sdk
from pprint import pprint
from on_sdk.api import auth_api
from on_sdk.model.bearer_response import BearerResponse
from on_sdk.model.body_reset_forgot_password_auth_forgot_password_post import BodyResetForgotPasswordAuthForgotPasswordPost
from on_sdk.model.body_reset_reset_password_auth_reset_password_post import BodyResetResetPasswordAuthResetPasswordPost
from on_sdk.model.body_verify_request_token_auth_request_verify_token_post import BodyVerifyRequestTokenAuthRequestVerifyTokenPost
from on_sdk.model.body_verify_verify_auth_verify_post import BodyVerifyVerifyAuthVerifyPost
from on_sdk.model.error_model import ErrorModel
from on_sdk.model.http_validation_error import HTTPValidationError
from on_sdk.model.user import User
from on_sdk.model.user_create import UserCreate
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = on_sdk.Configuration(
    host = "http://localhost"
)



# Enter a context with an instance of the API client
with on_sdk.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = auth_api.AuthApi(api_client)
    username = "username_example" # str | 
password = "password_example" # str | 
grant_type = "passwor" # str |  (optional)
scope = "" # str |  (optional) (default to "")
client_id = "client_id_example" # str |  (optional)
client_secret = "client_secret_example" # str |  (optional)

    try:
        # Auth:Jwt.Login
        api_response = api_instance.auth_jwt_login_auth_jwt_login_post(username, password, grant_type=grant_type, scope=scope, client_id=client_id, client_secret=client_secret)
        pprint(api_response)
    except on_sdk.ApiException as e:
        print("Exception when calling AuthApi->auth_jwt_login_auth_jwt_login_post: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
AuthApi auth_jwt_login_auth_jwt_login_post POST /auth/jwt/login Auth:Jwt.Login
AuthApi auth_jwt_logout_auth_jwt_logout_post POST /auth/jwt/logout Auth:Jwt.Logout
AuthApi register_register_auth_register_post POST /auth/register Register:Register
AuthApi reset_forgot_password_auth_forgot_password_post POST /auth/forgot-password Reset:Forgot Password
AuthApi reset_reset_password_auth_reset_password_post POST /auth/reset-password Reset:Reset Password
AuthApi verify_request_token_auth_request_verify_token_post POST /auth/request-verify-token Verify:Request-Token
AuthApi verify_verify_auth_verify_post POST /auth/verify Verify:Verify
FilterApi filter_needs_api_filter_needs_post POST /api/filter/needs Filter Needs
NeedsApi create_need_api_needs_post POST /api/needs/ Create Need
NeedsApi read_items_api_needs_get GET /api/needs/ Read Items
OrganizationsApi create_organization_api_organizations_post POST /api/organizations/ Create Organization
OrganizationsApi read_organization_api_organizations_organization_id_get GET /api/organizations/{organization_id} Read Organization
OrganizationsApi read_organizations_api_organizations_get GET /api/organizations/ Read Organizations
ProjectsApi create_project_api_projects_post POST /api/projects/ Create Project
ProjectsApi read_project_api_projects_project_id_get GET /api/projects/{project_id} Read Project
ProjectsApi read_projects_api_projects_get GET /api/projects/ Read Projects
UsersApi users_current_user_users_me_get GET /users/me Users:Current User
UsersApi users_current_user_users_me_patch PATCH /users/me Users:Current User
UsersApi users_user_users_id_delete DELETE /users/{id} Users:User
UsersApi users_user_users_id_get GET /users/{id} Users:User
UsersApi users_user_users_id_patch PATCH /users/{id} Users:User

Documentation For Models

Documentation For Authorization

OAuth2PasswordBearer

  • Type: OAuth
  • Flow: password
  • Authorization URL:
  • Scopes: N/A

Author

Notes for Large OpenAPI documents

If the OpenAPI document is large, imports in on_sdk.apis and on_sdk.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 on_sdk.api.default_api import DefaultApi
  • from on_sdk.model.pet import Pet

Solution 2: Before importing the package, adjust the maximum recursion limit as shown below:

import sys
sys.setrecursionlimit(1500)
import on_sdk
from on_sdk.apis import *
from on_sdk.models import *

Development

Generate SDK

Follow this instruction to install the OpenAPI Generator

Then execute:

npx @openapitools/openapi-generator-cli generate 
-i schemas/20220215_openapi.json 
-g python 
--additional-properties=projectName=open-needs-sdk 
--additional-properties=packageName=on_sdk 
-o ./temp

Everything gets created under ./temp and the generated SDK can be used directly.

To update the existing SDK, please copy the needed parts by hand. But be aware, that there may be manual changes inside the existing files.

About

Python SDK for Open-Needs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages