(Webhook)
Operations related to webhook api
- GetAll - Retrieve a Webhook
- Create - Create a webhook
- Get - Retrieve a webhook
- Update - Update a webhook
- Delete - Delete a webhook
- GetLogs - Retrieve webhook logs
- GetLog - Retrieve a webhook log
- ResendLog - Resend a webhook
Retrieve a Webhook
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
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetWebhooksResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
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.
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
}
}
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. |
*operations.CreateWebhookResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Retrieve a webhook
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
}
}
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. |
*operations.GetWebhookResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Update a webhook
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
}
}
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. |
*operations.UpdateWebhookResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Delete a webhook
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
}
}
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. |
*operations.DeleteWebhookResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Retrieve webhook logs
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
}
}
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. |
*operations.GetWebhookLogsResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Retrieve a webhook log
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
}
}
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. |
*operations.GetWebhookLogResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
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.
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
}
}
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. |
*operations.ResendWebhookResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |