update_oai_xml ( $xml, $opt )

Updates the origin access identity (OAI) configureation XML used in create_oai().

Access

public

Parameters

Parameter

Type

Required

Description

$xml

CFSimpleXML
CFResponse
string

Required

The source configuration XML to make updates to. Can be the CFSimpleXML body of a get_oai_config() response, the entire CFResponse of a get_oai_config() response, or a string of XML generated by generate_oai_xml() or update_oai_xml().

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • Comment - string - Optional - Replaces the existing value for “Comment”. Cannot exceed 128 characters.

Returns

Type

Description

string

XML document.

Examples

Update the OAI configuration.

// Create a new CloudFront distribution from an S3 bucket.
$cdn = new AmazonCloudFront();

// Get the existing OAI configuration
$config = $cdn->get_oai_config('E3HV63EQPFPPOA');

// Was the request successful?
if ($config->isOK())
{
	// Grab the ETag header
	$etag = $config->header['etag'];

	// Update the configuration. (Returns XML.)
	$updated_xml = $cdn->update_oai_xml($config, array(
		'Comment' => 'This is my updated comment.'
	));

	// Update the OAI configuration.
	$response = $cdn->set_oai_config('E3HV63EQPFPPOA', $updated_xml, $etag);

	// Success?
	var_dump($response->isOK());
}
Result:
bool(true)

Related Methods

Source

Method defined in services/cloudfront.class.php | Toggle source view (26 lines) | View on GitHub

public function update_oai_xml($xml, $opt = null)
{
    // If we receive a full CFResponse object, only use the body.
    if ($xml instanceof CFResponse)
    {
        $xml = $xml->body;
    }

    // If we received a string of XML, convert it into a CFSimpleXML object.
    if (is_string($xml))
    {
        $xml = simplexml_load_string($xml, $this->parser_class);
    }

    // Update the comment, if we have one.
    if (isset($opt['Comment']) && isset($xml->Comment))
    {
        $xml->Comment = $opt['Comment'];
    }
    elseif (isset($opt['Comment']))
    {
        $xml->addChild('Comment', $opt['Comment']);
    }

    return $xml->asXML();
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback