Amazon CloudFront CDN Service (http://aws.amazon.com/cloudfront)
2008.11.28
2006-2009 LifeNexus Digital, Inc., and contributors.
| Simplified BSD License | http://opensource.org/licenses/bsd-license.php |
| Tarzan | http://tarzan-aws.com |
| Amazon CloudFront | http://aws.amazon.com/cloudfront |
Container for all Amazon CloudFront-related methods. Inherits additional methods from TarzanCore.
TarzanCore
require_once('tarzan.class.php');
// Instantiate a new AmazonCloudFront object using the settings from the config.inc.php file.
$cdn = new AmazonCloudFront();
// Instantiate a new AmazonCloudFront object using these specific settings.
$cdn = new AmazonCloudFront($key, $secret_key);
public function __construct( $key = null, $secret_key = null )
The constructor
public
| key | string (Optional) Your Amazon API Key. If blank, it will look for the AWS_KEY constant. |
| secret_key | string (Optional) Your Amazon API Secret Key. If blank, it will look for the AWS_SECRET_KEY constant. |
boolean false if no valid values are set, otherwise true.
| Example Usage | http://tarzan-aws.com |
public function authenticate( $method = HTTP_GET, $path = null, $opt = null, $xml = null, $etag = null )
Authenticates a connection to CloudFront. This should not be used directly unless you’re writing custom methods for this class.
public
| method | string (Required) The HTTP method to use to connect. Accepts HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_DELETE, and HTTP_HEAD. |
| path | string (Optional) The endpoint path to make requests to. |
| opt | array (Optional) Associative array of parameters for authenticating. See the individual methods for allowed keys. |
| xml | string (Optional) The XML body content to send along in the request. |
| etag | string (Optional) The ETag value to pass along with the If-Match HTTP header. |
TarzanHTTPResponse object
http://docs.amazonwebservices.com
public function generate_config_xml( $origin, $caller_reference, $opt = null )
Used to generate the Distribution Config XML used in create_distribution() and set_distribution_config().
public
| origin | string (Required) The source S3 bucket to use for the CloudFront distribution. |
| caller_reference | string (Required) A unique identifier for the request. Must be generated on your own. A time stamp or hash is a good example. |
| opt | array (Optional) Associative array of parameters which can have the following keys: |
| CNAME | string | array (Optional) A DNS CNAME to use to map to the CloudFront distribution. If setting more than one, use an indexed array. Supports 1-10 CNAMEs. |
| Comment | integer (Optional) A comment to apply to the distribution. Cannot exceed 128 characters. |
| Enabled | string (Optional) Defaults to true. Use this to set Enabled to false. |
String DistributionConfig XML document.
| Example Usage | http://tarzan-aws.com |
| Related | generate_config_xml(), update_config_xml(), remove_cname() |
public function update_config_xml( $xml, $opt = null )
Used to update an existing DistributionConfig XML document.
public
| xml | SimpleXMLElement | TarzanHTTPResponse | string (Required) The source DistributionConfig XML to make updates to. Can be the SimpleXMLElement body of a get_distribution_config() response, the entire TarzanHTTPResponse of a get_distribution_config() response, or a string of XML generated by generate_config_xml() or update_config_xml(). |
| opt | array (Optional) Associative array of parameters which can have the following keys: |
| CNAME | string | array (Optional) This (these) value(s) will be ADDED to the existing list of CNAME values. To remove a CNAME value, see remove_cname(). |
| Comment | integer (Optional) This value will replace the existing value for ‘Comment’. Cannot exceed 128 characters. |
| Enabled | string (Optional) This value will replace the existing value for ‘Enabled’. |
String DistributionConfig XML document.
| Example Usage | http://tarzan-aws.com |
| Related | generate_config_xml(), update_config_xml(), remove_cname() |
public function remove_cname( $xml, $cname )
Used to remove one or more CNAMEs from a DistributionConfig XML document.
public
| xml | SimpleXMLElement | TarzanHTTPResponse | string (Required) The source DistributionConfig XML to make updates to. Can be the SimpleXMLElement body of a get_distribution_config() response, the entire TarzanHTTPResponse of a get_distribution_config() response, or a string of XML generated by generate_config_xml() or update_config_xml(). |
| cname | string | array (Optional) This (these) value(s) will be REMOVED from the existing list of CNAME values. To add a CNAME value, see update_config_xml(). |
String DistributionConfig XML document.
| Example Usage | http://tarzan-aws.com |
| Related | generate_config_xml(), update_config_xml(), remove_cname() |
public function create_distribution( $origin, $caller_reference, $opt = null )
The response echoes the DistributionConfig element and returns other metadata about the distribution. For more information, see Parts of a Basic Distribution. It takes a short time for CloudFront to propagate your new distribution’s information throughout the CloudFront system. For more information, see Eventual Consistency. You can have up to 100 distributions in the Amazon CloudFront system.
public
| origin | string (Required) The source S3 bucket to use for the CloudFront distribution. |
| caller_reference | integer (Required) A unique identifier for the request. Must be generated on your own. A timestamp could be good. |
| opt | array (Optional) Associative array of parameters which can have the following keys: |
| CNAME | string | array (Optional) A DNS CNAME to use to map to the CloudFront distribution. If setting more than one, use an indexed array. Supports 1-10 CNAMEs. |
| Comment | integer (Optional) A comment to apply to the distribution. Cannot exceed 128 characters. |
| Enabled | string (Optional) Defaults to true. Use this to set Enabled to false. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function list_distributions( $opt = null )
Gets a list of your distributions. By default, your entire list of distributions is returned in one single page. If the list is long, you can paginate it using the MaxItems and Marker parameters.
public
| opt | array (Required) Associative array of parameters which can have the following keys: |
| Marker | string (Optional) Use this when paginating results to indicate where in your list of distributions to begin. The results include distributions in the list that occur after the marker. To get the next page of results, set the Marker to the value of the NextMarker from the current page’s response (which is also the ID of the last distribution on that page). |
| MaxItems | integer (Optional) The maximum number of distributions you want in the response body. Maximum of 100. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function get_distribution_info( $distribution_id, $opt = null )
Gets information about a given distribution.
public
| distribution_id | string (Required) The distribution ID returned from create_distribution() or list_distributions(). |
| opt | array (Required) Associative array of parameters which can have the following keys: |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function delete_distribution( $distribution_id, $etag, $opt = null )
Deletes a disabled distribution. If you haven’t disabled the distribution, Amazon CloudFront returns a DistributionNotDisabled error. Use set_distribution_config() to disable a distribution before attempting to delete.
public
| distribution_id | string (Required) The distribution ID returned from create_distribution() or list_distributions(). |
| etag | string (Required) The ETag header value retrieved from a call to get_distribution_config(). |
| opt | array (Required) Associative array of parameters which can have the following keys: |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function get_distribution_config( $distribution_id, $opt = null )
Gets the current distribution config information for a given distribution ID.
public
| distribution_id | string (Required) The distribution ID returned from create_distribution() or list_distributions(). |
| opt | array (Required) Associative array of parameters which can have the following keys: |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function set_distribution_config( $distribution_id, $xml, $etag, $opt = null )
Sets a new distribution config for a given distribution ID.
public
| distribution_id | string (Required) The distribution ID returned from create_distribution() or list_distributions(). |
| xml | string (Required) The DistributionConfig XML generated by generate_config_xml() or update_config_xml(). |
| etag | string (Required) The ETag header value retrieved from a call to get_distribution_config(). |
| opt | array (Required) Associative array of parameters which can have the following keys: |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object