Giter Site home page Giter Site logo

driganttic's Introduction

driganttic

Code style: black

Ganttic API client


Documentation: https://dribia.github.io/driganttic/

Source Code: https://github.com/Dribia/driganttic


API REST Ganttic client for python.

Key features

  • Client simple programmatic access to Ganttic API Rest
  • Pydantic responses

Missing features

  • It only implements GET methods
  • It does not implement all fields of Tasks, Resources and Projects as they were not needed to us
  • It does not implement custom field fetchers for either texts or users

Example

The client is very trivial to use. It implements wrappers to the main types of available calls.

from driganttic import parse as dg_parse
from driganttic import client as dg_client

APIKEY = 'yourapikey'

Client = dg_client.GantticClient(APIKEY=APIKEY)
# get dictionary of custom fields
dict_of_fields = Client.Translator

print(f'Available fetchers: {dg_client.FETCHERS}')
# get all projects, tasks and resources
projects = Client.get_projects()
tasks = Client.get_tasks(timeMin = dg_parse.parse_timestamp('2021-01-01'),
                         timeMax= dg_parse.parse_timestamp('2021-04-30'))
resources = Client.get_resources()

p_id = projects.fetched_items.pop().id
t_id = tasks.fetched_items.pop().id
r_id = resources.fetched_items.pop().id
one_project = Client.get_project_details(projectId=p_id)
one_task = Client.get_task_details(taskId=t_id)
one_resource = Client.get_resource_details(resourceId=r_id)

All results are pydantic models already formatted with the interesting fields. See the fetcher.py file in /schemas for details.

Modifications

The only changes needed here are to adapt to your own custom data fields. To do so, you need to do two things:

  1. Define the relevant fields in the pydantic model definition in schemas/fetcher.py
class TaskDetails(FetcherDetails):
    """Task List schema."""

    # could be holidays
    projectId: Optional[str]
    resources: List[str]
    start: datetime.datetime
    end: datetime.datetime
    utilizationPercent: Optional[float]

    # Define here your custom fields
    my_custom_pydantic_name: Optional[str]
  1. Head to config/config.yaml and add your declared custom fields under the dict for the relevant fetcher (task, project or resource) and type (number, date, listvalue, user or text)
custom_fields:
  tasks:
    listValues:
       my_custom_ganttic_name: my_pydnatic_name
    numbers:
    dates:
  projects:
    listValues:
    numbers:
    dates:
  resources:
    listValues:
    numbers:
    dates:

License

This package is licensed under the MIT license, see LICENSE.md.

TODOs

  • Make optional to exhaust pages (now by default it exhausts the pages)
  • Implement good testing, in line using TestClient from Starlette by mocking the API response.
  • Implement modify, create and delete methods
  • Implement custom data types texts and users

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.