Skip to content

Latest commit

 

History

History
276 lines (176 loc) · 18.1 KB

File metadata and controls

276 lines (176 loc) · 18.1 KB

Client.Tools

Overview

Available Operations

list

Returns a filtered set of available tools based on optional tool name parameters. If no filters are provided, all available tools are returned.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.tools.list()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
tool_names List[str] Optional array of tool names to filter by
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ToolsListResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*

run

Execute the specified tool with provided parameters

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.tools.run(name="<value>", parameters={

    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ Required name of the tool to execute
parameters Dict[str, models.ToolsCallParameter] ✔️ The parameters for the tool. Each key is the name of the parameter and the value is the parameter object.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ToolsCallResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*

retrieve_action_pack_auth_status

Reports whether the calling user is already authenticated against the third-party tool backing the specified action pack. Intended for headless / server-driven clients that render an "Authorize" prompt when the user has not yet consented to the tool.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.tools.retrieve_action_pack_auth_status(action_pack_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
action_pack_id str ✔️ ID of the action pack to query or authorize.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ActionPackAuthStatusResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*

authorize_action_pack

Starts the third-party OAuth flow for the specified action pack and returns the redirect URL that the client should navigate the end user to. After the OAuth callback completes, the user's browser is redirected back to returnUrl with a status query parameter (?glean_action_auth=success|error&actionPackId=...).

returnUrl must match the tenant's configured return URL allowlist; otherwise the request is rejected with 400.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.tools.authorize_action_pack(action_pack_id="<id>", return_url="https://merry-allocation.org/")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
action_pack_id str ✔️ ID of the action pack to query or authorize.
return_url str ✔️ URL on the customer's domain to redirect the end user's browser back to after the third-party OAuth
callback completes. Must be present in the tenant's return URL allowlist.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.AuthorizeActionPackResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*

retrieve_tool_server_auth_status

Returns display information and the calling user's current authentication status for the specified tool server.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.tools.retrieve_tool_server_auth_status(server_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
server_id str ✔️ Unique identifier of the tool server.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ToolServerAuthStatusResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*

authorize_tool_server

Initiates the third-party OAuth flow for the specified tool server and returns the authorization URL that the client should navigate the end user to. After the OAuth callback completes, the user's browser is redirected back to returnUrl with query parameters indicating the result.

returnUrl must match the tenant's configured return URL allowlist; otherwise the request is rejected with 400.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.tools.authorize_tool_server(server_id="<id>", return_url="https://lucky-disadvantage.com")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
server_id str ✔️ Unique identifier of the tool server.
return_url str ✔️ URL to redirect the end user's browser back to after the OAuth flow completes.
Must be present in the tenant's configured return URL allowlist.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.AuthorizeToolServerResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*