Get Credentials from Provisioning API.
If you have already an instance of Storage API client in $storageApi
, then you can get credentials to transformation database with the following call:
$provisioning = new \Keboola\Provisioning\Client('snowflake', $storageApi->getTokenString(), $storageApi->getRunId());
$credentials = $provisioning->getCredentials('transformations');
First argument to Client
constructor is database backend, which may be either snowflake
, mysql
or redshift-workspace
. The $credentials
variable above will contain the following structure:
array (
'id' => 'foo',
'hostname' => 'ACMEdatabseServerAddress',
'db' => 'ACMEDatabse',
'password' => 'ACMEPassword',
'user' => 'Wile.E.Coyote',
'schema' => 'ACMESchema',
)
Resetting credentials is useful when you want to clean up the working schema. Resetting credentials will drop the entire schema and create a new empty one. Resetting credentials does not delete the credentials themselves - i.e. password and user name may remain the same. If you have already an instance of Storage API client in $storageApi
, then you can get credentials to transformation database with the following call:
// get current credentials
$provisioning = new \Keboola\Provisioning\Client('snowflake', $storageApi->getTokenString(), $storageApi->getRunId());
$credentials = $provisioning->getCredentials('transformations');
$provisioning->dropCredentials($credentials['id']);
// get new credentials
$credentials = $provisioning->getCredentials('transformations');
Library is available as composer package. To start using composer in your project follow these steps:
Install composer
curl -s http://getcomposer.org/installer | php
mv ./composer.phar ~/bin/composer # or /usr/local/bin/composer
Create composer.json file in your project root folder:
{
"require": {
"php" : ">=5.3.2",
"keboola/provisioning-client": "0.3.*"
}
}
Install package:
composer install
Add autoloader in your bootstrap script:
require 'vendor/autoload.php';
Read more in Composer documentation
- Create
.env
file and fill the missing info
PROVISIONING_API_URL=
PROVISIONING_API_TOKEN=
SYRUP_QUEUE_URL=
- Build Docker image
docker-compose build
Run tests with following command.
docker-compose run --rm tests /code/vendor/bin/phpunit
Please note, for running Docker (RStudio / Jupyter) tests, you need to have async job queue processing running or
run the provisioning:devel:poll-jobs
command of the provisioning-bundle.
MIT licensed, see LICENSE file.