Skip to content

Latest commit

 

History

History
121 lines (90 loc) · 5.12 KB

File metadata and controls

121 lines (90 loc) · 5.12 KB

Client.Tools

Overview

Available Operations

  • List - List available tools
  • Run - Execute the specified tool

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

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Client.Tools.List(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.ToolsListResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
toolNames []string Optional array of tool names to filter by
opts []operations.Option The options for this request.

Response

*operations.GetRestAPIV1ToolsListResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Run

Execute the specified tool with provided parameters

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Client.Tools.Run(ctx, components.ToolsCallRequest{
        Name: "<value>",
        Parameters: map[string]components.ToolsCallParameter{
            "key": components.ToolsCallParameter{
                Name: "<value>",
                Value: "<value>",
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.ToolsCallResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.ToolsCallRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.PostRestAPIV1ToolsCallResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*