Skip to content

Latest commit

 

History

History
444 lines (327 loc) · 18 KB

README.md

File metadata and controls

444 lines (327 loc) · 18 KB

Webhook

(Webhook)

Overview

Operations related to webhook api

Available Operations

GetAll

Retrieve a Webhook

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.Webhook.GetAll(ctx)
    if err != nil {
        log.Fatal(err)
    }
    if res.Data != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.GetWebhooksResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

Create

To create a new webhook, you need to make an API call with the events you want to listen for and the URL that will be called when those events occur.

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"github.com/livepeer/livepeer-go/models/components"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.Webhook.Create(ctx, components.WebhookInput{
        Name: "test_webhook",
        ProjectID: livepeergo.String("aac12556-4d65-4d34-9fb6-d1f0985eb0a9"),
        Events: []components.Events{
            components.EventsStreamStarted,
            components.EventsStreamIdle,
        },
        URL: "https://my-service.com/webhook",
        SharedSecret: livepeergo.String("my-secret"),
        StreamID: livepeergo.String("de7818e7-610a-4057-8f6f-b785dc1e6f88"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Webhook != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.CreateWebhookResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

Get

Retrieve a webhook

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.Webhook.Get(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Webhook != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.GetWebhookResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

Update

Update a webhook

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"github.com/livepeer/livepeer-go/models/components"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.Webhook.Update(ctx, "<id>", components.WebhookInput{
        Name: "test_webhook",
        ProjectID: livepeergo.String("aac12556-4d65-4d34-9fb6-d1f0985eb0a9"),
        Events: []components.Events{
            components.EventsStreamStarted,
            components.EventsStreamIdle,
        },
        URL: "https://my-service.com/webhook",
        SharedSecret: livepeergo.String("my-secret"),
        StreamID: livepeergo.String("de7818e7-610a-4057-8f6f-b785dc1e6f88"),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Webhook != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A
webhook components.WebhookInput ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.UpdateWebhookResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

Delete

Delete a webhook

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.Webhook.Delete(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Webhook != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.DeleteWebhookResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

GetLogs

Retrieve webhook logs

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.Webhook.GetLogs(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Data != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.GetWebhookLogsResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

GetLog

Retrieve a webhook log

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.Webhook.GetLog(ctx, "<id>", "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.WebhookLog != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A
logID string ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.GetWebhookLogResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

ResendLog

Use this API to resend the same webhook request. This is useful when developing and debugging, allowing you to easily repeat the same webhook to check or fix the behaviour in your handler.

Example Usage

package main

import(
	livepeergo "github.com/livepeer/livepeer-go"
	"context"
	"log"
)

func main() {
    s := livepeergo.New(
        livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
    )

    ctx := context.Background()
    res, err := s.Webhook.ResendLog(ctx, "<id>", "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.WebhookLog != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A
logID string ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.ResendWebhookResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /