SapiClient-class: Client for working with Keboola Connection Storage API.

SapiClient-classR Documentation

Client for working with Keboola Connection Storage API.

Description

Client for working with Keboola Connection Storage API.

Methods

bucketExists(bucketId)

Check that a bucket exists.

Parameters

  • bucketId Bucket ID.

Return Value

TRUE or FALSE

createBucket(name, stage, description, backend = "redshift")

Create a new bucket.

Parameters

  • name Name of the bucket.

  • stage One of in, out, sys.

  • description Arbitrary description of the bucket.

  • name Database backend - eithe mysql or redshift.

Return Value

List with bucket details.

createConfigurationRow(componentId, configId, rowId, configuration = list())

Create a new component configuration row.

Parameters

  • componentId Component ID.

  • configurationId Configuration ID.

  • rowId ID for the row

  • configuration The configuration to be stored as the row.

Return Value

The component configuration row

createCredentials(bucketId, credentialsName)

Create read-only redshift credentials for a given bucket.

Parameters

  • bucketId Bucket ID.

  • credentialsName Descriptive name for the credentials.

Return Value

List with redshift credentials

createWorkspace(backend = NULL)

Create a new workspace. If backend not specified, project default backend will be used.

Parameters

  • backend Either 'redshift' or 'snowflake'.

Return Value

The new workspace

decodeResponse(response)

Internal method to process API response.

Parameters

  • response List as returned from httr POST/GET method.

Return Value

Response body - either list or string in case the body cannot be parsed as JSON.

deleteBucket(bucketId)

Delete a bucket.

Parameters

  • bucketId String ID of the bucket.

Return Value

TRUE

deleteComponentConfiguration(componentId, configId)

DELETE the provided component configuration. CAUTION: this action is irreversible.

Parameters

  • componentId ID of the component

  • configId ID of the configuration

Return Value

TRUE

deleteConfigurationRow(componentId, configId, rowId, configuration = list())

DELETE the provided component configuration row.

Parameters

  • componentId ID of the component

  • configId ID of the configuration

  • rowId ID of the configurationRow

Return Value

TRUE

deleteCredentials(credentialsId)

Delete redshift credentials.

Parameters

  • credentialsId Credentials ID

Return Value

TRUE

deleteFile(fileId)

load a file from SAPI into your current R session.

Parameters

  • fileId the id of the file to delete

Return Value

TRUE

deleteTable(tableId)

Delete a table.

Parameters

  • tableId String ID of the table (including bucket ID).

Return Value

TRUE

dropWorkspace(workspaceId)

DELETE the provided workspace.

Parameters

  • workspaceId ID of the workspace

Return Value

TRUE

genericDelete(urlD, query = NULL)

Generic DELETE method.

Parameters

  • urlD Target URL.

  • query Query parameters.

Return Value

TRUE for success. Will throw error if status code returned is not 204.

genericGet(urlG, query = NULL)

Generic POST method.

Parameters

  • urlG Target URL.

  • query Query parameters.

Return Value

Decoded JSON body as a list of items.

genericPost(urlP, data = NULL)

Generic POST method.

Parameters

  • urlP Target URL.

  • data Body of the request.

Return Value

Decoded JSON body as a list of items.

get(urlG, query = NULL)

Generic GET method.

Parameters

  • urlG Target URL.

  • query List of query arguments ex. list(foo = bar).

Return Value

List with HTTP response.

getBucket(bucketId)

Get bucket information.

Parameters

  • bucketId Bucket ID.

Return Value

List with bucket details.

getComponentConfiguration(componentId, configId)

Get KBC Component Configuration.

Parameters

  • componentId ID of the component

  • configId ID of the configuration

Return Value

List containing component configuration

getConfigurationRow(componentId, configId, rowId)

Get KBC Component Configuration Row.

Parameters

  • componentId ID of the component

  • configId ID of the configuration

  • rowId ID of the configuration row

Return Value

List containing component configuration

getCredentials(credentialsId)

List read-only redshift credentials with a given name.

Parameters

  • credentialsId Credentials name.

Return Value

List with redshift credentials

getFileData(fileInfo)

Get a file from the S3 storage

Parameters

  • list File info list object (see getFileInfo()).

Return Value

Data frame with file contents

getFileInfo(fileId, federationToken = 1)

Get information about a file, including credentials.

Parameters

  • fileId Storage file ID.

  • federationToken Use federation token?.

Return Value

List with file information

getJobStatus(url)

Make a status request to an async syrup job

Parameters

  • url This will normally be the url returned from the createTableAsync/importTableAsync methods.

Return Value

List with job details

getS3Object(key, fileInfo)

Get a file from the S3 storage

Parameters

  • key Object Key to retrieve

  • list File info list object (see getFileInfo()).

Return Value

Data frame with file contents

getTable(tableId)

Get table information.

Parameters

  • tableId Table ID (including bucket ID).

Return Value

List with table details.

getWorkspace(workspaceId)

Get KBC Workspace.

Parameters

  • workspaceId ID of the workspace

Return Value

List containing workspace object

importTable(tableId, options = list())

Import a table from Storage into R. Wrapper for the importTableAsync function.

Parameters

  • tableId String table ID (including bucket ID).

  • options List with additional options.

Return Value

data.frame with table contents.

importTableAsync(tableId, options = list())

Begin an export job of a table.

Parameters

  • tableId String table Id (including bucket ID).

  • options List with additional parameters.

Return Value

URL to ping for table creation status check.

initialize(token, url = "https://connection.keboola.com/v2/", userAgent = "Keboola StorageApi R Client/v2")

Constructor.

Parameters

  • token KBC Storage API token.

  • url Optional URL of the provisioning API.

Return Value

Another return value

listBuckets(options = list())

Get a list of all buckets.

Parameters

  • options List with additional options.

Return Value

List of buckets.

listConfigurationRows(componentId, configId)

Get KBC Component Configuration Rows.

Parameters

  • componentId ID of the component

  • configId ID of the configuration

Return Value

List of component configuration rows

listCredentials()

List read-only redshift credentials.

Return Value

List with redshift credentials

listFiles(tags = NULL, limit = NULL, offset = NULL)

Get list of fileinfo objects about files in sapi.

Parameters

  • tags list of tags

  • limi limit of # of files to return. SAPI default is 100

  • offset which page of results to return, SAPI default is 0 (first page).

Return Value

List of fileInfo objects

listTables(bucket = NULL, options = list())

Get a list of all tables.

Parameters

  • bucket Bucket ID (if empty, list all tables).

  • options List with additional options.

Return Value

List of tables.

listWorkspaces()

Get KBC Workspaces.

Return Value

List of workspace

loadFile(fileId, options)

load a file from SAPI into your current R session.

Parameters

  • fileId the id of the file to load (hint: use listFiles to find the id of the file you want to load)

Return Value

the contents of the file

newComponentConfiguration(componentId, configurationId, name, description = "")

Create a new component configuration. Note that the configuration property must be put in a subsequent PUT call.

Parameters

  • configurationId Configuration ID.

  • name Name of the cconfiguration

  • description Descriptiion for the configuration.

Return Value

List with component configuration

prepareOptions(options)

Internal helper for parsing options

Parameters

  • options List.

Return Value

List with options

putComponentConfiguration(componentId, configId, configuration)

PUT the configuration property of the KBC Component Configuration.

Parameters

  • componentId ID of the component

  • configId ID of the configuration

  • configuration the configuration property (should be of type list)

Return Value

list of the new component configuration

putFile(fileName, tags = NULL)

Get list of fileinfo objects about files in sapi.

Parameters

  • fileName fileName including path if file not in the current directory

  • tags tags to describe the file

Return Value

fileId of the created file

saveTable(df, bucket, tableName, fileName = "tmpfile.csv", options = list())

Save a table to Storage. Wrapper for the saveTableAsync function.

Parameters

  • df data.frame to save.

  • bucket String bucket ID.

  • tableName String table name.

  • fileName String name of temporary file to use, will be deleted when done.

  • options List with additional options.

Return Value

String job ID

saveTableAsync(bucket, tableName, fileId, opts = list())

Create/Overwrite a new table in a bucket ascynchronously. Generally use the saveTable method

Parameters

  • bucket Storage bucket ID.

  • tableName Table name.

  • fileId Id of file received from the uploadFile method.

  • opts List with additional parameters.

Return Value

URL to ping for table creation status check.

tableExists(tableId)

Check that a bucket exists.

Parameters

  • tableId Table ID (including bucket ID).

Return Value

TRUE or FALSE

updateConfigurationRow(componentId, configId, rowId, configuration = list())

PUT the configuration property of the KBC Component Configuration Row.

Parameters

  • componentId ID of the component

  • configId ID of the configuration

  • rowId ID of the row

  • configuration the configuration property (should be of type list)

Return Value

list of the new component configuration

uploadFile(dataFile, options = list())

Upload a file to AWS S3 bucket. (compression is not yet supported by this client)

Parameters

  • string File to upload.

  • options List options. (For a full list of options please see the api docs).

Return Value

Integer file ID of the uploaded file.

verifyToken()

Get details of the current token

Return Value

List containing details of this client's token


keboola/sapi-r-client documentation built on March 15, 2023, 5:37 a.m.