public class AtmosApiClient extends AbstractAtmosApi
| Object Type (class) | Expected Content-Type(s) |
|---|---|
| byte[] | *any* |
| java.lang.String | *any* |
| java.io.File (send-only) | *any* |
| java.io.InputStream (send-only) | *any* |
| com.emc.atmos.api.BufferSegment (send-only) | *any* |
| any annotated JAXB root element bean | text/xml, application/xml |
| com.emc.atmos.api.multipart.MultipartEntity (receive-only) | multipart/* |
URI atmosEndpoint = new URI( "http://api.atmosonline.com" ); // or use your private cloud endpoint/load balancer
AtmosApi atmos = new AtmosApiClient( new AtmosConfig( "my_full_token_id", "my_secret_key", atmosEndpoint ) );
You can also specify multiple endpoints and have each request round-robin between them like so:
URI endpoint1 = new URI( "https://10.0.0.101" ); // 1st Atmos node
URI endpoint2 = new URI( "https://10.0.0.102" ); // 2nd Atmos node
URI endpoint3 = new URI( "https://10.0.0.103" ); // 3rd Atmos node
URI endpoint4 = new URI( "https://10.0.0.104" ); // 4th Atmos node
AtmosApi atmos = new AtmosApiClient( new AtmosConfig( "my_full_token_id", "my_secret_key",
endpoint1, endpoint2, endpoint3, endpoint4 ) );
To create an object, simply pass the object in to one of the createObject methods. The object type must be one of
the supported types above.
String stringContent = "Hello World!";
ObjectId oid1 = atmos.createObject( stringContent, "text/plain" );
File fileContent = new File( "spreadsheet.xls" );
ObjectId oid2 = atmos.createObject( fileContent, "application/vnd.ms-excel" );
byte[] binaryContent;
... // load binary content to store as an object
ObjectId oid3 = atmos.createObject( binaryContent, null ); // default content-type is application/octet-stream
To read an object, specify the type of object you want to receive from a readObject method. The same rules apply to
this type.
String stringContent = atmos.readObject( oid1, String.class );
byte[] fileContent = atmos.readObject( oid2, byte[].class );
// do something with file content (stream to client? save in local filesystem?)
byte[] binaryContent = atmos.readObject( oid3, byte[].class );
| Modifier and Type | Field and Description |
|---|---|
protected com.sun.jersey.api.client.Client |
client |
protected com.sun.jersey.api.client.Client |
client100 |
config, DEFAULT_CONTENT_TYPE| Modifier | Constructor and Description |
|---|---|
|
AtmosApiClient(AtmosConfig config) |
protected |
AtmosApiClient(AtmosConfig config,
com.sun.jersey.api.client.Client client,
com.sun.jersey.api.client.Client client100) |
|
AtmosApiClient(AtmosConfig config,
java.util.List<java.lang.Class<javax.ws.rs.ext.MessageBodyReader<?>>> readers,
java.util.List<java.lang.Class<javax.ws.rs.ext.MessageBodyWriter<?>>> writers) |
| Modifier and Type | Method and Description |
|---|---|
void |
addClientFilter(com.sun.jersey.api.client.filter.ClientFilter filter)
Adds a ClientFilter to the Jersey client used to make REST requests.
|
protected com.sun.jersey.api.client.WebResource.Builder |
addHeaders(com.sun.jersey.api.client.WebResource.Builder builder,
java.util.Map<java.lang.String,java.util.List<java.lang.Object>> headers) |
protected com.sun.jersey.api.client.WebResource.Builder |
build(Request request) |
long |
calculateServerClockSkew()
Calculates rough clock skew.
|
CreateAccessTokenResponse |
createAccessToken(CreateAccessTokenRequest request)
Creates an anonymous access token using all of the options provided in the request object.
|
ObjectId |
createDirectory(ObjectPath path)
Creates a directory in the subtenant namespace using the specified path.
|
ObjectId |
createDirectory(ObjectPath path,
Acl acl,
Metadata... metadata)
Creates a directory in the subtenant namespace using the specified path, acl and metadata.
|
CreateObjectResponse |
createObject(CreateObjectRequest request)
Creates a new object in the cloud using all of the options provided in the request object.
|
java.lang.String |
createSubtenant(CreateSubtenantRequest request)
Creates a new Atmos Subtenant in EMC ViPR.
|
ObjectId |
createVersion(ObjectIdentifier identifier)
Creates a new immutable version (snapshot) of the specified object from its current state.
|
void |
delete(ObjectIdentifier identifier)
Deletes an object from the cloud
|
void |
deleteAccessToken(java.lang.String accessTokenId)
Deletes the specified access token.
|
void |
deleteUserMetadata(ObjectIdentifier identifier,
java.lang.String... names)
Deletes metadata associated with the specified object.
|
void |
deleteVersion(ObjectId versionId)
Deletes the specified object version.
|
<T> GenericResponse<T> |
execute(PreSignedRequest request,
java.lang.Class<T> resultType,
java.lang.Object content)
Executes a pre-signed request, sending the specified content as a body (if provided) and returning the specified
resultType (if provided).
|
protected <T extends BasicResponse> |
fillResponse(T response,
com.sun.jersey.api.client.ClientResponse clientResponse)
Populates a response object with data from the ClientResponse.
|
GetAccessTokenResponse |
getAccessToken(java.lang.String accessTokenId)
Retrieves details about the specified access token.
|
Acl |
getAcl(ObjectIdentifier identifier)
Gets the ACL for the specified object.
|
protected java.lang.Object |
getContent(ContentRequest request) |
ObjectInfo |
getObjectInfo(ObjectIdentifier identifier)
Gets storage information for the specified object.
|
ObjectMetadata |
getObjectMetadata(ObjectIdentifier identifier)
Gets an object's metadata, ACL and content-type all in one call.
|
ServiceInformation |
getServiceInformation() |
java.util.Map<java.lang.String,Metadata> |
getSystemMetadata(ObjectIdentifier identifier,
java.lang.String... metadataNames)
Gets the system metadata associated with the specified object.
|
java.util.Map<java.lang.String,Metadata> |
getUserMetadata(ObjectIdentifier identifier,
java.lang.String... metadataNames)
Gets the user metadata associated with the specified object.
|
java.util.Map<java.lang.String,java.lang.Boolean> |
getUserMetadataNames(ObjectIdentifier identifier)
Lists the names of all metadata associated with the specified object.
|
ListAccessTokensResponse |
listAccessTokens(ListAccessTokensRequest request)
Lists all access tokens owned by the user using all of the options provided in the request object.
|
ListDirectoryResponse |
listDirectory(ListDirectoryRequest request)
Lists the contents of a directory in the namespace.
|
java.util.Set<java.lang.String> |
listMetadata(java.lang.String metadataName)
Lists the children of the specified metadata path in the hierarchy of listable metadata for the subtenant.
|
ListObjectsResponse |
listObjects(ListObjectsRequest request)
Lists all objects that are assigned the specified listable metadata using all of the options provided in the
request object.
|
ListVersionsResponse |
listVersions(ListVersionsRequest request)
Lists all versions (snapshots) of the specified object using all of the options provided in the request object.
|
void |
move(ObjectPath oldPath,
ObjectPath newPath,
boolean overwrite)
Moves an object in the namespace to a new location.
|
<T> ReadObjectResponse<T> |
readObject(ReadObjectRequest request,
java.lang.Class<T> objectType)
Reads an object's content from the cloud using all of the options provided in the request object.
|
ReadObjectResponse<java.io.InputStream> |
readObjectStream(ObjectIdentifier identifier,
Range range)
Provides an InputStream to read an object's content from the cloud.
|
void |
restoreVersion(ObjectId objectId,
ObjectId versionId)
Restores the specified version (snapshot) of the specified object so that the object's current state reflects
that of the version.
|
void |
setAcl(ObjectIdentifier identifier,
Acl acl)
Sets the ACL for the specified object.
|
void |
setUserMetadata(ObjectIdentifier identifier,
Metadata... metadata)
Adds or replaces user metadata associated with the specified object.
|
BasicResponse |
updateObject(UpdateObjectRequest request)
Updates an object's content in the cloud using all of the options provided in the request object.
|
createObject, createObject, deleteAccessToken, getAccessToken, getShareableUrl, getShareableUrl, preSignRequest, readObject, readObject, updateObject, updateObjectprotected com.sun.jersey.api.client.Client client
protected com.sun.jersey.api.client.Client client100
public AtmosApiClient(AtmosConfig config)
public AtmosApiClient(AtmosConfig config, java.util.List<java.lang.Class<javax.ws.rs.ext.MessageBodyReader<?>>> readers, java.util.List<java.lang.Class<javax.ws.rs.ext.MessageBodyWriter<?>>> writers)
protected AtmosApiClient(AtmosConfig config, com.sun.jersey.api.client.Client client, com.sun.jersey.api.client.Client client100)
public void addClientFilter(com.sun.jersey.api.client.filter.ClientFilter filter)
public ServiceInformation getServiceInformation()
public long calculateServerClockSkew()
AtmosApipublic CreateObjectResponse createObject(CreateObjectRequest request)
AtmosApirequest - The request object (click on the class name to get more information).public <T> ReadObjectResponse<T> readObject(ReadObjectRequest request, java.lang.Class<T> objectType) throws java.io.IOException
AtmosApirequest - The request object (click on the class name to get more information)objectType - The type of object to return. This can be any object type supported by the implementation.java.io.IOException - if an exception occurs while reading the object. Note that IOExceptions are generally
retried automatically (configured in AtmosConfig).public ReadObjectResponse<java.io.InputStream> readObjectStream(ObjectIdentifier identifier, Range range)
AtmosApiidentifier - The identifier of the object to read. May be any ObjectIdentifier.range - (optional) The range of bytes to read from the object. A null value will read the entire
object.public BasicResponse updateObject(UpdateObjectRequest request)
AtmosApirequest - The request object (click on the class name to get more information)public void delete(ObjectIdentifier identifier)
AtmosApiidentifier - The identifier of the object to delete. May be any ObjectIdentifier.public ObjectId createDirectory(ObjectPath path)
AtmosApipath - The path of the directory to create.public ObjectId createDirectory(ObjectPath path, Acl acl, Metadata... metadata)
AtmosApipath - The path of the directory to create.acl - The ACL to assign to the new directory.metadata - The metadata to associate with the new directory.public ListDirectoryResponse listDirectory(ListDirectoryRequest request)
AtmosApirequest - The request object (click on the class name to get more information)public void move(ObjectPath oldPath, ObjectPath newPath, boolean overwrite)
AtmosApioldPath - The existing path of the object.newPath - The new path that the object should have.overwrite - If true and an object already exists at newPath, this call will overwrite that object.public java.util.Map<java.lang.String,java.lang.Boolean> getUserMetadataNames(ObjectIdentifier identifier)
AtmosApiidentifier - The identifier of the object. Can be any ObjectIdentifier.public java.util.Map<java.lang.String,Metadata> getUserMetadata(ObjectIdentifier identifier, java.lang.String... metadataNames)
AtmosApiidentifier - The identifier of the object. Can be any ObjectIdentifier.metadataNames - (optional) Constrains the result to include only the metadata named in this list.public java.util.Map<java.lang.String,Metadata> getSystemMetadata(ObjectIdentifier identifier, java.lang.String... metadataNames)
AtmosApiidentifier - The identifier of the object. Can be any ObjectIdentifier.metadataNames - (optional) Constrains the result to include only the metadata named in this list.public ObjectMetadata getObjectMetadata(ObjectIdentifier identifier)
AtmosApiidentifier - The identifier of the object. Can be any ObjectIdentifier.public void setUserMetadata(ObjectIdentifier identifier, Metadata... metadata)
AtmosApiAtmosApi.deleteUserMetadata(ObjectIdentifier, String...).identifier - The identifier of the object. Can be any ObjectIdentifier.metadata - The metadata to add to or replace on the object.public void deleteUserMetadata(ObjectIdentifier identifier, java.lang.String... names)
AtmosApiidentifier - The identifier of the object. Can be any ObjectIdentifier.names - The names of the metadata to delete/remove from the object.public java.util.Set<java.lang.String> listMetadata(java.lang.String metadataName)
AtmosApimetadataName - The metadata name (sometime called a "tag") whose children should be returned. If null, all
root-level names will be returned (i.e. "ford", "chevy", "chrysler").public ListObjectsResponse listObjects(ListObjectsRequest request)
AtmosApirequest - The request object (click on the class name to get more information)public Acl getAcl(ObjectIdentifier identifier)
AtmosApiidentifier - The identifier of the object. Can be any ObjectIdentifier.public void setAcl(ObjectIdentifier identifier, Acl acl)
AtmosApiidentifier - The identifier of the object. Can be any ObjectIdentifier.acl - The new ACL for the specified object.public ObjectInfo getObjectInfo(ObjectIdentifier identifier)
AtmosApiidentifier - The identifier of the object. Can be any ObjectIdentifier.public ObjectId createVersion(ObjectIdentifier identifier)
AtmosApiidentifier - The identifier of the object. Can be any ObjectIdentifier.public ListVersionsResponse listVersions(ListVersionsRequest request)
AtmosApirequest - The request object (click on the class name to get more information)public void restoreVersion(ObjectId objectId, ObjectId versionId)
AtmosApiobjectId - The ObjectId of the object.versionId - The ObjectId of the version (must be a version of the specified object).public void deleteVersion(ObjectId versionId)
AtmosApiversionId - The ObjectId of the version to delete (must point to a version and not an object).public CreateAccessTokenResponse createAccessToken(CreateAccessTokenRequest request) throws java.net.MalformedURLException
AtmosApirequest - The request object (click on the class name to get more information)java.net.MalformedURLException - if the configured Atmos endpoint is syntactically invalid.public GetAccessTokenResponse getAccessToken(java.lang.String accessTokenId)
AtmosApiaccessTokenId - The ID of the access token.public void deleteAccessToken(java.lang.String accessTokenId)
AtmosApiaccessTokenId - The ID of the access token.public ListAccessTokensResponse listAccessTokens(ListAccessTokensRequest request)
AtmosApirequest - The request object (click on the class name to get more information)public <T> GenericResponse<T> execute(PreSignedRequest request, java.lang.Class<T> resultType, java.lang.Object content) throws java.net.URISyntaxException
AtmosApirequest - A pre-signed request generated by calling
AtmosApi.preSignRequest(com.emc.atmos.api.request.Request, java.util.Date).resultType - (optional) The type of object to return. This can be any object type supported by the
implementation.content - (optional) The body content to send in the request (i.e. the object content for a
create-object request). Can be any object type supported by the implementation.java.net.URISyntaxException - if the URL in the pre-signed request is syntactically invalid.protected com.sun.jersey.api.client.WebResource.Builder build(Request request)
protected com.sun.jersey.api.client.WebResource.Builder addHeaders(com.sun.jersey.api.client.WebResource.Builder builder,
java.util.Map<java.lang.String,java.util.List<java.lang.Object>> headers)
protected <T extends BasicResponse> T fillResponse(T response, com.sun.jersey.api.client.ClientResponse clientResponse)
protected java.lang.Object getContent(ContentRequest request)
public java.lang.String createSubtenant(CreateSubtenantRequest request)
AtmosApirequest - The CreateSubtenantRequest containing the parameters for
the new subtenant.