|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jets3t.service.CloudFrontService
public class CloudFrontService
A service that handles communication with the Amazon CloudFront REST API, offering all the operations that can be performed on CloudFront distributions.
This class uses properties obtained through Jets3tProperties. For more information on
these properties please refer to
JetS3t Configuration
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_BUCKET_SUFFIX
|
static java.lang.String |
ENDPOINT
|
protected int |
internalErrorRetryMax
|
protected Jets3tProperties |
jets3tProperties
|
protected long |
timeOffset
The approximate difference in the current time between your computer and Amazon's servers, measured in milliseconds. |
static java.lang.String |
VERSION
|
static java.lang.String |
XML_NAMESPACE
|
| Constructor Summary | |
|---|---|
CloudFrontService(AWSCredentials awsCredentials)
Constructs the service with default properties. |
|
CloudFrontService(AWSCredentials awsCredentials,
java.lang.String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider,
Jets3tProperties jets3tProperties,
org.apache.commons.httpclient.HostConfiguration hostConfig)
Constructs the service and initialises its properties. |
|
| Method Summary | |
|---|---|
void |
authorizeHttpRequest(org.apache.commons.httpclient.HttpMethod httpMethod)
|
Distribution |
createDistribution(java.lang.String origin)
Create a CloudFront distribution for an S3 bucket that will be publicly available once created. |
Distribution |
createDistribution(java.lang.String origin,
java.lang.String callerReference,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus)
Create a CloudFront distribution for an S3 bucket. |
void |
deleteDistribution(java.lang.String id)
Delete a disabled distribution. |
void |
disableDistributionForDeletion(java.lang.String id)
Convenience method to disable a distribution that you intend to delete. |
AWSCredentials |
getAWSCredentials()
|
protected java.util.Date |
getCurrentTimeWithOffset()
Returns the current date and time, adjusted according to the time offset between your computer and an AWS server (as set by the RestUtils.getAWSTimeAdjustment() method). |
DistributionConfig |
getDistributionConfig(java.lang.String id)
Lookup configuration information for a distribution. |
Distribution |
getDistributionInfo(java.lang.String id)
Lookup information for a distribution. |
Distribution[] |
listDistributions()
List all your CloudFront distributions. |
Distribution[] |
listDistributions(int pagingSize)
List all your CloudFront distributions, with a given maximum number of Distribution items in each "page" of results. |
Distribution[] |
listDistributions(java.lang.String bucketName)
List the distributions for a given S3 bucket name, if any. |
protected void |
performRestRequest(org.apache.commons.httpclient.HttpMethod httpMethod,
int expectedResponseCode)
Performs an HTTP/S request by invoking the provided HttpMethod object. |
static java.lang.String |
sanitizeS3BucketName(java.lang.String proposedBucketName)
Sanitizes a proposed bucket name to ensure it is fully-specified rather than merely the bucket's short name. |
DistributionConfig |
updateDistributionConfig(java.lang.String id,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus)
Update the configuration of an existing distribution to change its CNAME aliases, comment or enabled status. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String ENDPOINT
public static final java.lang.String VERSION
public static final java.lang.String XML_NAMESPACE
public static final java.lang.String DEFAULT_BUCKET_SUFFIX
protected Jets3tProperties jets3tProperties
protected int internalErrorRetryMax
protected long timeOffset
getCurrentTimeWithOffset()
to obtain the current time with this offset factor included, and the
RestUtils.getAWSTimeAdjustment() method to calculate an offset value for your
computer based on a response from an AWS server.
| Constructor Detail |
|---|
public CloudFrontService(AWSCredentials awsCredentials,
java.lang.String invokingApplicationDescription,
org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider,
Jets3tProperties jets3tProperties,
org.apache.commons.httpclient.HostConfiguration hostConfig)
throws CloudFrontServiceException
awsCredentials - the AWS user credentials to use when communicating with CloudFrontinvokingApplicationDescription - a short description of the application using the service, suitable for inclusion in a
user agent string for REST/HTTP requests. Ideally this would include the application's
version number, for example: Cockpit/0.7.1 or My App Name/1.0.
May be null.credentialsProvider - an implementation of the HttpClient CredentialsProvider interface, to provide a means for
prompting for credentials when necessary. May be null.jets3tProperties - JetS3t properties that will be applied within this service. May be null.hostConfig - Custom HTTP host configuration; e.g to register a custom Protocol Socket Factory.
May be null.
CloudFrontServiceException
public CloudFrontService(AWSCredentials awsCredentials)
throws CloudFrontServiceException
awsCredentials - the AWS user credentials to use when communicating with CloudFront
CloudFrontServiceException| Method Detail |
|---|
public AWSCredentials getAWSCredentials()
protected java.util.Date getCurrentTimeWithOffset()
RestUtils.getAWSTimeAdjustment() method).
public void authorizeHttpRequest(org.apache.commons.httpclient.HttpMethod httpMethod)
throws java.lang.Exception
authorizeHttpRequest in interface AWSRequestAuthorizerhttpMethod - the request object
java.lang.Exception
protected void performRestRequest(org.apache.commons.httpclient.HttpMethod httpMethod,
int expectedResponseCode)
throws CloudFrontServiceException
httpMethod - the object containing a request target and all other information necessary to
perform the requestexpectedResponseCode - the HTTP response code that indicates a successful request. If the response code received
does not match this value an error must have occurred, so an exception is thrown.
CloudFrontServiceException - all exceptions are wrapped in a CloudFrontServiceException. Depending on the kind of error that
occurred, this exception may contain additional error information available from an XML
error response document.
public Distribution[] listDistributions(int pagingSize)
throws CloudFrontServiceException
pagingSize - the maximum number of distributions the CloudFront service will
return in each response message.
CloudFrontServiceException
public Distribution[] listDistributions()
throws CloudFrontServiceException
CloudFrontServiceException
public Distribution[] listDistributions(java.lang.String bucketName)
throws CloudFrontServiceException
bucketName - the name of the S3 bucket whose distributions will be returned.
CloudFrontServiceException
public Distribution createDistribution(java.lang.String origin)
throws CloudFrontServiceException
origin - the Amazon S3 bucket to associate with the distribution, specified as a full
S3 sub-domain path (e.g. 'jets3t.s3.amazonaws.com' for the 'jets3t' bucket)
CloudFrontServiceException
public Distribution createDistribution(java.lang.String origin,
java.lang.String callerReference,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus)
throws CloudFrontServiceException
origin - the Amazon S3 bucket to associate with the distribution, specified as a full
S3 sub-domain path (e.g. 'jets3t.s3.amazonaws.com' for the 'jets3t' bucket)callerReference - A user-set unique reference value that ensures the request can't be replayed
(max UTF-8 encoding size 128 bytes). This parameter may be null, in which
case your computer's local epoch time in milliseconds will be used.cnames - A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be a null or empty array.comment - An optional comment to describe the distribution in your own terms
(max 128 characters). May be null.enabled - Should the distribution should be enabled and publicly accessible upon creation?loggingStatus - Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.
CloudFrontServiceException
public Distribution getDistributionInfo(java.lang.String id)
throws CloudFrontServiceException
id - the distribution's unique identifier.
CloudFrontServiceException
public DistributionConfig getDistributionConfig(java.lang.String id)
throws CloudFrontServiceException
getDistributionInfo(String)
method.
id - the distribution's unique identifier.
CloudFrontServiceException
public DistributionConfig updateDistributionConfig(java.lang.String id,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus)
throws CloudFrontServiceException
This method performs all the steps necessary to update the configuration. It
first performs lookup on the distribution using
getDistributionConfig(String) to find its origin and caller reference
values, then uses this information to apply your configuration changes.
id - the distribution's unique identifier.cnames - A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be null, in which case the original CNAME aliases are retained.comment - An optional comment to describe the distribution in your own terms
(max 128 characters). May be null, in which case the original comment is retained.enabled - Should the distribution should be enabled and publicly accessible after the
configuration update?loggingStatus - Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.
CloudFrontServiceException
public void disableDistributionForDeletion(java.lang.String id)
throws CloudFrontServiceException
updateDistributionConfig(String, String[], String, boolean, LoggingStatus)
method with default values for most of the distribution's configuration
settings.
Warning: Do not use this method with distributions you intend to keep, because it will reset most of the distribution's configuration settings such as CNAMEs and logging status.
id - the distribution's unique identifier.
CloudFrontServiceException
public void deleteDistribution(java.lang.String id)
throws CloudFrontServiceException
This method performs many of the steps necessary to delete a disabled
distribution. It first performs lookup on the distribution using
getDistributionConfig(String) to find its ETag value, then uses
this information to delete the distribution.
Because it can take a long time (minutes) to disable a distribution, this task is not performed automatically by this method. In your own code, you need to verify that a distribution is disabled with a status of Deployed before you invoke this method.
id - the distribution's unique identifier.
CloudFrontServiceExceptionpublic static java.lang.String sanitizeS3BucketName(java.lang.String proposedBucketName)
proposedBucketName - the proposed S3 bucket name that will be sanitized.
DEFAULT_BUCKET_SUFFIX added, if necessary.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||