Skip to main content

Utility library for Tabular.io

Project description

Tab

This is a helper library to easily fetch and refresh access token from Tabular.

Usage

Every command has --help available:

 tab --help
Usage: tab [OPTIONS] COMMAND [ARGS]...

Options:
--environment TEXT
--help              Show this message and exit.

Commands:
refresh-token       Retrieves a fresh token based on an existing token
request-token       Retrieves an access token based on credentials
request-user-token  Retrieves a user token based on credentials

And the specific commands:

 tab request-user-token --help
Usage: tab request-user-token [OPTIONS] [SERVICE_TOKEN] [SERVICE_TOKEN_TYPE]
[ID_TOKEN] [ID_TOKEN_TYPE] [SCOPES]...

Retrieves a user token based on credentials

Options:
--help  Show this message and exit.

Requesting access token

 tab request-token t-GdCZGj5OpoQ:jIcDDITVeIOnqxo7FxWbI21Y3kI | jq
{
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzUxMiJ9.eyJjcmVkc0tleSI6InQtR2RDWkdqNU9wb1EiLCJzdWJJZCI6ImViMzc2NTQ4LTIwNmItNDBiYS1hN2E1LWVkYmUzZjg4YWVlZCIsInN1YiI6ImZva2tvQHRhYnVsYXIuaW8iLCJ3YXJlaG91c2VJZCI6IjhiY2IwODM4LTUwZmMtNDcyZC05ZGRiLThmZWI4OWVmNWYxZSIsImlzcyI6InRhYnVsYXIuaW8iLCJsb2NhdGlvbiI6InMzOi8vdGFidWxhci13aC11cy13ZXN0LTItZGV2LzhiY2IwODM4LTUwZmMtNDcyZC05ZGRiLThmZWI4OWVmNWYxZS8iLCJ0eXBlIjoiV0FSRUhPVVNFIiwicmVnaW9uIjoidXMtd2VzdC0yIiwiZXhwIjoxNjY1NzU1MzU2LCJpYXQiOjE2NjU2Njg5NTYsImp0aSI6IjRhZjcyMzk3LTVlOGQtNDc0OS1iZThmLWI4OTFmYTMwNjNhNiIsIm9yZ0lkIjoiMWM1MmU4MzItMjY2Yy00OTYxLTk3YWYtMTE1ZDFiNzJmY2UwIn0.sTu-j2lGG02Ui_Ts7_rMfkT-zha6ugMzz0JyiumHpTupqEXnDdNiaxyEJmJcu81IcjEaWwT32hxAlznLy6Qhr-yTeSoVY5pJnTiXMNxeAZwzDkGh87uLcp0PjgwRLc6DmD3ZAXC2WQEUf8PS_mcMXF_6HoegHv1GHGLk9aHhWLze6WI_SIKSLc0Gmw8ZjjZoUpL8SSwt-uinT8gY_D0TksHkeVzM5DFxhLvhXMjJ1VyRUbsrE_6An83-aG0NzsFFgK3IhCf-RsEsOXH1MKZpdLdIlelcz8Av1uFzgWA6kFAcy9dGVZu_Ycj19e58e17IKHgLbtk4cc4wJOAg6lCBsw",
    "issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
    "token_type": "Bearer",
    "expires_in": 86400,
    "scope": null
}

Also, stdin is supported:

 cat cred.json | jq
{
    "credential": "t-GdCZGj5OpoQ:jIcDDITVeIOnqxo7FxWbI21Y3kI"
} cat cred.json | tab request-token | jq
{
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzUxMiJ9.eyJjcmVkc0tleSI6InQtR2RDWkdqNU9wb1EiLCJzdWJJZCI6ImViMzc2NTQ4LTIwNmItNDBiYS1hN2E1LWVkYmUzZjg4YWVlZCIsInN1YiI6ImZva2tvQHRhYnVsYXIuaW8iLCJ3YXJlaG91c2VJZCI6IjhiY2IwODM4LTUwZmMtNDcyZC05ZGRiLThmZWI4OWVmNWYxZSIsImlzcyI6InRhYnVsYXIuaW8iLCJsb2NhdGlvbiI6InMzOi8vdGFidWxhci13aC11cy13ZXN0LTItZGV2LzhiY2IwODM4LTUwZmMtNDcyZC05ZGRiLThmZWI4OWVmNWYxZS8iLCJ0eXBlIjoiV0FSRUhPVVNFIiwicmVnaW9uIjoidXMtd2VzdC0yIiwiZXhwIjoxNjY1NzU1Mjg2LCJpYXQiOjE2NjU2Njg4ODYsImp0aSI6IjZhNzljNzU1LTYzNGEtNDJlNC04YmVlLTEzZjgxOWFlYTYyNCIsIm9yZ0lkIjoiMWM1MmU4MzItMjY2Yy00OTYxLTk3YWYtMTE1ZDFiNzJmY2UwIn0.WZNP_e-cMKX9pj7ydPA_sm2Zyy54Iht1bOx7g3lr8p5NRh8jyyD2RHY1hAhvDgLASZr49vBcjAsbRdvmq3WEAO_LV3c_ts-5edDhLfetAfmcDjR5Xv70HDvpmofkEkZVK7HE8P_IPA6z2YX-CbnEcAHPzZ3hrjfR6nc2ouo0h8tlg6OqmT8w75aX5PA9inh6xquMhBLYSfeGlET5XF3fryQ6Kd2PfTTftMRqo-DbkdMHHF7t8E8wrbf-I7cE7--o_KfF2paaebyRAuS9n7RSdOw82FL2dBn9V3cMwyNeTPH05m6OKChnXenG9xorgKnRkEeB_P6UdwEPcPH8YeQJHA",
    "issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
    "token_type": "Bearer",
    "expires_in": 86400,
    "scope": null
}

Requesting a user access token

tab request-user-token eyJ0e...eQJHA urn:ietf:params:oauth:token-type:id_token eyJ0e...eQJHA urn:ietf:params:oauth:token-type:access_token | jq
{
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzUxMiJ9.eyJjcmVkc0tleSI6InQtR2RDWkdqNU9wb1EiLCJzdWJJZCI6ImViMzc2NTQ4LTIwNmItNDBiYS1hN2E1LWVkYmUzZjg4YWVlZCIsInN1YiI6ImZva2tvQHRhYnVsYXIuaW8iLCJ3YXJlaG91c2VJZCI6IjhiY2IwODM4LTUwZmMtNDcyZC05ZGRiLThmZWI4OWVmNWYxZSIsImlzcyI6InRhYnVsYXIuaW8iLCJsb2NhdGlvbiI6InMzOi8vdGFidWxhci13aC11cy13ZXN0LTItZGV2LzhiY2IwODM4LTUwZmMtNDcyZC05ZGRiLThmZWI4OWVmNWYxZS8iLCJ0eXBlIjoiV0FSRUhPVVNFIiwicmVnaW9uIjoidXMtd2VzdC0yIiwiZXhwIjoxNjY1NzU1Mjg2LCJpYXQiOjE2NjU2Njg4ODYsImp0aSI6IjZhNzljNzU1LTYzNGEtNDJlNC04YmVlLTEzZjgxOWFlYTYyNCIsIm9yZ0lkIjoiMWM1MmU4MzItMjY2Yy00OTYxLTk3YWYtMTE1ZDFiNzJmY2UwIn0.WZNP_e-cMKX9pj7ydPA_sm2Zyy54Iht1bOx7g3lr8p5NRh8jyyD2RHY1hAhvDgLASZr49vBcjAsbRdvmq3WEAO_LV3c_ts-5edDhLfetAfmcDjR5Xv70HDvpmofkEkZVK7HE8P_IPA6z2YX-CbnEcAHPzZ3hrjfR6nc2ouo0h8tlg6OqmT8w75aX5PA9inh6xquMhBLYSfeGlET5XF3fryQ6Kd2PfTTftMRqo-DbkdMHHF7t8E8wrbf-I7cE7--o_KfF2paaebyRAuS9n7RSdOw82FL2dBn9V3cMwyNeTPH05m6OKChnXenG9xorgKnRkEeB_P6UdwEPcPH8YeQJHA",
    "issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
    "token_type": "Bearer",
    "expires_in": 64982,
    "scope": null
}

Refreshing an access token

 tab refresh-token eyJ0e...eQJHA urn:ietf:params:oauth:token-type:access_token | jq
{
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzUxMiJ9.eyJjcmVkc0tleSI6InQtR2RDWkdqNU9wb1EiLCJzdWJJZCI6ImViMzc2NTQ4LTIwNmItNDBiYS1hN2E1LWVkYmUzZjg4YWVlZCIsInN1YiI6ImZva2tvQHRhYnVsYXIuaW8iLCJ3YXJlaG91c2VJZCI6IjhiY2IwODM4LTUwZmMtNDcyZC05ZGRiLThmZWI4OWVmNWYxZSIsImlzcyI6InRhYnVsYXIuaW8iLCJsb2NhdGlvbiI6InMzOi8vdGFidWxhci13aC11cy13ZXN0LTItZGV2LzhiY2IwODM4LTUwZmMtNDcyZC05ZGRiLThmZWI4OWVmNWYxZS8iLCJ0eXBlIjoiV0FSRUhPVVNFIiwicmVnaW9uIjoidXMtd2VzdC0yIiwiZXhwIjoxNjY1NzU1NDM5LCJpYXQiOjE2NjU2NjkwMzksImp0aSI6IjZhNzljNzU1LTYzNGEtNDJlNC04YmVlLTEzZjgxOWFlYTYyNCIsIm9yZ0lkIjoiMWM1MmU4MzItMjY2Yy00OTYxLTk3YWYtMTE1ZDFiNzJmY2UwIn0.DBmmCfyj4hNaP0eVwzyv6R5aoSLrwWwHbHKePs2lEphA8zzilVreN1BPligIjezLPsn57S8FiOHqsCAwkeNWPthxxCI_gBkeZuCDhqbP90GsIuKwsFIaECZjn2_sO7UAhT3oSLgSeSB289QsQck6qIPPLLXM95jKrfzClKIF3Me4lKPmsRdLNRwCEDAOIgiR9sjBEUbSxgSkRvwxPQNDu75T25pn8O18EMlhmOUROSYva8VPRCc9PIFJL0PfcD_D7wlKZfiug8v58-q-1RAfB57IF0p-o9G_5RNeDrbEDA35OM8jTZEFDpL8Q-WlzT_6EZTvsIx_b7HxNW6kxf6WsQ",
    "issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
    "token_type": "Bearer",
    "expires_in": 86400,
    "scope": null
}

Listing all the warehouses

 tab warehouses --help
Usage: tab warehouses [OPTIONS]

Fetches all the warehouses

Options:
-c, --credential TEXT
-t, --token TEXT
--help                 Show this message and exit.

Example:

 tab warehouses --credential t-GdCZGj5OpoQ:jIcDDITVeIOnqxo7FxWbI21Y3kI | jq
[
  {
    "id": "6efbcaf4-21ae-499d-b340-3bc1a7003f52",
    "name": "sandbox",
    "region": "us-east-1"
  },
  {
    "id": "c70f668c-4746-414f-8a74-b1e4f1f0de60",
    "name": "Fokko",
    "region": "us-west-2"
  }
]
>>> from tabular import Tabular
>>> t = Tabular(credential="t-GdCZGj5OpoQ:jIcDDITVeIOnqxo7FxWbI21Y3kI")
>>> t.list_warehouses()
[
    Warehouse(id='6efbcaf4-21ae-499d-b340-3bc1a7003f52', name='sandbox', region='us-east-1'),
    Warehouse(id='c70f668c-4746-414f-8a74-b1e4f1f0de60', name='Fokko', region='us-west-2')
]
>>> from tabular import Tabular
>>> t = Tabular(**{
        "rest.sigv4-enabled": "true",
        "rest.signing-region": "us-east-1",
        "rest.signing-name": "execute-api",
    })
>>> t.list_warehouses()
[
    Warehouse(id='6efbcaf4-21ae-499d-b340-3bc1a7003f52', name='sandbox', region='us-east-1'),
    Warehouse(id='c70f668c-4746-414f-8a74-b1e4f1f0de60', name='Fokko', region='us-west-2')
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tabulario-0.4.0rc1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

tabulario-0.4.0rc1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file tabulario-0.4.0rc1.tar.gz.

File metadata

  • Download URL: tabulario-0.4.0rc1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.17 Linux/5.15.0-1040-azure

File hashes

Hashes for tabulario-0.4.0rc1.tar.gz
Algorithm Hash digest
SHA256 8a6bb8a86e3e0b7494b0093a98101cc3b4baefcd2bb8c3be2c25bfc7cd9e9e02
MD5 34ea10105f48557246a3639361340a86
BLAKE2b-256 19223d044bab30e6c00586ca87e7c6c12c58f2275b3624c9d94ddc5c24deaab5

See more details on using hashes here.

File details

Details for the file tabulario-0.4.0rc1-py3-none-any.whl.

File metadata

  • Download URL: tabulario-0.4.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.17 Linux/5.15.0-1040-azure

File hashes

Hashes for tabulario-0.4.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 f2d46b95f653d2dd6062f14cdf25ad14b7ffdb46a2300bfc2f2dc8e9fd85cfb9
MD5 2578e91dfeca968a6b70ae9c0d7d5465
BLAKE2b-256 07ef3bede8c4067d82753a3254f5d1c1ff77b935786ea40b53fbe3e5f2edf9ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page