|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectus.monoid.web.Resty
io.clarify.api.ClarifyClient
public class ClarifyClient
The starting point for the Clarify API Java SDK. The client offers two methods of interacting with the Clarify API: 1) A high-level API for performing common workflows, including high-level classes to wrap API resource responses 2) A low-level API for directly interacting with the Clarify REST API. This provides only a thin wrapper around the actual HTTP request, but will perform the necessary steps for constructing properly-formed HTTP requests and for sending credentials. The low-level API uses Resty, a lightweight wrapper for making HTTP API calls and processing the response payload using CSS-style JSON selectors. More details are available at the Resty Overview page
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class us.monoid.web.Resty |
|---|
us.monoid.web.Resty.Option, us.monoid.web.Resty.Proxy, us.monoid.web.Resty.Timeout |
| Field Summary | |
|---|---|
static String |
CLARIFY_BASE_URI
|
static String |
DEFAULT_VERSION
|
static String |
SDK_VERSION
|
| Fields inherited from class us.monoid.web.Resty |
|---|
DEFAULT_USER_AGENT, MOZILLA, userAgent |
| Constructor Summary | |
|---|---|
ClarifyClient(String appKey)
|
|
| Method Summary | |
|---|---|
BundleTrack |
addTrackToBundle(String bundleId,
URI trackUri)
Adds a new Track to the Bundle with the given media URI, then fetches the resulting resource (resulting in 2 API calls) |
protected String |
baseUri()
Returns the base URI for the Clarify API |
String |
buildPathFromHref(String href)
Helper to concatenate the base URI of the Clarify API with a given HREF |
String |
buildPathFromResourcePath(String resourcePath)
Helper to concatenate the base URI of the Clarify API, the version, and a given resource path |
Bundle |
createBundle(String name,
URI mediaURI)
Creates a new Clarify Bundle using the Create Bundle REST API. |
Bundle |
createBundle(String name,
URI mediaURI,
Map<String,String> fields)
Creates a new Clarify Bundle using the Create Bundle REST API using a name, initial media URL, and any number of additional fields (as defined by the Clarify Create Bundle API). |
boolean |
deleteBundle(String bundleId)
Deletes this bundle by bundleId, all of its related Metadata and Tracks, along with media stored on Clarify systems. |
boolean |
deleteTrack(String bundleId,
String trackId)
Deletes a track from a specific media Bundle. |
Bundle |
findBundle(String bundleId)
Uses the Retrieve Bundle API to return a specific Bundle by the specific bundleId |
Bundle |
findBundleByHref(String href)
Uses the Retrieve Bundle API to return a specific Bundle by the specific relative href path |
BundleMetadata |
findMetadata(String bundleId)
Returns a Bundle's Metadata class, with details on the bundle and any attached user data (if available) |
BundleTrack |
findTrackByHref(String href)
Returns a specific Track by the HREF provided in a JSON response |
BundleTrack |
findTrackForBundle(String bundleId,
String trackId)
Returns a specific Track by track number for a media Bundle |
BundleList |
listBundles()
Retrieves the first page from the List Bundles REST API. |
BundleTrackList |
listTracksForBundle(String bundleId)
Returns the list of Tracks associated to this media Bundle |
boolean |
resetMetadata(String bundleId)
Delete the metadata of a bundle and set data to {} (empty object.) This is functionally equivalent to an update metadata request with data set to {}. |
BundleSearchResults |
searchBundles(String query)
Performs a wildcard search for the specific query string provided. |
BundleSearchResults |
searchBundles(String query,
Map<String,String> params)
Performs an advanced search for the specific query string provided using the additional search query parameters provided. |
boolean |
updateBundle(String bundleId,
Map<String,String> fields)
Updates an existing Bundle's properties, incrementing the Bundle version number on success. |
BundleMetadata |
updateMetadata(String bundleId,
String json)
Updates the user-defined data property of the Bundle's Metadata with the supplied JSON string, then return a refreshed copy (resulting in 2 API calls) |
String |
urlEncodeMap(Map<String,String> fields)
|
protected String |
version()
Returns the default API version |
| Methods inherited from class us.monoid.web.Resty |
|---|
addAdditionalHeaders, addStandardHeaders, alwaysSend, authenticate, authenticate, authenticateForRealm, bytes, bytes, bytes, bytes, content, content, content, createBinaryResource, createJSONResource, createTextResource, createXMLResource, data, data, delete, doGET, dontSend, doPOSTOrPUT, enc, fillResourceFromURL, form, form, getAdditionalHeaders, identifyAsMozilla, identifyAsResty, ignoreAllCerts, json, json, json, json, openConnection, path, put, setOptions, setProxy, text, text, text, text, withHeader, xml, xml, xml, xml, xpath |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static String CLARIFY_BASE_URI
public static String DEFAULT_VERSION
public static String SDK_VERSION
| Constructor Detail |
|---|
public ClarifyClient(String appKey)
| Method Detail |
|---|
public Bundle createBundle(String name,
URI mediaURI)
throws IOException
name - a string containing the name of the API bundlemediaURI - a URI containing a valid URL where the media for this Bundle resides
IOException - if the bundle fails creation
public Bundle createBundle(String name,
URI mediaURI,
Map<String,String> fields)
throws IOException
name - a string containing the name of the API bundlemediaURI - a URI containing a valid URL where the media for this Bundle residesfields - a Map of key-value String pairs with any additional parameter values. This value may be null or empty if no additional
parameters are desired
IOException - on a non-success HTTP response containing the JSON payload with the message and any error details
public BundleList listBundles()
throws IOException
IOException - on a non-success HTTP response containing the JSON payload with the message and any error details
public BundleSearchResults searchBundles(String query)
throws IOException
query - a raw string (automatically URL encoded) containing the query string to search for within the bundles
IOException - on a non-success HTTP response containing the JSON payload with the message and any error details
public BundleSearchResults searchBundles(String query,
Map<String,String> params)
throws IOException
query - a raw string (automatically URL encoded) containing the query string to search for within the bundlesparams - a Map of key-value String pairs to pass to the search API. May be nill or empty if no additional parameters are to be provided
IOException - on a non-success HTTP response containing the JSON payload with the message and any error details
public Bundle findBundleByHref(String href)
throws IOException
href - a String containing the relative href path of the Bundle to attempt to retrieve, as returned by the Clarify API
IOException - if a HTTP 400 error is returned due to a malformed GUID, or if a HTTP 404 not found is returned.
The response will contain a JSON payload with a message and error details
public Bundle findBundle(String bundleId)
throws IOException
bundleId - a String containing the GUID of the Bundle to attempt to retrieve
IOException - if a HTTP 400 error is returned due to a malformed GUID, or if a HTTP 404 not found is returned.
The response will contain a JSON payload with a message and error details
public boolean updateBundle(String bundleId,
Map<String,String> fields)
throws IOException
bundleId - a String containing the GUID of the Bundle to attempt to updatefields - A Map of key-value String pairs with the fields to update (see the API docs for field names allowed to be updated)
IOException - if a HTTP 400 error is returned due to a malformed GUID, or if a HTTP 404 not found is returned.
The response will contain a JSON payload with a message and error details
public boolean deleteBundle(String bundleId)
throws IOException
bundleId -
IOException - if an error occurred during the delete bundle API call
public BundleTrackList listTracksForBundle(String bundleId)
throws IOException
bundleId - the GUID of the Bundle to retrieve the Tracks for
IOException - if a failure occurred during the API,
typically a 4xx HTTP error code + JSON payload with the error message and details
public BundleTrack addTrackToBundle(String bundleId,
URI trackUri)
throws IOException
bundleId - the GUID of the Bundle to add the Track totrackUri - the URI of the remote media file to add to the Bundle
IOException - if a failure occurred during the API,
typically a 4xx HTTP error code + JSON payload with the error message and details
RuntimeException - if there is a failure calling the Find Track API
public BundleTrack findTrackForBundle(String bundleId,
String trackId)
throws IOException
bundleId - the GUID of the Bundle to retrieve the Track fortrackId - the GUID of the Track
IOException - if a failure occurred during the API,
typically a 4xx HTTP error code + JSON payload with the error message and details
public BundleTrack findTrackByHref(String href)
throws IOException
href - the relative URL to the resource
IOException - if a failure occurred during the API,
typically a 4xx HTTP error code + JSON payload with the error message and details
public boolean deleteTrack(String bundleId,
String trackId)
throws IOException
bundleId - the GUID of the Bundle to delete the specific trackNum fortrackId - the GUID of the Track to delete
IOException - if a failure occurred during the API,
typically a 4xx HTTP error code + JSON payload with the error message and details
public BundleMetadata findMetadata(String bundleId)
throws IOException
bundleId - the GUID of the Bundle to retrieve the Metadata for
IOException - if a failure occurred during the API,
typically a 4xx HTTP error code + JSON payload with the error message and details
public BundleMetadata updateMetadata(String bundleId,
String json)
throws IOException
bundleId - the GUID of the Bundle for updating the Metadatajson - a String containing valid JSON, or null. If null is passed, then the data is reset to a JSON equiv of {}
IOException - if a failure occurred during the API,
typically a 4xx HTTP error code + JSON payload with the error message and details
public boolean resetMetadata(String bundleId)
throws IOException
IOException - if a failure occurred during the API,
typically a 4xx HTTP error code + JSON payload with the error message and detailspublic String buildPathFromHref(String href)
href - the full path to the resource
public String buildPathFromResourcePath(String resourcePath)
resourcePath - the full path to the resource
public String urlEncodeMap(Map<String,String> fields)
protected String baseUri()
protected String version()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||