(webhook())
Operations related to webhook api
Retrieve a Webhook
package hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.GetWebhooksResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetWebhooksResponse res = sdk.webhook().getAll()
.call();
if (res.data().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
GetWebhooksResponse
Error Object |
Status Code |
Content Type |
models/errors/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 hello.world;
import java.lang.Exception;
import java.util.List;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.components.Events;
import studio.livepeer.livepeer.models.components.WebhookInput;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.CreateWebhookResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
WebhookInput req = WebhookInput.builder()
.name("test_webhook")
.url("https://my-service.com/webhook")
.projectId("aac12556-4d65-4d34-9fb6-d1f0985eb0a9")
.events(List.of(
Events.STREAM_STARTED,
Events.STREAM_IDLE))
.sharedSecret("my-secret")
.streamId("de7818e7-610a-4057-8f6f-b785dc1e6f88")
.build();
CreateWebhookResponse res = sdk.webhook().create()
.request(req)
.call();
if (res.webhook().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
request |
WebhookInput |
✔️ |
The request object to use for the request. |
CreateWebhookResponse
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
*/* |
Retrieve a webhook
package hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.GetWebhookResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetWebhookResponse res = sdk.webhook().get()
.id("<value>")
.call();
if (res.webhook().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
id |
String |
✔️ |
N/A |
GetWebhookResponse
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
*/* |
Update a webhook
package hello.world;
import java.lang.Exception;
import java.util.List;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.components.Events;
import studio.livepeer.livepeer.models.components.WebhookInput;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.UpdateWebhookResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
UpdateWebhookResponse res = sdk.webhook().update()
.id("<value>")
.webhook(WebhookInput.builder()
.name("test_webhook")
.url("https://my-service.com/webhook")
.projectId("aac12556-4d65-4d34-9fb6-d1f0985eb0a9")
.events(List.of(
Events.STREAM_STARTED,
Events.STREAM_IDLE))
.sharedSecret("my-secret")
.streamId("de7818e7-610a-4057-8f6f-b785dc1e6f88")
.build())
.call();
if (res.webhook().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
id |
String |
✔️ |
N/A |
webhook |
WebhookInput |
✔️ |
N/A |
UpdateWebhookResponse
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
*/* |
Delete a webhook
package hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.DeleteWebhookResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
DeleteWebhookResponse res = sdk.webhook().delete()
.id("<value>")
.call();
if (res.webhook().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
id |
String |
✔️ |
N/A |
DeleteWebhookResponse
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
*/* |
Retrieve webhook logs
package hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.GetWebhookLogsResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetWebhookLogsResponse res = sdk.webhook().getLogs()
.id("<value>")
.call();
if (res.data().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
id |
String |
✔️ |
N/A |
GetWebhookLogsResponse
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
*/* |
Retrieve a webhook log
package hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.GetWebhookLogResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetWebhookLogResponse res = sdk.webhook().getLog()
.id("<value>")
.logId("<value>")
.call();
if (res.webhookLog().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
id |
String |
✔️ |
N/A |
logId |
String |
✔️ |
N/A |
GetWebhookLogResponse
Error Object |
Status Code |
Content Type |
models/errors/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 hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.ResendWebhookResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
ResendWebhookResponse res = sdk.webhook().resendLog()
.id("<value>")
.logId("<value>")
.call();
if (res.webhookLog().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
id |
String |
✔️ |
N/A |
logId |
String |
✔️ |
N/A |
ResendWebhookResponse
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
*/* |