Skip to content

Latest commit

 

History

History
262 lines (182 loc) · 22.8 KB

README.md

File metadata and controls

262 lines (182 loc) · 22.8 KB

Consumers

(vault.consumers)

Overview

Available Operations

create

Create a consumer

Example Usage

from apideck_unify import Apideck
import os

with Apideck(
    api_key=os.getenv("APIDECK_API_KEY", ""),
    consumer_id="test-consumer",
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:

    res = apideck.vault.consumers.create(consumer_id="test_consumer_id", metadata={
        "account_name": "SpaceX",
        "user_name": "Elon Musk",
        "email": "elon@musk.com",
        "image": "https://www.spacex.com/static/images/share.jpg",
    })

    assert res.create_consumer_response is not None

    # Handle response
    print(res.create_consumer_response)

Parameters

Parameter Type Required Description Example
consumer_id str ✔️ Unique consumer identifier. You can freely choose a consumer ID yourself. Most of the time, this is an ID of your internal data model that represents a user or account in your system (for example account:12345). If the consumer doesn't exist yet, Vault will upsert a consumer based on your ID. test_consumer_id
metadata Optional[models.ConsumerMetadata] The metadata of the consumer. This is used to display the consumer in the sidebar. This is optional, but recommended.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VaultConsumersAddResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*

list

This endpoint includes all application consumers, along with an aggregated count of requests made.

Example Usage

from apideck_unify import Apideck
import os

with Apideck(
    api_key=os.getenv("APIDECK_API_KEY", ""),
    consumer_id="test-consumer",
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:

    res = apideck.vault.consumers.list()

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
cursor OptionalNullable[str] Cursor to start from. You can find cursors for next/previous pages in the meta.cursors property of the response.
limit Optional[int] Number of results to return. Minimum 1, Maximum 200, Default 20
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VaultConsumersAllResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*

get

Consumer detail including their aggregated counts with the connections they have authorized.

Example Usage

from apideck_unify import Apideck
import os

with Apideck(
    api_key=os.getenv("APIDECK_API_KEY", ""),
    consumer_id="test-consumer",
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:

    res = apideck.vault.consumers.get(consumer_id="test_user_id")

    assert res.get_consumer_response is not None

    # Handle response
    print(res.get_consumer_response)

Parameters

Parameter Type Required Description Example
consumer_id str ✔️ ID of the consumer to return test_user_id
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VaultConsumersOneResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*

update

Update consumer metadata such as name and email.

Example Usage

from apideck_unify import Apideck
import os

with Apideck(
    api_key=os.getenv("APIDECK_API_KEY", ""),
    consumer_id="test-consumer",
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:

    res = apideck.vault.consumers.update(consumer_id="test_user_id", metadata={
        "account_name": "SpaceX",
        "user_name": "Elon Musk",
        "email": "elon@musk.com",
        "image": "https://www.spacex.com/static/images/share.jpg",
    })

    assert res.update_consumer_response is not None

    # Handle response
    print(res.update_consumer_response)

Parameters

Parameter Type Required Description Example
consumer_id str ✔️ ID of the consumer to return test_user_id
metadata Optional[models.ConsumerMetadata] The metadata of the consumer. This is used to display the consumer in the sidebar. This is optional, but recommended.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VaultConsumersUpdateResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*

delete

Delete consumer and all their connections, including credentials.

Example Usage

from apideck_unify import Apideck
import os

with Apideck(
    api_key=os.getenv("APIDECK_API_KEY", ""),
    consumer_id="test-consumer",
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
) as apideck:

    res = apideck.vault.consumers.delete(consumer_id="test_user_id")

    assert res.delete_consumer_response is not None

    # Handle response
    print(res.delete_consumer_response)

Parameters

Parameter Type Required Description Example
consumer_id str ✔️ ID of the consumer to return test_user_id
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VaultConsumersDeleteResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*