Skip to content

Latest commit

 

History

History
306 lines (232 loc) · 17.8 KB

File metadata and controls

306 lines (232 loc) · 17.8 KB

Events

(Events)

Overview

REST APIs for managing events captured by a speakeasy binary (CLI, GitHub Action etc)

Available Operations

  • GetEventsByTarget - Load recent events for a particular workspace
  • GetTargets - Load targets for a particular workspace
  • GetTargetsDeprecated - Load targets for a particular workspace
  • Post - Post events for a specific workspace
  • Search - Search events for a particular workspace by any field

GetEventsByTarget

Load recent events for a particular workspace

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    res, err := s.Events.GetEventsByTarget(ctx, operations.GetWorkspaceEventsByTargetRequest{
        TargetID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.CliEventBatch != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.GetWorkspaceEventsByTargetResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.Error 5XX application/json
sdkerrors.SDKError 4XX */*

GetTargets

Load targets for a particular workspace

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    res, err := s.Events.GetTargets(ctx, operations.GetWorkspaceTargetsRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.TargetSDKList != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.GetWorkspaceTargetsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.Error 5XX application/json
sdkerrors.SDKError 4XX */*

GetTargetsDeprecated

Load targets for a particular workspace

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    res, err := s.Events.GetTargetsDeprecated(ctx, operations.GetWorkspaceTargetsDeprecatedRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.TargetSDKList != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.GetWorkspaceTargetsDeprecatedResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.Error 5XX application/json
sdkerrors.SDKError 4XX */*

Post

Sends an array of events to be stored for a particular workspace.

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/types"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    res, err := s.Events.Post(ctx, operations.PostWorkspaceEventsRequest{
        RequestBody: []shared.CliEvent{
            shared.CliEvent{
                CreatedAt: types.MustTimeFromString("2024-08-12T17:54:17.538Z"),
                ExecutionID: "<id>",
                ID: "<id>",
                InteractionType: shared.InteractionTypeCiExec,
                LocalStartedAt: types.MustTimeFromString("2023-11-23T06:26:30.993Z"),
                SpeakeasyAPIKeyName: "<value>",
                SpeakeasyVersion: "<value>",
                Success: false,
                WorkspaceID: "<id>",
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.PostWorkspaceEventsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.Error 5XX application/json
sdkerrors.SDKError 4XX */*

Search

Search events for a particular workspace by any field

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    res, err := s.Events.Search(ctx, operations.SearchWorkspaceEventsRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.CliEventBatch != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.SearchWorkspaceEventsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.Error 5XX application/json
sdkerrors.SDKError 4XX */*