VDMS Api Client
Java client library for consuming the Verizon Digital Media Services (formerly Uplynk) streaming API.
Goals
- Comprehensive support for the Verizon Digital Media Services API.
- Minimal dependencies. Currently the main source depends on only three libraries:
- Broad compatibility.
VDMSApiClient
is written in Java 8, so can it be included in most current Java & Kotlin applications. - Full test coverage.
- Robust error handling.
VDMSApiClient
aims to catch errors in requests before they are sent.
Usage
There are two ways you can use this library:
- Using a higher-level
VDMSApiClient
, or - Using the lower-level
VDMSApiGateway
(which is what each VDMSApiClient
uses itself).
Using a VDMSApiClient
offers several advantages over the VDMSApiGateway
, including:
- type safety
- clear signatures for requests and responses
- built-in JSON serialization/deserialization
- request validation
The disadvantage to using a VDMSApiClient
is that you're limited to the APIs it supports. While this library strives to offer comprehensive support of the full range of VDMS streaming APIs, it only supports a small fraction of them at the current time.
The VDMSApiGateway
allows you to consume any and all of the published VDMS streaming APIs. However, if you use it, you are responsible for handling request validation, JSON serialization/deseriazation, response error handling, etc.
Account credentials
Whether you use VDMSApiClient
or VDMSApiGateway
, you will need to supply three pieces of data:
ROOT_URL
: The root url of the VDMS API, currently https://services.uplynk.com
OWNER
: Your account User ID. You can find this on the VDMS Settings page.SECRET
: Your account API Key. You can find this on the VDMS Integration Keys page.
VDMSApiClient
Instantiating a new instance:
VDMSChannelApiClient channelApiClient = new VDMSChannelApiClient(ROOT_URL, OWNER, SECRET);
For a full list of features, consult the tests; here are a few examples of things you can do with VDMSChannelApiClient
:
- Listing all channels in your account:
VDMSListChannelsResponse response = channelApiClient.listChannels();
List<VDMSChannel> channels = response.getChannels();
- Creating a new channel:
VDMSCreateChannelRequest request = VDMSCreateChannelRequest.builder()
.title("A new channel")
.build();
VDMSCreateChannelResponse response = channelApiClient.createChannel(request);
if (response.getError() == 0) {
VDMSChannel channel = response.getChannel();
} else {
}
- Deleting a channel:
VDMSChannel channel;
VDMSDeleteChannelRequest request = VDMSDeleteChannelRequest.builder()
.id(channel.getId())
.build();
VDMSDeleteChannelResponse response = channelApiClient.deleteChannel(request);
if (response.getError() != 0) {
}
Notice that VDMSApiClient
is built around a request/response pattern. Each API method takes in a request object of certain shape and returns a response object of a certain shape.
VDMSApiGateway
Instantiating a new instance:
VDMSApiGateway apiGateway = new VDMSApiGateway(ROOT_URL, OWNER, SECRET);
Here are the same actions described above, but using VDMSApiGateway
instead:
- Listing all channels in your account:
String response = apiGateway.call("/api2/channel/list");
- Creating a new channel:
Map<String, Object> params = new HashMap<String, Object>() {{
put("desc", "New Title");
put("slicer_id", "my_slicer");
put("meta", "{\"key1\": \"value1\"}");
}};
String response = vdmsApiGateway.call("/api2/channel/create", params);
- Deleting a channel:
List<String> ids = Collections.singletonList("0a671113bebb4192bf679db9ee146051");
List<String> externalIds = Arrays.asList("channel1", "channel2");
Map<String, Object> params = new HashMap<String, Object>() {{
put("ids", ids);
put("external_ids", externalIds);
}};
String response = vdmsApiGateway.call("/api2/channel/delete", params);
Contributing
Clone the repository:
$ git clone https://github.com/alexbasson/vdms-api-client.git
$ cd vdms-api-client
Run the tests:
$ ./mvnw clean test
Pushing new code:
$ ./scripts/ship-it.sh