CartoDB / carto-python

CARTO Python client
https://carto.com
BSD 3-Clause "New" or "Revised" License
154 stars 62 forks source link

Auth API support #94

Closed pcaro closed 5 years ago

pcaro commented 5 years ago

I would be great to support the Auth API

https://carto.com/developers/auth-api/reference/

This little gist runs:

class ApiKey(Resource):
    name = CharField()
    token = CharField()
    type = CharField()
    created_at = DateTimeField()
    updated_at = DateTimeField()
    grants = Field()

    class Meta:
        id_field = "name"
        collection_endpoint = "api/v3/api_keys/"

class ApiKeyManager(Manager):
    resource_class = ApiKey
    json_collection_attribute = "result"

keys_manager = ApiKeyManager(auth_client)
keys_manager.all()
keys_manager.get('Master')
grants =  [
    {
        "type": "apis",
        "apis": ["sql", "maps"]
    },
    {
        "type": "database",
        "tables" : []
    }
]
key = self.keys_manager.create(name="myname", grants=grants)

Would be possible a complete implementation?