Skip to content

Latest commit

 

History

History
509 lines (369 loc) · 14.9 KB

README.md

File metadata and controls

509 lines (369 loc) · 14.9 KB

Webhook

(webhook())

Overview

Operations related to webhook api

Available Operations

getAll

Retrieve a Webhook

Example Usage

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;
        }

    }
}

Response

GetWebhooksResponse

Errors

Error Object Status Code Content Type
models/errors/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 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;
        }

    }
}

Parameters

Parameter Type Required Description
request WebhookInput ✔️ The request object to use for the request.

Response

CreateWebhookResponse

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx */*

get

Retrieve a webhook

Example Usage

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;
        }

    }
}

Parameters

Parameter Type Required Description
id String ✔️ N/A

Response

GetWebhookResponse

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx */*

update

Update a webhook

Example Usage

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;
        }

    }
}

Parameters

Parameter Type Required Description
id String ✔️ N/A
webhook WebhookInput ✔️ N/A

Response

UpdateWebhookResponse

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx */*

delete

Delete a webhook

Example Usage

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;
        }

    }
}

Parameters

Parameter Type Required Description
id String ✔️ N/A

Response

DeleteWebhookResponse

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx */*

getLogs

Retrieve webhook logs

Example Usage

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;
        }

    }
}

Parameters

Parameter Type Required Description
id String ✔️ N/A

Response

GetWebhookLogsResponse

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx */*

getLog

Retrieve a webhook log

Example Usage

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;
        }

    }
}

Parameters

Parameter Type Required Description
id String ✔️ N/A
logId String ✔️ N/A

Response

GetWebhookLogResponse

Errors

Error Object Status Code Content Type
models/errors/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 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;
        }

    }
}

Parameters

Parameter Type Required Description
id String ✔️ N/A
logId String ✔️ N/A

Response

ResendWebhookResponse

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx */*