circle-boltExecution

Basic Example (Direct Execution)

It is the basic way to execute actions, where you need to provide the connector name, action name, and user token. The response will contain the data and status:

params = {
    "owner": "gdp-admin",
    "author": "samuellusandi",
    "per_page": 1,
}
data = connector.execute("github", "search_commits", token=user_token, input_=params)
print(data)

Alternative Approach (Fluent Interface)

For more complex scenarios or more control over the execution, you can use the fluent interface. We're recommending this approach if you:

  • Need to execute multiple actions with different parameters

  • Expecting list response

  • Need to execute actions in a loop

params = {
    "owner": "gdp-admin",
    "author": "samuellusandi",
    "per_page": 1,
}
github = connector.connect('github')
response = github.action('list_pull_requests')\
    .params(params)\
    .max_attempts(3)\
    .token('user-token')\
    .run()  # Execute and return ActionResponse for advanced data handling

# Get initial data
initial_data = response.get_data()

# Iterate the following next pages
while response.has_next():
    response = response.next_page(
    data = response.get_data()
    # Process data here

# You can also navigate backwards
while response.has_prev():
    response = response.prev_page()
    data = response.get_data()
    # Process data here

# Execute multiple independent actions using the same connector instance
commits_response = github.action('list_commits')\
    .params({
        'owner': 'GDP-ADMIN',
        'repo': 'gl-connectors',
        'page': 1,
        'per_page': 10
    })\
    .token('user-token')\
    .run()

run method also available for direct execution from connector instance, without using fluent interface.

Working with Files using ConnectorFile

When working with APIs that require file uploads or return file downloads, use the ConnectorFile model. Here are the examples of how to uplaod or download files using GL Connectors.

Uploading Files

Downloading Files

Last updated