Skip to content

Latest commit

 

History

History
executable file
·
386 lines (300 loc) · 14.7 KB

README.md

File metadata and controls

executable file
·
386 lines (300 loc) · 14.7 KB

Ruleset

Available Operations

Archive

Archive a ruleset

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )
    id := "recusandae"

    ctx := context.Background()
    res, err := s.Ruleset.Archive(ctx, id)
    if err != nil {
        log.Fatal(err)
    }

    if res.Ruleset != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A

Response

*operations.ArchiveRulesetResponse, error

Create

Create a ruleset

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Ruleset.Create(ctx, operations.CreateRulesetRequestBody{
        IsTeamDefault: hookdeck.Bool(false),
        Name: "Miss Cesar Metz",
        Rules: []interface{}{
            shared.TransformReference{
                TransformationID: "occaecati",
                Type: shared.TransformReferenceTypeTransform,
            },
            shared.TransformReference{
                TransformationID: "asperiores",
                Type: shared.TransformReferenceTypeTransform,
            },
            shared.DelayRule{
                Delay: 267262,
                Type: shared.DelayRuleTypeDelay,
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.Ruleset != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.CreateRulesetRequestBody ✔️ The request object to use for the request.

Response

*operations.CreateRulesetResponse, error

Get

Get a ruleset

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )
    id := "iste"

    ctx := context.Background()
    res, err := s.Ruleset.Get(ctx, id)
    if err != nil {
        log.Fatal(err)
    }

    if res.Ruleset != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A

Response

*operations.GetRulesetResponse, error

Unarchive

Unarchive a ruleset

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )
    id := "dolorum"

    ctx := context.Background()
    res, err := s.Ruleset.Unarchive(ctx, id)
    if err != nil {
        log.Fatal(err)
    }

    if res.Ruleset != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A

Response

*operations.UnarchiveRulesetResponse, error

Update

Update a ruleset

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )
    requestBody := operations.UpdateRulesetRequestBody{
        IsTeamDefault: hookdeck.Bool(false),
        Name: hookdeck.String("Ervin McLaughlin"),
        Rules: []interface{}{
            shared.AlertRule{
                Strategy: shared.AlertStrategyLastAttempt,
                Type: shared.AlertRuleTypeAlert,
            },
            shared.AlertRule{
                Strategy: shared.AlertStrategyEachAttempt,
                Type: shared.AlertRuleTypeAlert,
            },
            shared.AlertRule{
                Strategy: shared.AlertStrategyEachAttempt,
                Type: shared.AlertRuleTypeAlert,
            },
            shared.RetryRule{
                Count: hookdeck.Int64(218749),
                Interval: hookdeck.Int64(944373),
                Strategy: shared.RetryStrategyExponential,
                Type: shared.RetryRuleTypeRetry,
            },
        },
    }
    id := "cum"

    ctx := context.Background()
    res, err := s.Ruleset.Update(ctx, requestBody, id)
    if err != nil {
        log.Fatal(err)
    }

    if res.Ruleset != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
requestBody operations.UpdateRulesetRequestBody ✔️ N/A
id string ✔️ N/A

Response

*operations.UpdateRulesetResponse, error

Upsert

Update or create a ruleset

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Ruleset.Upsert(ctx, operations.UpsertRulesetRequestBody{
        IsTeamDefault: hookdeck.Bool(false),
        Name: "Marian Wisozk",
        Rules: []interface{}{
            shared.RetryRule{
                Count: hookdeck.Int64(58029),
                Interval: hookdeck.Int64(56418),
                Strategy: shared.RetryStrategyLinear,
                Type: shared.RetryRuleTypeRetry,
            },
            shared.FilterRule{
                Body: &shared.ConnectionFilterProperty{},
                Headers: &shared.ConnectionFilterProperty{},
                Path: &shared.ConnectionFilterProperty{},
                Query: &shared.ConnectionFilterProperty{},
                Type: shared.FilterRuleTypeFilter,
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.Ruleset != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.UpsertRulesetRequestBody ✔️ The request object to use for the request.

Response

*operations.UpsertRulesetResponse, error